Skip to content

Commit

Permalink
shopfloor: fix zone picking scan empty package
Browse files Browse the repository at this point in the history
  • Loading branch information
TDu committed Aug 21, 2023
1 parent 4a45e54 commit 80cfcbb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
11 changes: 6 additions & 5 deletions shopfloor/services/zone_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,12 @@ def _scan_source_package(
package = search.package_from_scan(barcode)
if not package:
return response, message
if not package.location_id.is_sublocation_of(self.zone_location):
# Package is not in an allowed location
response = self._list_move_lines(self.zone_location)
message = self.msg_store.location_not_allowed()
return response, message
if package.location_id:
if not package.location_id.is_sublocation_of(self.zone_location):
# Package is not in an allowed location
response = self._list_move_lines(self.zone_location)
message = self.msg_store.location_not_allowed()
return response, message

Check warning on line 602 in shopfloor/services/zone_picking.py

View check run for this annotation

Codecov / codecov/patch

shopfloor/services/zone_picking.py#L600-L602

Added lines #L600 - L602 were not covered by tests

move_lines = self._find_location_move_lines(
locations=sublocation, package=package
Expand Down
20 changes: 20 additions & 0 deletions shopfloor/tests/test_zone_picking_select_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,26 @@ def test_scan_source_package_many_products(self):
location_first=False,
)

def test_scan_source_empty_package(self):
"""Scan source: scanned an empty package."""
pack_empty = self.env["stock.quant.package"].create({})
response = self.service.dispatch(
"scan_source",
params={"barcode": pack_empty.name},
)
move_lines = self.service._find_location_move_lines(
locations=self.zone_location
)
move_lines = move_lines.sorted(lambda l: l.move_id.priority, reverse=True)
self.assert_response_select_line(
response,
zone_location=self.zone_location,
picking_type=self.picking_type,
move_lines=move_lines,
message=self.service.msg_store.package_has_no_product_to_take(pack_empty.name),
location_first=False,
)

def test_scan_source_barcode_package_can_replace_in_line(self):
"""Scan source: scanned package has no related line but can replace
next step 'select_line' expected with confirmation required set.
Expand Down

0 comments on commit 80cfcbb

Please sign in to comment.