Skip to content

Commit 9faef64

Browse files
committed
TA#57380 [IMP] stock_picking_barcode: error message
1 parent 5202829 commit 9faef64

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

stock_picking_barcode/models/stock_picking.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ def on_barcode_scanned(self, barcode):
3333
limit=1,
3434
)
3535
if product:
36-
self._check_product(product, qty)
36+
if not self._check_product(product, qty):
37+
return {
38+
"warning": {
39+
"title": _("Wrong barcode"),
40+
"message": _(
41+
'The barcode "%(barcode)s" does not match any '
42+
'product on this picking.'
43+
)
44+
% {"barcode": barcode},
45+
}
46+
}
3747
return {
3848
"warning": {
3949
"title": _("Wrong barcode"),
@@ -50,8 +60,6 @@ def _check_product(self, product, qty=1.0):
5060
"""
5161
# Get back the move line to increase. If multiple are found, chose
5262
# arbitrary the first one that doesn't have qty_done set.
53-
# Filter out the ones processed by `_check_location` and the ones already
54-
# having a # destination package.
5563
picking_move_lines = self.move_line_ids_without_package
5664
if not self.show_reserved:
5765
picking_move_lines = self.move_line_nosuggest_ids
@@ -62,14 +70,5 @@ def _check_product(self, product, qty=1.0):
6270
)[:1]
6371
if corresponding_ml:
6472
corresponding_ml.qty_done += qty
65-
else:
66-
return {
67-
"warning": {
68-
"title": _("Wrong barcode"),
69-
"message": _(
70-
'The barcode "%(barcode)s" does not match any product on this picking.'
71-
)
72-
% {"barcode": barcode},
73-
}
74-
}
75-
return True
73+
return True
74+
return False

0 commit comments

Comments
 (0)