From 58d2429c481ec73e180cf9f8f8a55e8ac02a8506 Mon Sep 17 00:00:00 2001 From: micheledic Date: Sun, 22 Oct 2023 13:52:00 +0000 Subject: [PATCH] [IMP] mrp: new prepare move line finished vals to write custom values before the post_inventory closes odoo/odoo#146526 X-original-commit: 6f5519105787ead32d27658ac291ef18dac51698 Signed-off-by: William Henrotin (whe) --- addons/mrp/models/mrp_production.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 {