From 3de6048314a8fc1fc02bdbe4a38f08810a669621 Mon Sep 17 00:00:00 2001 From: "Benjamin Boulle (bebo)" Date: Fri, 23 Jun 2023 09:24:30 +0000 Subject: [PATCH] [FIX] purchase: fixing wrong currency when autocompleting a vendor bill using l10n_in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before the fix, when trying to autocomplete a bill with a PO using India localization, the invoice lines would not get the same currency as the autocompleted PO. This is because with India localization, the journal_id gets updated at the same time of the currency_id, which recomputes and erases the currency set just before. I propose to update the currency at the end to avoid all sort of recomputation it could be subject to. opw-3374634 closes odoo/odoo#127657 X-original-commit: 7f37e523cffbe3d7d98fd7457b30e2fb93f453d5 Signed-off-by: Josse Colpaert Signed-off-by: Benjamin Boullé (bebo) --- addons/purchase/models/account_invoice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index a614c31f635..10b7992d0bc 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -54,10 +54,11 @@ class AccountMove(models.Model): # Copy data from PO invoice_vals = self.purchase_id.with_company(self.purchase_id.company_id)._prepare_invoice() - invoice_vals['currency_id'] = self.invoice_line_ids and self.currency_id or invoice_vals.get('currency_id') + new_currency_id = self.invoice_line_ids and self.currency_id or invoice_vals.get('currency_id') del invoice_vals['ref'] del invoice_vals['company_id'] # avoid recomputing the currency self.update(invoice_vals) + self.currency_id = new_currency_id # Copy purchase lines. po_lines = self.purchase_id.order_line - self.invoice_line_ids.mapped('purchase_line_id')