From 0f39ee9370b1fbe9684a29fec7e6fffbf3ba0755 Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Tue, 15 May 2018 17:22:56 +0200 Subject: [PATCH] [FIX] purchase: anglosaxon: use currency rates to determine whether or not to post price difference amount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before that, we compared the amounts naïvely, leading to possible errors in case the PO and invoices were made in different currencies. --- 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 36dad6857f5..8b068509539 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -218,7 +218,9 @@ class AccountInvoice(models.Model): price_unit_val_dif = price_unit - valuation_price_unit price_val_dif = price_before - interim_account_price - if inv.currency_id.compare_amounts(i_line.price_unit, i_line.purchase_line_id.price_unit) != 0 and acc: + po_line = i_line.purchase_line_id + po_line_price_unit_inv_cur = po_line.currency_id.with_context(date=po_line.order_id.date_order).compute(po_line.price_unit, inv.currency_id) + if inv.currency_id.compare_amounts(i_line.price_unit, po_line_price_unit_inv_cur) != 0 and acc: # If the unit prices have not changed and we have a # valuation difference, it means this difference is due to exchange rates, # so we don't create anything, the exchange rate entries will