[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.

Goffin Simon 7 years ago
parent f1ed73e5ea
commit 1995c347b6

@ -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
#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€