diff --git a/addons/stock/models/stock_move.py b/addons/stock/models/stock_move.py index f37554cf583..0ad0284b60b 100644 --- a/addons/stock/models/stock_move.py +++ b/addons/stock/models/stock_move.py @@ -517,7 +517,7 @@ class StockMove(models.Model): @api.model def _prepare_merge_moves_distinct_fields(self): return [ - 'product_id', 'price_unit', 'product_packaging', + 'product_id', 'price_unit', 'product_packaging', 'procure_method', 'product_uom', 'restrict_partner_id', 'scrapped', 'origin_returned_move_id' ] @@ -525,8 +525,8 @@ class StockMove(models.Model): def _prepare_merge_move_sort_method(self, move): move.ensure_one() return [ - move.product_id.id, move.price_unit, move.product_packaging.id, move.product_uom.id, - move.restrict_partner_id.id, move.scrapped, move.origin_returned_move_id.id + move.product_id.id, move.price_unit, move.product_packaging.id, move.procure_method, + move.product_uom.id, move.restrict_partner_id.id, move.scrapped, move.origin_returned_move_id.id ] def _merge_moves(self): diff --git a/addons/stock/tests/test_move2.py b/addons/stock/tests/test_move2.py index 2a9625bb2f4..f6653593913 100644 --- a/addons/stock/tests/test_move2.py +++ b/addons/stock/tests/test_move2.py @@ -24,6 +24,7 @@ class TestPickShip(TestStockCommon): 'location_id': self.pack_location, 'location_dest_id': self.customer_location, 'state': 'waiting', + 'procure_method': 'make_to_order', }) picking_pick = self.env['stock.picking'].create({ @@ -509,6 +510,26 @@ class TestPickShip(TestStockCommon): self.assertEqual(set(return_pick_picking.move_lines.move_orig_ids.ids), set((picking_pick.move_lines | return_pack_picking.move_lines).ids)) self.assertEqual(len(return_pick_picking.move_lines.move_dest_ids), 0) + def test_merge_move_mto_mts(self): + """ Create 2 moves of the same product in the same picking with + one in 'MTO' and the other one in 'MTS'. The moves shouldn't be merged + """ + picking_pick, picking_client = self.create_pick_ship() + + self.MoveObj.create({ + 'name': self.productA.name, + 'product_id': self.productA.id, + 'product_uom_qty': 3, + 'product_uom': self.productA.uom_id.id, + 'picking_id': picking_client.id, + 'location_id': self.stock_location, + 'location_dest_id': self.customer_location, + 'origin': 'MPS', + 'procure_method': 'make_to_stock', + }) + picking_client.action_confirm() + self.assertEqual(len(picking_client.move_lines), 2, 'Moves should not be merged') + class TestSinglePicking(TestStockCommon): def test_backorder_1(self): """ Check the good behavior of creating a backorder for an available stock move.