From d8112b02387df0c0eff92d13e14259292b5ed0e9 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 12 Jan 2018 13:56:26 +0100 Subject: [PATCH] [FIX] purchase: change invoice date - Create a PO, generate the vendor bill - Change a price unit - Change the invoice date The price unit is reset to the PO value. We only recompute it if the currency of the invoice is different from the currency of the PO. Fixes #22164 opw-804894 --- addons/purchase/models/account_invoice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 43ffb17dddf..90c86f82d55 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -89,7 +89,9 @@ class AccountInvoice(models.Model): def _onchange_currency_id(self): if self.currency_id: for line in self.invoice_line_ids.filtered(lambda r: r.purchase_line_id): - line.price_unit = line.purchase_id.currency_id.with_context(date=self.date_invoice).compute(line.purchase_line_id.price_unit, self.currency_id, round=False) + if line.purchase_id.currency_id != self.currency_id: + line.price_unit = line.purchase_id.currency_id.with_context(date=self.date_invoice)\ + .compute(line.purchase_line_id.price_unit, self.currency_id, round=False) @api.onchange('invoice_line_ids') def _onchange_origin(self):