Skip to content

Commit

Permalink
[IMP] shopfloor: Optionnal picking type on moves search
Browse files Browse the repository at this point in the history
To disable the filtering of move line based on specific picking types, the additional parameter ‘enforce_picking_types’ had to be set to True when calling the method 'search_move_lines' of the 'hopfloor.search.move.line' action. The name of this parameter was not really relevant and its meaning conflicted with another parameter ‘enforce_package_types’. To avoid this situation, the semantics of the ‘picking_type’ parameter have been modified so that it can be explicitly stated that the search is not on a particular picking type if an empty recordset is passed as a parameter. Previously, if the parameter was None or an empty recordset, the filtering was forced on the picking types specified into the work context.

Translated with DeepL.com (free version)
  • Loading branch information
lmignon committed Oct 11, 2024
1 parent 4f450e1 commit b977550
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
19 changes: 11 additions & 8 deletions shopfloor/actions/move_line_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,22 @@ def _search_move_lines_domain(
picking_ready=True,
# When True, adds the package in the domain even if the package is False
enforce_empty_package=False,
enforce_picking_types=True,
):
"""Return a domain to search move lines.
Be careful on the use of the picking_type parameter. This paramater can take
a recordset or None as value. The interpretation of the value is as follows:
* If picking_type is None, the domain will be filtered on all picking types
defined in the work. (most probably those defined on the menu)
* If picking_type is a recordset, the domain will be filtered on the given
picking types if the recordset is not empty. If the recordset is empty,
the domain will not be filtered on any picking type.
"""
domain = [
("qty_done", "=", 0),
("state", "in", ("assigned", "partially_available")),
]
picking_types = (
picking_type or self.picking_types
if enforce_picking_types
else picking_type
)
picking_types = picking_type if picking_type is not None else self.picking_types
if picking_types:
domain += [("picking_id.picking_type_id", "in", self.picking_types.ids)]
locations = locations or picking_types.default_location_src_id
Expand Down Expand Up @@ -114,7 +119,6 @@ def search_move_lines(
sort_keys_func=None,
picking_ready=True,
enforce_empty_package=False,
enforce_picking_types=True,
):
"""Find lines that potentially need work in given locations."""
move_lines = self.env["stock.move.line"].search(
Expand All @@ -127,7 +131,6 @@ def search_move_lines(
match_user=match_user,
picking_ready=picking_ready,
enforce_empty_package=enforce_empty_package,
enforce_picking_types=enforce_picking_types,
)
)
order = order or self.sort_order
Expand Down
6 changes: 5 additions & 1 deletion shopfloor/services/location_content_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,11 @@ def scan_location(self, barcode): # noqa: C901
)

move_lines = self.search_move_line.search_move_lines(
locations=location, match_user=True, enforce_picking_types=False
locations=location,
match_user=True,
picking_type=self.env[
"stock.picking.type"
], # disable filtering on picking types
)
move_lines = self._select_move_lines_first_location(move_lines)

Expand Down

0 comments on commit b977550

Please sign in to comment.