[FIX] purchase: _anglo_saxon_purchase_move_lines

Since the stock valuation refactoring, the price_unit on out move are
negatives. This brought an issue when _anglo_saxon_purchase_move_lines
tried to get the amount of the accounting entry in the stock received
account when validating a credit note for a return: as the price_unit
total resulted in 0, the entry was taken from the price difference
account.

Fixes #20840
opw 781836
This commit is contained in:
Simon Lejeune
2017-11-20 17:08:25 +01:00
parent 2d5ae3c4ff
commit 5e48193654
+1 -1
View File
@@ -159,7 +159,7 @@ class AccountInvoice(models.Model):
valuation_price_unit_total = 0
valuation_total_qty = 0
for val_stock_move in valuation_stock_move:
valuation_price_unit_total += val_stock_move.price_unit * val_stock_move.product_qty
valuation_price_unit_total += abs(val_stock_move.price_unit) * val_stock_move.product_qty
valuation_total_qty += val_stock_move.product_qty
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)