[FIX] stock: do not merge mts and mto moves together

When we have two moves of the same product and procurement method
different on both, we don't want to merge them, because if a mto and a
mts move are merged together, it is possible to wait for an incoming
that will nerver come as a part the merged move should be taken from
stock
This commit is contained in:
Josse Colpaert
2017-10-24 15:15:01 +02:00
committed by Pierre Masereel
parent 5a348bb6d1
commit 918dc4e6c4
2 changed files with 24 additions and 3 deletions
+3 -3
View File
@@ -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):
+21
View File
@@ -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.