diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index c9a50f3f704..70c9fe55d14 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -498,9 +498,12 @@ class StockMove(models.Model): self._push_apply() return self + def _set_default_price_moves(self): + return self.filtered(lambda move: not move.price_unit) + def set_default_price_unit_from_product(self): """ Set price to move, important in inter-company moves or receipts with only one partner """ - for move in self.filtered(lambda move: not move.price_unit): + for move in self._set_default_price_moves(): move.write({'price_unit': move.product_id.standard_price}) attribute_price = set_default_price_unit_from_product diff --git a/addons/stock_account/models/stock.py b/addons/stock_account/models/stock.py index e5087c67814..074a0ab748d 100644 --- a/addons/stock_account/models/stock.py +++ b/addons/stock_account/models/stock.py @@ -173,6 +173,12 @@ class StockQuant(models.Model): class StockMove(models.Model): _inherit = "stock.move" + def _set_default_price_moves(self): + # When the cost method is in real or average price, the price can be set to 0.0 on the PO + # So the price doesn't have to be updated + moves = super(StockMove, self)._set_default_price_moves() + return moves.filtered(lambda m: not m.product_id.cost_method in ('real', 'average')) + @api.multi def action_done(self): self.product_price_update_before_done()