From 10a9287f2e9df12a0be978b92f264d20b9fc5c60 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 22 Dec 2016 15:12:35 +0100 Subject: [PATCH] [FIX] sale: expense price unit The company currency is EUR, and GBP rates are: - 0.8414 at day 1 - 0.8389 at day 2 Then: - Create a SO in GBP at day 1 and confirm - Create an expense in GBP at day 2 and choose the analytic account of the SO - Validate the expense and post the journal entries Problem: - The amount of the expense is 93 GBP - The amount of the sale order line is 93.28 GBP opw-696375 --- addons/sale/sale_analytic.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/sale/sale_analytic.py b/addons/sale/sale_analytic.py index 4b20d388c3e..622d2520c63 100644 --- a/addons/sale/sale_analytic.py +++ b/addons/sale/sale_analytic.py @@ -47,6 +47,12 @@ class AccountAnalyticLine(models.Model): def _get_invoice_price(self, order): if self.unit_amount == 0.0: return 0.0 + + # Prevent unnecessary currency conversion that could be impacted by exchange rate + # fluctuations + if self.currency_id and self.amount_currency and self.currency_id == order.currency_id: + return abs(self.amount_currency / self.unit_amount) + price_unit = abs(self.amount / self.unit_amount) currency_id = self.company_id.currency_id if currency_id and currency_id != order.currency_id: