-
-
Notifications
You must be signed in to change notification settings - Fork 770
[17.0][ADD] account_invoice_currency_by_partner: New module #2177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 17.0
Are you sure you want to change the base?
[17.0][ADD] account_invoice_currency_by_partner: New module #2177
Conversation
5934d0d to
79e9e5b
Compare
| vendor_currency_id = fields.Many2one( | ||
| comodel_name="res.currency", | ||
| string="Currency", | ||
| help="This field set currency_id in vendor bill automatically", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| help="This field set currency_id in vendor bill automatically", | |
| help="If field, this value is set as currency in vendor bills for this partner", |
79e9e5b to
944ce37
Compare
victoralmau
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review OK
944ce37 to
62f6959
Compare
|
I made improvements, and now its working with customer invoice too. Also add some test. |
f27637b to
075fcb7
Compare
pedrobaeza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check independently if each field is filled, or you may assign an empty value.
| ) | ||
| customer_currency_id = fields.Many2one( | ||
| comodel_name="res.currency", | ||
| string="Currency", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use the same label for both fields...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, anyways open to suggestions for the label.
075fcb7 to
59545c7
Compare
|
@pedrobaeza did add another condition before assigning the value. |
| class AccountMove(models.Model): | ||
| _inherit = "account.move" | ||
|
|
||
| @api.depends("partner_id.vendor_currency_id", "partner_id.customer_currency_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Watch out! You shouldn't put a dependency that affects previous records. Imagine all the past invoices being changed because you now change the currency in the partner...
| @api.depends("partner_id.vendor_currency_id", "partner_id.customer_currency_id") | |
| @api.depends("partner_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change done.
59545c7 to
1a6d6eb
Compare
| from odoo.addons.base.tests.common import BaseCommon | ||
|
|
||
|
|
||
| class TestAccountMoveCurrency(BaseCommon): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not depending on AccountInvoicingCommon for avoiding most of the stuff and be sure the CoA is loaded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, did not know much about AccountTestInvoicingCommon, but after a quick research this will make sure account.move works correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have this setting:
But when I create a vendor bill for that partner, the GBP currency is used.
On the other hand, I created a purchase order and the currency was USD, which was expected. But then I created an invoice from that purchase order and the currency was still USD, even though I’ve set GBP for vendor bills. Maybe this is the expected behaviour to maintain consistency between the purchase order and the invoice. Let me know.
|
@luisDIXMIT I have checked, and when you create a vendor bill for that partner, EUR is used. Am I missing something? |
Yes, you're right. I’ve now run the same test and it works. However, when I tested with a customer invoice, the currency wasn’t updated, and I even got this error when saving the invoice. The pricelist currency is USD, and the invoice shows USD as well (maybe the correct GBP currency is being used in the background? I’m not sure). Anyway, I don’t intend to block this PR.
|
1a6d6eb to
777133f
Compare

cc @Tecnativa TT59474
New module that lets you set a default currency on a partner, which is then automatically applied to vendor bills.
ping @sergio-teruel @pedrobaeza