Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shopfloor delivery: better error when return picking is scanned
Browse files Browse the repository at this point in the history
mmequignon committed Jan 14, 2025
1 parent 21cef26 commit 99041a2
Showing 3 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions shopfloor/actions/message.py
Original file line number Diff line number Diff line change
@@ -961,3 +961,12 @@ def lot_change_no_line_found(self):
"message_type": "error",
"body": _("Unable to find a line with the same product but different lot."),
}

def picking_type_is_return(self):
return {
"message_type": "error",
"body": _(
"The scanned barcode is related to a return transfer."
"This product is meant to be transfered by another scenario."
),
}
2 changes: 2 additions & 0 deletions shopfloor/services/service.py
Original file line number Diff line number Diff line change
@@ -61,6 +61,8 @@ def _check_picking_status(self, pickings, states=("assigned",)):
return self.msg_store.transfer_cancelled()
if picking.state not in states: # the picking must be ready
return self.msg_store.stock_picking_not_available(picking)
if picking.picking_type_id in self.picking_types.return_picking_type_id:
return self.msg_store.picking_type_is_return()
if picking.picking_type_id not in self.picking_types:
return self.msg_store.cannot_move_something_in_picking_type()

24 changes: 24 additions & 0 deletions shopfloor/tests/test_delivery_scan_deliver.py
Original file line number Diff line number Diff line change
@@ -10,6 +10,19 @@ class DeliveryScanDeliverCase(DeliveryCommonCase):
@classmethod
def setUpClassBaseData(cls):
super().setUpClassBaseData()
cls.cleanup_type = (
cls.env["stock.picking.type"]
.sudo()
.create(
{
"name": "Cancel Cleanup",
"default_location_dest_id": cls.stock_location.id,
"sequence_code": "CCP",
"code": "internal",
}
)
)
cls.picking_type.sudo().return_picking_type_id = cls.cleanup_type
cls.product_e.tracking = "lot"
cls.picking = picking = cls._create_picking(
lines=[
@@ -454,6 +467,17 @@ def test_scan_deliver_picking_cancelled(self):
message=self.service.msg_store.transfer_cancelled(),
)

def test_scan_delivery_return_picking(self):
cleanup_picking = self._create_picking(
picking_type=self.cleanup_type, lines=[(self.product_c, 1)]
)
params = {"barcode": cleanup_picking.name}
response = self.service.dispatch("scan_deliver", params=params)
self.assert_response_deliver(
response,
message=self.service.msg_store.picking_type_is_return(),
)

def test_scan_deliver_picking_done(self):
# Set qty done for all lines (packages/raw product/lot...), picking is
# automatically set to done when the last line is completed

0 comments on commit 99041a2

Please sign in to comment.