From 07b192b8efde169fad09c43338e340d3f81bb115 Mon Sep 17 00:00:00 2001 From: Arnold Moyaux <arm@odoo.com> Date: Mon, 8 May 2023 14:39:18 +0000 Subject: [PATCH] [FIX] mrp: merge moves in pick before manufacturing Use case: It happens that a product is consumed in different operations. So it needs two distinct BoM lines. Since commit [1] the stock.move in pbm are not merged. However [1] was design for kit. In our case we would like to have only one stock.move for all the quantities. The fix is not perfect because it won't work if we confirm at the same time a move with a kit and without it. But at least it will let people using MO without kit has the correct behavior + remove a duplicate of the function [1] commit 741d2fe9efff6529eda0f516754639edcf4a7a35 closes odoo/odoo#120835 Signed-off-by: William Henrotin (whe) <whe@odoo.com> --- addons/mrp/models/stock_move.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/addons/mrp/models/stock_move.py b/addons/mrp/models/stock_move.py index cd986d0961ab..ed41b595e8cb 100644 --- a/addons/mrp/models/stock_move.py +++ b/addons/mrp/models/stock_move.py @@ -120,12 +120,6 @@ class StockMove(models.Model): for move in self: move.order_finished_lot_ids = move.raw_material_production_id.lot_producing_id - @api.model - def _prepare_merge_moves_distinct_fields(self): - distinct_fields = super()._prepare_merge_moves_distinct_fields() - distinct_fields.append('bom_line_id') - return distinct_fields - @api.depends('raw_material_production_id.bom_id') def _compute_allowed_operation_ids(self): for move in self: @@ -380,7 +374,8 @@ class StockMove(models.Model): def _prepare_merge_moves_distinct_fields(self): distinct_fields = super()._prepare_merge_moves_distinct_fields() distinct_fields.append('created_production_id') - distinct_fields.append('bom_line_id') + if self.bom_line_id and ("phantom" in self.bom_line_id.bom_id.mapped('type')): + distinct_fields.append('bom_line_id') return distinct_fields @api.model -- GitLab