From 5e481936541f1796ea57f8b420e963ec93df0d64 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Mon, 20 Nov 2017 16:20:00 +0100 Subject: [PATCH] [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 --- addons/purchase/models/account_invoice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/models/account_invoice.py b/addons/purchase/models/account_invoice.py index 953f4557753e6..c9b868b63b928 100644 --- a/addons/purchase/models/account_invoice.py +++ b/addons/purchase/models/account_invoice.py @@ -159,7 +159,7 @@ def _anglo_saxon_purchase_move_lines(self, i_line, res): 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)