Skip to content

Commit

Permalink
shopfloor, checkout: check lot on change confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
sebalix authored and TDu committed Nov 30, 2023
1 parent 183a88d commit c9ef529
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions shopfloor/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,15 @@ def lot_changed(self):
"body": _("Lot changed"),
}

def lot_change_wrong_lot(self, lot_name):
return {
"message_type": "error",
"body": _("Scanned lot differs from the previous scan: %(lot)s.")
% {
"lot": lot_name,
},
}

def lot_change_no_line_found(self):
return {
"message_type": "error",
Expand Down
10 changes: 5 additions & 5 deletions shopfloor/services/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Checkout(Component):
_description = __doc__

def _response_for_select_line(
self, picking, message=None, need_confirm_pack_all=False, need_confirm_lot=False
self, picking, message=None, need_confirm_pack_all=False, need_confirm_lot=None
):
if all(line.shopfloor_checkout_done for line in picking.move_line_ids):
return self._response_for_summary(picking, message=message)
Expand All @@ -56,7 +56,7 @@ def _response_for_select_line(
)

def _data_for_select_line(
self, picking, need_confirm_pack_all=False, need_confirm_lot=False
self, picking, need_confirm_pack_all=False, need_confirm_lot=None
):
return {
"picking": self._data_for_stock_picking(picking),
Expand Down Expand Up @@ -425,7 +425,7 @@ def _deselect_lines(self, lines):
{"qty_done": 0, "shopfloor_user_id": False}
)

def scan_line(self, picking_id, barcode, confirm_pack_all=False, confirm_lot=False):
def scan_line(self, picking_id, barcode, confirm_pack_all=False, confirm_lot=None):
"""Scan move lines of the stock picking
It allows to select move lines of the stock picking for the next
Expand Down Expand Up @@ -1559,7 +1559,7 @@ def scan_line(self):
"required": False,
},
"confirm_lot": {
"type": "boolean",
"type": "integer",
"nullable": True,
"required": False,
},
Expand Down Expand Up @@ -1785,7 +1785,7 @@ def _schema_stock_picking_details(self):
group_lines_by_location={"type": "boolean"},
show_oneline_package_content={"type": "boolean"},
need_confirm_pack_all={"type": "boolean"},
need_confirm_lot={"type": "boolean"},
need_confirm_lot={"type": "integer", "nullable": True},
)

@property
Expand Down
2 changes: 1 addition & 1 deletion shopfloor/tests/test_checkout_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _data_for_select_line(self, picking, **kw):
"group_lines_by_location": True,
"show_oneline_package_content": False,
"need_confirm_pack_all": False,
"need_confirm_lot": False,
"need_confirm_lot": None,
}
data.update(kw)
return data
Expand Down
6 changes: 3 additions & 3 deletions shopfloor/tests/test_checkout_scan_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_scan_line_product_in_one_package_all_package_lines_ok(self):
# more than one package, it would be an error.
self._test_scan_line_ok(self.product_a.barcode, picking.move_line_ids)

def _test_scan_line_error(self, picking, barcode, message, need_confirm_lot=False):
def _test_scan_line_error(self, picking, barcode, message, need_confirm_lot=None):
"""Test errors for /scan_line
:param picking: the picking we are currently working with (selected)
Expand Down Expand Up @@ -351,15 +351,15 @@ def test_scan_line_error_lot_different_change_success(self):
picking,
lot.name,
self.msg_store.lot_different_change(),
need_confirm_lot=True,
need_confirm_lot=lot.id,
)
# Second scan to confirm the change of lot
response = self.service.dispatch(
"scan_line",
params={
"picking_id": picking.id,
"barcode": lot.name,
"confirm_lot": True,
"confirm_lot": lot.id,
},
)
message = self.msg_store.lot_replaced_by_lot(previous_lot, lot)
Expand Down

0 comments on commit c9ef529

Please sign in to comment.