diff --git a/shopfloor_location_package_restriction/services/zone_picking.py b/shopfloor_location_package_restriction/services/zone_picking.py index fe994eabe3d..f482df90ae1 100644 --- a/shopfloor_location_package_restriction/services/zone_picking.py +++ b/shopfloor_location_package_restriction/services/zone_picking.py @@ -17,5 +17,10 @@ def _validate_destination(self, location, moves): if location.package_restriction != "norestriction": try: moves._check_location_package_restriction(only_qty_done=False) - except ValidationError: - return self.msg_store.location_has_restrictions() + except ValidationError as ex: + # __import__("pdb").set_trace() + return { + "message_type": "error", + "body": ex.name, + } + # return self.msg_store.location_has_restrictions() diff --git a/shopfloor_location_package_restriction/tests/test_zone_picking_force_package.py b/shopfloor_location_package_restriction/tests/test_zone_picking_force_package.py index 22f4f4a6709..deb99d1926c 100644 --- a/shopfloor_location_package_restriction/tests/test_zone_picking_force_package.py +++ b/shopfloor_location_package_restriction/tests/test_zone_picking_force_package.py @@ -10,7 +10,7 @@ def setUp(self): self.service.work.current_picking_type = self.picking1.picking_type_id def test_set_destination_location_package_restriction(self): - """""" + """Check error restriction on location is properly forwarded to frontend.""" # Add a restriction on the location self.packing_location.sudo().package_restriction = "singlepackage" # Add a first package on the location @@ -32,11 +32,18 @@ def test_set_destination_location_package_restriction(self): "confirmation": False, }, ) + message = { + "message_type": "error", + "body": ( + f"Only one package is allowed on the location {self.packing_location.display_name}." + f"You cannot add the {move_line.package_id.name}, there is already {self.pack_1.name}." + ), + } self.assert_response_set_line_destination( response, self.zone_location, picking_type, move_line, - message=self.service.msg_store.location_has_restrictions(), + message=message, qty_done=10.0, )