[FIX] sale_stock: unit price rounding

Rounding the unit price at that moment is a bad idea. Here is the use
case:
- Set the product 'Costing Method' to 'Real Price'
- Set the product 'Inventory Valuation' to 'Perpetual'
- Receive through a PO 9 products for a unit price of 115.80
- Receive through a PO 35 products for a unit price of 116.80
- Sell these 44 products thanks to a SO, generate and validate the
  invoice

On the Stock Output Account, the following entries will be generated:
- First PO --> 1042.20  = 9  * 115.80
- Second PO --> 4088.00 = 35 * 116.80
- Invoice --> 5130.22   = 44 * 116.596

116.596 is the average price of the two POs, but rounded. The issue is
that there are 2 cents of difference... Nice ;-)

The fix is to avoid the rounding of the unit price, since we don't even
store it on the account move line anyway.

opw-673976
This commit is contained in:
Nicolas Martinelli
2016-04-14 13:37:15 +02:00
parent 3705a868d1
commit 7ab2d0e647
+1 -1
View File
@@ -345,7 +345,7 @@ class AccountInvoiceLine(models.Model):
if qty_delivered == quantity:
break
price_unit = average_price_unit or price_unit
price_unit = uom_obj._compute_qty_obj(self.uom_id, price_unit, self.product_id.uom_id)
price_unit = uom_obj._compute_qty_obj(self.uom_id, price_unit, self.product_id.uom_id, round=False)
return price_unit