Skip to content

Commit

Permalink
Merge PR #720 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by simahawk
  • Loading branch information
OCA-git-bot committed Aug 23, 2023
2 parents 85784c0 + 9cc0168 commit eca0449
Show file tree
Hide file tree
Showing 3 changed files with 66 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
37 changes: 23 additions & 14 deletions shopfloor/services/zone_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,25 +941,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
Expand Down
35 changes: 35 additions & 0 deletions shopfloor/tests/test_zone_picking_set_line_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,41 @@ def test_set_same_destination_package_multiple_moves(self):
message=self.service.msg_store.confirm_pack_moved(),
)

def test_set_same_destination_package_different_picking_type(self):
self.menu.sudo().write({"multiple_move_single_pack": True})
picking_type1 = self.picking1.picking_type_id
self._update_qty_in_location(
picking_type1.default_location_src_id, self.product_a, 100
)
picking_type = picking_type1.sudo().copy(
{"name": "test", "shopfloor_menu_ids": False}
)
picking = self._create_picking(
picking_type=picking_type, lines=[(self.product_a, 10)]
)
self.assertEqual(picking.picking_type_id, picking_type)
picking.action_assign()
move_line = picking.move_line_ids
move_line.result_package_id = self.free_package.id
self.assertEqual(self.free_package.planned_move_line_ids, move_line)
response = self.service.dispatch(
"set_destination",
params={
"move_line_id": move_line.id,
"barcode": self.free_package.name,
"quantity": move_line.product_uom_qty,
"confirmation": False,
},
)
self.assertEqual(
response["message"],
{
"body": "Package FREE_PACKAGE contains already lines"
" from a different operation type test",
"message_type": "warning",
},
)

def test_set_destination_location_zero_quantity(self):
"""Scanned barcode is the destination location.
Expand Down

0 comments on commit eca0449

Please sign in to comment.