Skip to content

Commit

Permalink
[IMP] shopfloor: zone picking is package not valid
Browse files Browse the repository at this point in the history
- a package is now also not valid
  if it already contains move lines from
  an other picking type
  • Loading branch information
mt-software-de committed Aug 11, 2023
1 parent 4a45e54 commit ea3782a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 14 deletions.
8 changes: 8 additions & 0 deletions shopfloor/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
36 changes: 22 additions & 14 deletions shopfloor/services/zone_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,25 +940,33 @@ 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)
elif any(
line.picking_id.picking_type_id.id not in self.picking_types.ids
for line in package.planned_move_line_ids
):
message = self.msg_store.package_different_picking_type(
package, line.picking_id.picking_type_id
)
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
Expand Down

0 comments on commit ea3782a

Please sign in to comment.