diff --git a/shopfloor/actions/message.py b/shopfloor/actions/message.py index 5cd617ac97..90580e1bca 100644 --- a/shopfloor/actions/message.py +++ b/shopfloor/actions/message.py @@ -686,12 +686,19 @@ def picking_zero_quantity(self): "body": _("The picked quantity must be a value above zero."), } - def selected_lines_qty_done_higher_than_allowed(self): + def selected_lines_qty_done_higher_than_allowed(self, line): + """ + :param line: The selected line + """ return { "message_type": "warning", "body": _( "The quantity scanned for one or more lines cannot be " - "higher than the maximum allowed." + "higher than the maximum allowed. " + "(%(product_name)s : %(quantity_done)s > %(quantity_reserved)s)", + product_name=line.product_id.name, + quantity_done=str(line.qty_done), + quantity_reserved=str(line.reserved_uom_qty), ), } diff --git a/shopfloor/services/checkout.py b/shopfloor/services/checkout.py index 2c70c77db2..7ad90ac868 100644 --- a/shopfloor/services/checkout.py +++ b/shopfloor/services/checkout.py @@ -1216,7 +1216,9 @@ def _check_allowed_qty_done(self, picking, lines): return self._response_for_select_package( picking, lines, - message=self.msg_store.selected_lines_qty_done_higher_than_allowed(), + message=self.msg_store.selected_lines_qty_done_higher_than_allowed( + line + ), ) def _set_dest_package_from_selection(self, picking, selected_lines, package): diff --git a/shopfloor/tests/test_checkout_base.py b/shopfloor/tests/test_checkout_base.py index 55c40a08d8..62c626a685 100644 --- a/shopfloor/tests/test_checkout_base.py +++ b/shopfloor/tests/test_checkout_base.py @@ -1,5 +1,7 @@ # Copyright 2020 Camptocamp SA (http://www.camptocamp.com) # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from odoo.fields import first + from .common import CommonCase @@ -71,6 +73,7 @@ def _data_for_select_line(self, picking, **kw): return data def _assert_select_package_qty_above(self, response, picking): + line = first(picking.move_line_ids) self.assert_response( response, next_state="select_package", @@ -86,6 +89,12 @@ def _assert_select_package_qty_above(self, response, picking): message={ "message_type": "warning", "body": "The quantity scanned for one or more lines cannot be " - "higher than the maximum allowed.", + "higher than the maximum allowed. " + "(%(product_name)s : %(quantity_done)s > %(quantity_reserved)s)" + % dict( + product_name=line.product_id.name, + quantity_done=str(line.qty_done), + quantity_reserved=str(line.reserved_uom_qty), + ), }, )