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
6 changes: 6 additions & 0 deletions shopfloor/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,9 @@ def picking_without_carrier_cannot_pack(self, picking):
"The system couldn't pack goods automatically."
).format(picking),
}

def qty_must_be_greater_than_zero(self):
return {
"message_type": "error",
"body": _(u"Quantity must be greater than zero."),
}
5 changes: 5 additions & 0 deletions shopfloor/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,11 @@ def scan_destination_pack(self, picking_batch_id, move_line_id, barcode, quantit
move_line, message=self.msg_store.bin_not_found_for_barcode(barcode)
)

if quantity <= 0:
return self._response_for_scan_destination(
move_line, message=self.msg_store.qty_must_be_greater_than_zero()
)

# the scanned package can contain only move lines of the same picking
if bin_package.quant_ids or any(
ml.picking_id != move_line.picking_id
Expand Down
23 changes: 23 additions & 0 deletions shopfloor/tests/test_cluster_picking_scan_destination.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,26 @@ def test_scan_destination_pack_zero_check_disabled(self):
),
},
)

def test_scan_destination_pack_zero_quantity(self):
"""Try to enter 0 as quantity picked : should not be possible"""
line = self.batch.move_line_ids[0]
response = self.service.dispatch(
"scan_destination_pack",
params={
"picking_batch_id": self.batch.id,
"move_line_id": line.id,
"barcode": self.bin1.name,
"quantity": 0,
},
)

self.assert_response(
response,
next_state="scan_destination",
data=self.self._line_data(line),
message={
"message_type": "error",
"body": "Quantity must be greater than zero.",
},
)