Skip to content

Commit

Permalink
Merge PR #942 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by jbaudoux
  • Loading branch information
OCA-git-bot committed Nov 4, 2024
2 parents d56784b + 5b0e7b4 commit c9a9c78
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
11 changes: 9 additions & 2 deletions shopfloor/actions/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
}

Expand Down
4 changes: 3 additions & 1 deletion shopfloor/services/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 10 additions & 1 deletion shopfloor/tests/test_checkout_base.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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",
Expand All @@ -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),
),
},
)

0 comments on commit c9a9c78

Please sign in to comment.