Skip to content

Conversation

@eduezerouali-tecnativa
Copy link

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

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 17.0-add-account_vendor_bill_currency_by_partner branch from 5934d0d to 79e9e5b Compare November 26, 2025 16:34
@pedrobaeza pedrobaeza added this to the 17.0 milestone Nov 27, 2025
vendor_currency_id = fields.Many2one(
comodel_name="res.currency",
string="Currency",
help="This field set currency_id in vendor bill automatically",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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",

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 17.0-add-account_vendor_bill_currency_by_partner branch from 79e9e5b to 944ce37 Compare November 27, 2025 13:43
Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review OK

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 17.0-add-account_vendor_bill_currency_by_partner branch from 944ce37 to 62f6959 Compare November 27, 2025 16:59
@eduezerouali-tecnativa eduezerouali-tecnativa changed the title [17.0][ADD] account_vendor_bill_currency_by_partner: New module [17.0][ADD] account_invoice_currency_by_partner: New module Nov 27, 2025
@eduezerouali-tecnativa
Copy link
Author

eduezerouali-tecnativa commented Nov 27, 2025

I made improvements, and now its working with customer invoice too. Also add some test.
ping @victoralmau @pedrobaeza @sergio-teruel

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 17.0-add-account_vendor_bill_currency_by_partner branch 2 times, most recently from f27637b to 075fcb7 Compare November 27, 2025 17:06
Copy link
Member

@pedrobaeza pedrobaeza left a 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",
Copy link
Contributor

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...

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.

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 17.0-add-account_vendor_bill_currency_by_partner branch from 075fcb7 to 59545c7 Compare December 1, 2025 15:30
@eduezerouali-tecnativa
Copy link
Author

@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")
Copy link
Member

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...

Suggested change
@api.depends("partner_id.vendor_currency_id", "partner_id.customer_currency_id")
@api.depends("partner_id")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change done.

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 17.0-add-account_vendor_bill_currency_by_partner branch from 59545c7 to 1a6d6eb Compare December 1, 2025 15:42
from odoo.addons.base.tests.common import BaseCommon


class TestAccountMoveCurrency(BaseCommon):
Copy link
Member

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?

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.

Copy link
Contributor

@luisDIXMIT luisDIXMIT left a 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:

image

But when I create a vendor bill for that partner, the GBP currency is used.

image

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.

@eduezerouali-tecnativa
Copy link
Author

@luisDIXMIT I have checked, and when you create a vendor bill for that partner, EUR is used. Am I missing something?
We did not intend to change anything in the purchase workflow, but in any case, there is a supplier currency field that actually manages this.

@luisDIXMIT
Copy link
Contributor

@luisDIXMIT I have checked, and when you create a vendor bill for that partner, EUR is used. Am I missing something? We did not intend to change anything in the purchase workflow, but in any case, there is a supplier currency field that actually manages this.

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.

image

@eduezerouali-tecnativa eduezerouali-tecnativa force-pushed the 17.0-add-account_vendor_bill_currency_by_partner branch from 1a6d6eb to 777133f Compare December 31, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants