@@ -60,6 +60,7 @@ def setUpClass(cls):
6060 ],
6161 }
6262 )
63+ cls .stock_location = cls .env .ref ("stock.stock_location_stock" )
6364
6465 @classmethod
6566 def _get_kit_quantity (cls , picking , bom ):
@@ -73,6 +74,16 @@ def _get_kit_quantity(cls, picking, bom):
7374 )
7475 return kit_quantity
7576
77+ @classmethod
78+ def _set_quantity_in_stock (cls , location , product , qty = 10 ):
79+ cls .env ["stock.quant" ].create (
80+ {
81+ "location_id" : location .id ,
82+ "product_id" : product .id ,
83+ "inventory_quantity" : qty ,
84+ }
85+ ).action_apply_inventory ()
86+
7687 def _check_move_lines (self , picking , move_lines ):
7788 moves = []
7889 for move in picking .move_ids :
@@ -127,6 +138,34 @@ def test_split_picking_kit_single_split(self):
127138 "1 kit is left in the original picking" ,
128139 )
129140
141+ def test_split_assigned_picking_kit_single_split (self ):
142+ """Check reservation is decreased if needed.
143+
144+ Number of kits is 3 and the split limit is 2.
145+
146+ """
147+ self ._set_quantity_in_stock (
148+ self .stock_location , self .product_garden_table_leg , qty = 12
149+ )
150+ self ._set_quantity_in_stock (
151+ self .stock_location , self .product_garden_table_top , qty = 3
152+ )
153+ picking = self ._create_picking ()
154+ self ._create_stock_move (self .product_garden_table , picking , qty = 3 )
155+ picking .action_confirm ()
156+ picking .action_assign ()
157+ self .assertEqual (picking .state , "assigned" )
158+ self .assertEqual (picking .move_ids .mapped ("quantity" ), [12.0 , 3.0 ])
159+
160+ with RecordCapturer (self .env ["stock.picking" ], []) as rc_picking :
161+ self ._split_picking (picking , mode = "kit_quantity" , kit_split_quantity = 2 )
162+ new_picking = rc_picking .records
163+
164+ self .assertEqual (new_picking .state , "assigned" , "New picking is assigned" )
165+ self .assertEqual (picking .state , "assigned" , "Original picking is assigned" )
166+ self .assertEqual (picking .move_ids .mapped ("quantity" ), [4.0 , 1.0 ])
167+ self .assertEqual (new_picking .move_ids .mapped ("quantity" ), [8.0 , 2.0 ])
168+
130169 def test_split_picking_kit_with_no_kit (self ):
131170 """Check split picking only has non kit product.
132171
0 commit comments