Skip to content

Commit

Permalink
TA#57380 [IMP] stock_picking_barcode: error message
Browse files Browse the repository at this point in the history
  • Loading branch information
majouda committed Jun 10, 2024
1 parent 5202829 commit 9faef64
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions stock_picking_barcode/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ def on_barcode_scanned(self, barcode):
limit=1,
)
if product:
self._check_product(product, qty)
if not self._check_product(product, qty):
return {
"warning": {
"title": _("Wrong barcode"),
"message": _(
'The barcode "%(barcode)s" does not match any '
'product on this picking.'
)
% {"barcode": barcode},
}
}
return {
"warning": {
"title": _("Wrong barcode"),
Expand All @@ -50,8 +60,6 @@ def _check_product(self, product, qty=1.0):
"""
# Get back the move line to increase. If multiple are found, chose
# arbitrary the first one that doesn't have qty_done set.
# Filter out the ones processed by `_check_location` and the ones already
# having a # destination package.
picking_move_lines = self.move_line_ids_without_package
if not self.show_reserved:
picking_move_lines = self.move_line_nosuggest_ids
Expand All @@ -62,14 +70,5 @@ def _check_product(self, product, qty=1.0):
)[:1]
if corresponding_ml:
corresponding_ml.qty_done += qty
else:
return {
"warning": {
"title": _("Wrong barcode"),
"message": _(
'The barcode "%(barcode)s" does not match any product on this picking.'
)
% {"barcode": barcode},
}
}
return True
return True
return False

0 comments on commit 9faef64

Please sign in to comment.