[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
This commit is contained in:
sofiagvaladze
2022-08-10 16:08:06 +02:00
parent 6673a9c965
commit 7abf1b33f0
+1 -1
View File
@@ -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