[FIX] purchase: fixing wrong currency when autocompleting a vendor bill using l10n_in

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 <jco@odoo.com>
Signed-off-by: Benjamin Boullé (bebo) <bebo@odoo.com>
This commit is contained in:
Benjamin Boulle (bebo)
2023-07-13 14:47:50 +02:00
committed by Boullé Benjamin (bebo)
parent 9e0277eeec
commit 3de6048314
+2 -1
View File
@@ -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')