Skip to content

Commit

Permalink
[REF] ref unload_end for better inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Dec 2, 2023
1 parent 0d339e8 commit a5062fc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,17 +1122,19 @@ def set_destination_all(self, picking_batch_id, barcode, confirmation=False):
def _unload_write_destination_on_lines(self, lines, location):
lines.write({"shopfloor_unloaded": True, "location_dest_id": location.id})
lines.package_level_id.location_dest_id = location
for line in lines:
# We set the picking to done only when the last line is
# unloaded to avoid backorders.
picking = line.picking_id
if picking.state == "done":
continue
picking_lines = picking.mapped("move_line_ids")
if all(line.shopfloor_unloaded for line in picking_lines):
picking._action_done()
for picking in lines.batch_id.picking_ids:
picking_lines = lines.filtered(lambda l, p=picking: l.picking_id == p)
self._unload_set_picking_to_done(picking, picking_lines)

def _unload_set_picking_to_done(self, picking, picking_lines):
if picking.state == "done":
return
# We set the picking to done only when the last line is
# unloaded to avoid backorders.
if all(line.shopfloor_unloaded for line in picking.move_line_ids):
picking._action_done()
if self.work.menu.unload_package_at_destination:
lines.result_package_id = False
picking_lines.result_package_id = False

def _unload_end(self, batch, completion_info_popup=None):
"""Try to close the batch if all transfers are done.
Expand Down

0 comments on commit a5062fc

Please sign in to comment.