From dcef43aaa7787c5ca3e0ad32848dae46b7d64a95 Mon Sep 17 00:00:00 2001 From: Michael Tietz Date: Thu, 10 Aug 2023 22:20:20 +0200 Subject: [PATCH] [IMP] shopfloor: zone picking is package not valid - a package is now also not valid if it already contains move lines from an other picking type --- shopfloor/actions/message.py | 8 +++++++ shopfloor/services/zone_picking.py | 37 +++++++++++++++++++----------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/shopfloor/actions/message.py b/shopfloor/actions/message.py index c5bcf1365a0..62969334193 100644 --- a/shopfloor/actions/message.py +++ b/shopfloor/actions/message.py @@ -126,6 +126,14 @@ def package_already_used(self, package): "body": _("Package {} is already used.").format(package.name), } + def package_different_picking_type(self, package, picking_type): + return { + "message_type": "warning", + "body": _( + "Package {} contains already lines from a different operation type {}" + ).format(package.name, picking_type.name), + } + def dest_package_required(self): return { "message_type": "warning", diff --git a/shopfloor/services/zone_picking.py b/shopfloor/services/zone_picking.py index 73b4ec3fb65..e010bd2c944 100644 --- a/shopfloor/services/zone_picking.py +++ b/shopfloor/services/zone_picking.py @@ -940,25 +940,34 @@ def _move_line_full_qty(self, move_line, qty): move_line.product_uom_qty - qty, precision_rounding=rounding ) - def _set_destination_package(self, move_line, quantity, package): - package_changed = False - response = None + def _is_package_not_valid(self, package): + message = False # A valid package is: # * an empty package # * not used as destination for another move line + # * not contains move lines with different operation type if not self._is_package_empty(package): + message = self.msg_store.package_not_empty(package) + elif package.planned_move_line_ids: + if not self.work.menu.multiple_move_single_pack: + message = self.msg_store.package_already_used(package) + else: + for line in package.planned_move_line_ids: + if line.picking_id.picking_type_id.id in self.picking_types.ids: + continue + message = self.msg_store.package_different_picking_type( + package, line.picking_id.picking_type_id + ) + break + return message + + def _set_destination_package(self, move_line, quantity, package): + package_changed = False + response = None + package_invalid_message = self._is_package_not_valid(package) + if package_invalid_message: response = self._response_for_set_line_destination( - move_line, - message=self.msg_store.package_not_empty(package), - qty_done=quantity, - ) - return (package_changed, response) - multiple_move_allowed = self.work.menu.multiple_move_single_pack - if package.planned_move_line_ids and not multiple_move_allowed: - response = self._response_for_set_line_destination( - move_line, - message=self.msg_store.package_already_used(package), - qty_done=quantity, + move_line, message=package_invalid_message, qty_done=quantity ) return (package_changed, response) # the quantity done is set to the passed quantity