diff --git a/addons/mrp/models/mrp_production.py b/addons/mrp/models/mrp_production.py index 9713ed31031..b4538e381f7 100644 --- a/addons/mrp/models/mrp_production.py +++ b/addons/mrp/models/mrp_production.py @@ -1657,8 +1657,9 @@ class MrpProduction(models.Model): # the finish move can already be completed by the workorder. for move in finish_moves: move.quantity = float_round(order.qty_producing - order.qty_produced, precision_rounding=order.product_uom_id.rounding, rounding_method='HALF-UP') - if move.has_tracking != 'none' and order.lot_producing_id: - move.move_line_ids.lot_id = order.lot_producing_id + extra_vals = order._prepare_finished_extra_vals() + if extra_vals: + move.move_line_ids.write(extra_vals) # workorder duration need to be set to calculate the price of the product for workorder in order.workorder_ids: if workorder.state not in ('done', 'cancel'): @@ -2712,6 +2713,12 @@ class MrpProduction(models.Model): clean_action(action, self.env) return action + def _prepare_finished_extra_vals(self): + self.ensure_one() + if self.lot_producing_id: + return {'lot_id' : self.lot_producing_id.id} + return {} + def action_open_label_layout(self): view = self.env.ref('stock.product_label_layout_form_picking') return {