Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions shopfloor/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from odoo import _

from odoo.addons.component.core import Component
from odoo.addons.stock.models.stock_location import Location

_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -191,8 +192,22 @@ def no_location_found(self):
def location_not_allowed(self):
return {"message_type": "error", "body": _("Location not allowed here.")}

def dest_location_not_allowed(self):
return {"message_type": "error", "body": _("You cannot place it here")}
def dest_location_not_allowed(
self, location: (Location | None) = None, extra_message: str = ""
) -> dict:
"""
This returns the message that destination location is incorrect
"""
if location:
body = _(
"You cannot place it here (%(location_name)s)",
location_name=location.name if location else "",
)
else:
body = _("You cannot place it here")
if extra_message:
body += "\n" + extra_message
return {"message_type": "error", "body": body}

def need_confirmation(self):
return {"message_type": "warning", "body": _("Are you sure?")}
Expand Down
2 changes: 1 addition & 1 deletion shopfloor/services/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@ def scan_dest_location(self, picking_id, barcode):
if scanned_location not in allowed_locations:
return self._response_for_select_child_location(
picking,
message=self.msg_store.dest_location_not_allowed(),
message=self.msg_store.dest_location_not_allowed(scanned_location),
)
lines_done = self._lines_checkout_done(picking)
for line in lines_done:
Expand Down
7 changes: 5 additions & 2 deletions shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,8 @@ def set_destination_all(self, picking_batch_id, barcode, confirmation=None):
)
if not self.is_dest_location_valid(lines.move_id, scanned_location):
return self._response_for_unload_all(
batch, message=self.msg_store.dest_location_not_allowed()
batch,
message=self.msg_store.dest_location_not_allowed(scanned_location),
)

if confirmation != barcode and self.is_dest_location_to_confirm(
Expand Down Expand Up @@ -1297,7 +1298,9 @@ def _unload_scan_destination_lines(
)
if not self.is_dest_location_valid(lines.move_id, scanned_location):
return self._response_for_unload_set_destination(
batch, package, message=self.msg_store.dest_location_not_allowed()
batch,
package,
message=self.msg_store.dest_location_not_allowed(scanned_location),
)
if confirmation != barcode and self.is_dest_location_to_confirm(
first_line.location_dest_id, scanned_location
Expand Down
13 changes: 7 additions & 6 deletions shopfloor/services/location_content_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,7 @@ def scan_location(self, barcode): # noqa: C901
if not self.is_dest_location_valid(line.move_id, line.location_dest_id):
savepoint.rollback()
return self._response_for_start(
message=self.msg_store.location_content_unable_to_transfer(
location
)
message=self.msg_store.dest_location_not_allowed(location)
)

stock = self._actions_for("stock")
Expand Down Expand Up @@ -467,7 +465,8 @@ def set_destination_all(self, location_id, barcode, confirmation=None):

if not self.is_dest_location_valid(move_lines.move_id, scanned_location):
return self._response_for_scan_destination_all(
pickings, message=self.msg_store.dest_location_not_allowed()
pickings,
message=self.msg_store.dest_location_not_allowed(scanned_location),
)
if confirmation != barcode and self.is_dest_location_to_confirm(
move_lines.location_dest_id, scanned_location
Expand Down Expand Up @@ -693,7 +692,7 @@ def set_destination_package(
return self._response_for_scan_destination(
location,
package_level,
message=self.msg_store.dest_location_not_allowed(),
message=self.msg_store.dest_location_not_allowed(scanned_location),
)
if confirmation != barcode and self.is_dest_location_to_confirm(
package_level.location_dest_id, scanned_location
Expand Down Expand Up @@ -750,7 +749,9 @@ def set_destination_line(
)
if not self.is_dest_location_valid(move_line.move_id, scanned_location):
return self._response_for_scan_destination(
location, move_line, message=self.msg_store.dest_location_not_allowed()
location,
move_line,
message=self.msg_store.dest_location_not_allowed(scanned_location),
)
if confirmation != barcode and self.is_dest_location_to_confirm(
move_line.location_dest_id, scanned_location
Expand Down
3 changes: 2 additions & 1 deletion shopfloor/services/single_pack_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ def validate(self, package_level_id, location_barcode, confirmation=None):

if not self.is_dest_location_valid(moves, scanned_location):
return self._response_for_scan_location(
package_level, message=self.msg_store.dest_location_not_allowed()
package_level,
message=self.msg_store.dest_location_not_allowed(scanned_location),
)

if confirmation != location_barcode and self.is_dest_location_to_confirm(
Expand Down
4 changes: 2 additions & 2 deletions shopfloor/services/zone_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def _check_set_destination_location(
if not self.is_dest_location_valid(move_line.move_id, location):
return self._response_for_set_line_destination(
move_line,
message=self.msg_store.dest_location_not_allowed(),
message=self.msg_store.dest_location_not_allowed(location),
qty_done=quantity,
)

Expand Down Expand Up @@ -1704,7 +1704,7 @@ def unload_set_destination(self, package_id, barcode, confirmation=None):
if not self.is_dest_location_valid(moves, location):
return self._response_for_unload_set_destination(
first(buffer_lines),
message=self.msg_store.dest_location_not_allowed(),
message=self.msg_store.dest_location_not_allowed(location),
)
# check if the destination location is not the expected one
# - OK if the scanned destination is a child of the current
Expand Down
4 changes: 3 additions & 1 deletion shopfloor/tests/test_checkout_scan_dest_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@ def test_scan_dest_location_not_allowed(self):
self.picking, done=True, with_lines=False, with_location=True
),
},
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.child_location_view
),
)
18 changes: 14 additions & 4 deletions shopfloor/tests/test_cluster_picking_unload.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ def test_set_destination_all_error_location_invalid(self):
response,
next_state="unload_all",
data=data,
message={"message_type": "error", "body": "You cannot place it here"},
message={
"message_type": "error",
"body": f"You cannot place it here ({self.dispatch_location.name})",
},
)

def test_set_destination_all_error_location_move_invalid(self):
Expand All @@ -374,7 +377,9 @@ def test_set_destination_all_error_location_move_invalid(self):
response,
next_state="unload_all",
data=data,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.packing_b_location
),
)

def test_set_destination_all_need_confirmation(self):
Expand Down Expand Up @@ -822,7 +827,10 @@ def test_unload_scan_destination_error_location_invalid(self):
response,
next_state="unload_set_destination",
data=data,
message={"message_type": "error", "body": "You cannot place it here"},
message={
"message_type": "error",
"body": f"You cannot place it here ({self.dispatch_location.name})",
},
)

def test_unload_scan_destination_error_location_move_invalid(self):
Expand All @@ -846,7 +854,9 @@ def test_unload_scan_destination_error_location_move_invalid(self):
response,
next_state="unload_set_destination",
data=data,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.packing_b_location
),
)

def test_unload_scan_destination_need_confirmation(self):
Expand Down
4 changes: 1 addition & 3 deletions shopfloor/tests/test_location_content_transfer_putaway.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ def test_putaway_move_dest_not_child_of_picking_type_dest(self):
response,
next_state="scan_location",
data=self.ANY,
message=self.service.msg_store.location_content_unable_to_transfer(
self.test_loc
),
message=self.service.msg_store.dest_location_not_allowed(self.test_loc),
)
current_moves = self.env["stock.move"].search(
[("location_id", "=", self.test_loc.id), ("state", "=", "assigned")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ def test_set_destination_all_dest_location_invalid(self):
self.assert_response_scan_destination_all(
response,
self.pickings,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.dispatch_location
),
)

def test_set_destination_all_dest_location_move_invalid(self):
Expand All @@ -332,7 +334,7 @@ def test_set_destination_all_dest_location_move_invalid(self):
self.assert_response_scan_destination_all(
response,
self.pickings,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(self.shelf2),
)

def test_go_to_single(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_set_destination_package_dest_location_nok(self):
self.assert_response_scan_destination(
response,
package_level,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(customer_location),
)

def test_set_destination_package_dest_location_move_nok(self):
Expand All @@ -141,7 +141,7 @@ def test_set_destination_package_dest_location_move_nok(self):
self.assert_response_scan_destination(
response,
package_level,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(self.shelf2),
)

def test_set_destination_package_dest_location_to_confirm(self):
Expand Down Expand Up @@ -309,7 +309,7 @@ def test_set_destination_line_dest_location_nok(self):
self.assert_response_scan_destination(
response,
move_line,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(customer_location),
)

def test_set_destination_line_dest_location_move_nok(self):
Expand All @@ -333,7 +333,7 @@ def test_set_destination_line_dest_location_move_nok(self):
self.assert_response_scan_destination(
response,
move_line,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(self.shelf2),
)

def test_set_destination_line_dest_location_to_confirm(self):
Expand Down
5 changes: 4 additions & 1 deletion shopfloor/tests/test_single_pack_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,10 @@ def test_validate_location_forbidden(self):
response,
next_state="scan_location",
data=self.ANY,
message={"message_type": "error", "body": "You cannot place it here"},
message={
"message_type": "error",
"body": f"You cannot place it here ({self.dispatch_location.name})",
},
)

def test_validate_location_move_not_child_of_picking_allowed(self):
Expand Down
8 changes: 6 additions & 2 deletions shopfloor/tests/test_zone_picking_set_line_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def test_set_destination_location_confirm(self):
zone_location,
picking_type,
move_line,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.customer_location
),
qty_done=quantity_done,
)
# Confirm the destination with the right destination this time
Expand Down Expand Up @@ -127,7 +129,9 @@ def test_set_destination_location_move_invalid_location(self):
zone_location,
picking_type,
move_line,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.packing_sublocation_b
),
qty_done=quantity_done,
)

Expand Down
8 changes: 6 additions & 2 deletions shopfloor/tests/test_zone_picking_unload_set_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def test_unload_set_destination_location_not_allowed(self):
zone_location,
picking_type,
move_line,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.customer_location
),
)

def test_unload_set_destination_location_move_not_allowed(self):
Expand All @@ -122,7 +124,9 @@ def test_unload_set_destination_location_move_not_allowed(self):
zone_location,
picking_type,
move_line,
message=self.service.msg_store.dest_location_not_allowed(),
message=self.service.msg_store.dest_location_not_allowed(
self.packing_sublocation_b
),
)
# Ensure that when unload_package_at_destination is False,
# the result_package_id remains.
Expand Down