diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index 4c33b0df245..fe89547e200 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -184,6 +184,7 @@ class StockMove(models.Model): def product_price_update_before_done(self): tmpl_dict = defaultdict(lambda: 0.0) # adapt standard price on incomming moves if the product cost_method is 'average' + std_price_update = {} for move in self.filtered(lambda move: move.location_id.usage == 'supplier' and move.product_id.cost_method == 'average'): product_tot_qty_available = move.product_id.qty_available + tmpl_dict[move.product_id.id] @@ -192,12 +193,13 @@ class StockMove(models.Model): new_std_price = move.get_price_unit() else: # Get the standard price - amount_unit = move.product_id.standard_price + amount_unit = std_price_update.get(move.product_id.id) or move.product_id.standard_price new_std_price = ((amount_unit * product_tot_qty_available) + (move.get_price_unit() * move.product_qty)) / (product_tot_qty_available + move.product_qty) tmpl_dict[move.product_id.id] += move.product_qty # Write the standard price, as SUPERUSER_ID because a warehouse manager may not have the right to write on products move.product_id.with_context(force_company=move.company_id.id).write({'standard_price': new_std_price}) + std_price_update[move.product_id.id] = new_std_price @api.multi def product_price_update_after_done(self):