@@ -256,6 +256,40 @@ def test_change_lot_reserved_qty(self):
256256 line2 , lambda : line2 .quantity_product_uom , lot = initial_lot
257257 )
258258
259+ def test_change_lot_reserved_qty_same_picking (self ):
260+ """Scan a lot already reserved by other lines in the same picking.
261+
262+ It should NOT unreserve the other line, use the lot for the current line,
263+ and swap the lot to the other move.
264+ """
265+ initial_lot1 = self ._create_lot (self .product_a )
266+ initial_lot2 = self ._create_lot (self .product_a )
267+ self ._update_qty_in_location (self .shelf1 , self .product_a , 10 , lot = initial_lot1 )
268+ self ._update_qty_in_location (self .shelf1 , self .product_a , 10 , lot = initial_lot2 )
269+ picking = self ._create_picking (lines = [(self .product_a , 20 )])
270+ picking .action_assign ()
271+ line1 = picking .move_line_ids [0 ]
272+ line2 = picking .move_line_ids [1 ]
273+ self .assertEqual (line1 .lot_id , initial_lot1 )
274+ self .assertEqual (line2 .lot_id , initial_lot2 )
275+
276+ # swap lot 2 on line 1
277+ self ._change_lot (line1 , initial_lot2 )
278+ self .assertRecordValues (
279+ line1 , [{"lot_id" : initial_lot2 .id , "quantity_product_uom" : 10 }]
280+ )
281+ # line 2 has been assigned to lot 1
282+ self .assertRecordValues (
283+ line2 , [{"lot_id" : initial_lot1 .id , "quantity_product_uom" : 10 }]
284+ )
285+ # check that reservations have been updated
286+ self .assert_quant_reserved_qty (
287+ line1 , lambda : line1 .quantity_product_uom , lot = initial_lot2
288+ )
289+ self .assert_quant_reserved_qty (
290+ line2 , lambda : line2 .quantity_product_uom , lot = initial_lot1
291+ )
292+
259293 def test_change_lot_reserved_partial_qty (self ):
260294 """Scan a lot already reserved by other lines and can only be reserved
261295 partially
@@ -340,7 +374,7 @@ def test_change_lot_reserved_qty_done(self):
340374 )
341375
342376 def test_change_lot_different_location (self ):
343- "If the scanned lot is in a different location, we cannot process it"
377+ """ If the scanned lot is in a different location, we cannot process it"" "
344378 initial_lot = self ._create_lot (self .product_a )
345379 self ._update_qty_in_location (self .shelf1 , self .product_a , 10 , lot = initial_lot )
346380 picking = self ._create_picking (lines = [(self .product_a , 10 )])
0 commit comments