From 1995c347b658f4123457bad5bb84ccb885a805d6 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Tue, 15 Dec 2015 14:32:39 +0100 Subject: [PATCH] [FIX] stock_account: _store_average_cost_price The function "_store_average_cost_price" doesn't have to update the average cost price of a product if qty of the product in the move is equal to zero. opw:659329 --- addons/stock_account/stock_account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_account/stock_account.py b/addons/stock_account/stock_account.py index 63c4a542e16..41aae4a84fb 100644 --- a/addons/stock_account/stock_account.py +++ b/addons/stock_account/stock_account.py @@ -276,7 +276,7 @@ class stock_move(osv.osv): def _store_average_cost_price(self, cr, uid, move, context=None): ''' move is a browe record ''' product_obj = self.pool.get('product.product') - if any([q.qty <= 0 for q in move.quant_ids]): + if any([q.qty <= 0 for q in move.quant_ids]) or move.product_qty == 0: #if there is a negative quant, the standard price shouldn't be updated return #Note: here we can't store a quant.cost directly as we may have moved out 2 units (1 unit to 5€ and 1 unit to 7€) and in case of a product return of 1 unit, we can't know which of the 2 costs has to be used (5€ or 7€?). So at that time, thanks to the average valuation price we are storing we will svaluate it at 6€