From 7abf1b33f03d4c7bb631b7953cff7626d81cf74f Mon Sep 17 00:00:00 2001 From: sofiagvaladze Date: Mon, 25 Jul 2022 15:51:31 +0000 Subject: [PATCH] [FIX] sale: always round price_unit In case there is no need for currency conversion, the return value of _sale_get_invoice_price is not rounded. While, when currency conversion takes place, the return value is rounded. First of all, the behavior is not universal, It should be the same across these cases. Secondly, not rounding the return value causes discrepancy when computing margin (in the sale_margin module) for expense products; as price_unit is not rounded (in the first case), while purchase_price is rounded. task - 2867723 Part-of: odoo/odoo#96981 --- addons/sale/models/account_move_line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sale/models/account_move_line.py b/addons/sale/models/account_move_line.py index c9fc6af130c..b36ef138b7c 100644 --- a/addons/sale/models/account_move_line.py +++ b/addons/sale/models/account_move_line.py @@ -196,7 +196,7 @@ class AccountMoveLine(models.Model): # Prevent unnecessary currency conversion that could be impacted by exchange rate # fluctuations if self.company_id.currency_id and amount and self.company_id.currency_id == order.currency_id: - return abs(amount / unit_amount) + return self.company_id.currency_id.round(abs(amount / unit_amount)) price_unit = abs(amount / unit_amount) currency_id = self.company_id.currency_id