[FIX] purchase: prevent rounding during currency conversion

With the settings:
- Anglo saxon accounting
- real price on product, perpetual accounting,
- multicurrency
- a product with a very small uom (like gram or kilograms and you want to sell many of them, like 500kg)

Flow: purchasing something in another currency

Before this commit, the rounding of the unit price took place right at the conversion level
which led the rounding errors to be amplified by the quantities when the total price was computed

After this commit, the conversion is done on the unit price but is not rounded yet
Only the prices are rounded, as late as possible

OPW 742293

Closes #17015
This commit is contained in:
Lucas Perais (lpe)
2017-05-22 09:01:39 +02:00
parent 7eda91ce58
commit 02ce25ba01
+1 -1
View File
@@ -156,7 +156,7 @@ class AccountInvoice(models.Model):
valuation_price_unit = valuation_price_unit_total / valuation_total_qty
valuation_price_unit = i_line.product_id.uom_id._compute_price(valuation_price_unit, i_line.uom_id)
if inv.currency_id.id != company_currency.id:
valuation_price_unit = company_currency.with_context(date=inv.date_invoice).compute(valuation_price_unit, inv.currency_id)
valuation_price_unit = company_currency.with_context(date=inv.date_invoice).compute(valuation_price_unit, inv.currency_id, round=False)
if valuation_price_unit != i_line.price_unit and line['price_unit'] == i_line.price_unit and acc:
# price with discount and without tax included
price_unit = i_line.price_unit * (1 - (i_line.discount or 0.0) / 100.0)