Skip to content

Commit 305181b

Browse files
committed
stock_picking_batch_creation: fix stock device order
Before this change when searching for a device to use for the batch, the order of the devices was not guaranteed although important. And it could cause some batch split not happening. Now the possible devices will be sorted by their default order, which is by sequence and name.
1 parent f8ffab7 commit 305181b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

stock_picking_batch_creation/wizards/make_picking_batch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def _execute_search_pickings(self, domain, limit=None):
263263
)
264264

265265
def _split_first_picking_for_limit(self, picking):
266-
last_device = self.stock_device_type_ids[-1]
266+
last_device = self.stock_device_type_ids.sorted()[-1]
267267
if last_device.split_mode == "dimension":
268268
return (
269269
self.env["stock.split.picking"]
@@ -291,7 +291,7 @@ def _is_picking_exceeding_limits(self, picking):
291291
):
292292
return True
293293
# Then, check the device limits
294-
last_device = self.stock_device_type_ids[-1]
294+
last_device = self.stock_device_type_ids.sorted()[-1]
295295
if last_device.split_mode == "dimension":
296296
if last_device.max_volume and picking.volume > last_device.max_volume:
297297
return True
@@ -363,7 +363,7 @@ def _get_remaining_volume(self, partner=False):
363363
return remaining_volume
364364

365365
def _compute_device_to_use(self, picking):
366-
for device in self.stock_device_type_ids.sorted("sequence"):
366+
for device in self.stock_device_type_ids.sorted():
367367
if picking.filtered_domain(self._get_picking_domain_for_device(device)):
368368
return device
369369
return self.env["stock.device.type"]

0 commit comments

Comments
 (0)