@@ -213,3 +213,67 @@ def test_get_device_to_use_filter_pickings(self):
213213 self .assertEqual (first_picking , self .pick1 )
214214 device = make_picking_batch ._compute_device_to_use (first_picking )
215215 self .assertEqual (device , self .device1 )
216+
217+ def test_device_used_for_first_picking_splitting_00 (self ):
218+ """Check the last device is used for splitting the first picking.
219+
220+ Default order is :: device3, device2, device1.
221+ The last device (device1) can not manage the only picking.
222+ So the picking will be split.
223+
224+ """
225+ # Keep only one picking and a heavy one
226+ self .pick1 .action_cancel ()
227+ self .pick2 .action_cancel ()
228+ product_big_1 = self ._create_product ("Unittest P1 voluminous" , 10 , 100 , 1 , 1 )
229+ self ._set_quantity_in_stock (self .stock_location , product_big_1 )
230+ self ._add_product_to_picking (self .pick3 , product_big_1 )
231+ make_picking_batch = self .make_picking_batch .create (
232+ {
233+ "user_id" : self .env .user .id ,
234+ "picking_type_ids" : [(4 , self .picking_type_1 .id )],
235+ "split_picking_exceeding_limits" : True ,
236+ # Add the device not in their default sort order
237+ "stock_device_type_ids" : [
238+ (4 , self .device1 .id ),
239+ (4 , self .device2 .id ),
240+ (4 , self .device3 .id ),
241+ ],
242+ }
243+ )
244+ first_picking = make_picking_batch ._get_first_picking ()
245+ # A split picking has been created
246+ self .assertTrue (first_picking != self .pick3 )
247+
248+ def test_device_used_for_first_picking_splitting_01 (self ):
249+ """Check the last device is used for splitting the first picking.
250+
251+ The last device (device2) can manage the only picking.
252+ So picking will not be split.
253+
254+ """
255+ # Keep only one picking and a heavy one.
256+ self .pick1 .action_cancel ()
257+ self .pick2 .action_cancel ()
258+ product_big_1 = self ._create_product ("Unittest P1 voluminous" , 10 , 100 , 1 , 1 )
259+ self ._set_quantity_in_stock (self .stock_location , product_big_1 )
260+ self ._add_product_to_picking (self .pick3 , product_big_1 )
261+ # Set the device order
262+ self .device1 .sequence = 10
263+ self .device3 .sequence = 20
264+ self .device2 .sequence = 30
265+ make_picking_batch = self .make_picking_batch .create (
266+ {
267+ "user_id" : self .env .user .id ,
268+ "picking_type_ids" : [(4 , self .picking_type_1 .id )],
269+ "split_picking_exceeding_limits" : True ,
270+ # Add the device not in their default sort order
271+ "stock_device_type_ids" : [
272+ (4 , self .device1 .id ),
273+ (4 , self .device2 .id ),
274+ (4 , self .device3 .id ),
275+ ],
276+ }
277+ )
278+ first_picking = make_picking_batch ._get_first_picking ()
279+ self .assertEqual (first_picking , self .pick3 )
0 commit comments