Skip to content

Commit

Permalink
[IMP] shopfloor_packing: Move data retrieval to data action + enable …
Browse files Browse the repository at this point in the history
…tests
  • Loading branch information
rousseldenis committed Sep 20, 2024
1 parent 9342929 commit bf53107
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
18 changes: 18 additions & 0 deletions shopfloor_packing/actions/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,21 @@ def _package_parser(self):
res = super()._package_parser
res.append("is_internal")
return res

def _data_for_packing_info(self, picking):
"""Return the packing information
Intended to be extended.
"""
# TODO: This could be avoided if included in the picking parser.
return ""

def select_package(self, picking, lines):
return {
"selected_move_lines": self.move_lines(lines.sorted()),
"picking": self.picking(picking),
"packing_info": self._data_for_packing_info(picking),
# "no_package_enabled": not self.options.get("checkout__disable_no_package"),
# Used by inheriting module
"package_allowed": True,
}
15 changes: 1 addition & 14 deletions shopfloor_packing/services/cluster_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ def scan_package_action(self, picking_id, selected_line_ids, barcode):
# Call the specific put in pack with package type filled in
return self._put_in_pack(self, picking, package_type_id=package_type_id)

def _data_for_move_lines(self, lines, **kw):
return self.data.move_lines(lines, **kw)

@property
def default_pick_pack_action(self):
return self.work.menu.default_pack_pickings_action
Expand Down Expand Up @@ -334,20 +331,10 @@ def _data_for_packing_info(self, picking):
# TODO: This could be avoided if included in the picking parser.
return ""

def _data_response_for_select_package(self, picking, lines):
return {
"selected_move_lines": self._data_for_move_lines(lines.sorted()),
"picking": self.data.picking(picking),
"packing_info": self._data_for_packing_info(picking),
# "no_package_enabled": not self.options.get("checkout__disable_no_package"),
# Used by inheriting module
"package_allowed": True,
}

def _response_for_select_package(self, picking, lines, message=None):
return self._response(
next_state="select_package",
data=self._data_response_for_select_package(picking, lines),
data=self.data.select_package(picking, lines),
message=message,
)

Expand Down
4 changes: 2 additions & 2 deletions shopfloor_packing/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import ( # test_cluster_picking_pick_pack,
common,
from . import (
test_cluster_picking_pack_picking,
test_cluster_picking_pick_pack,
test_cluster_picking_unload,
)
15 changes: 11 additions & 4 deletions shopfloor_packing/tests/test_cluster_picking_pick_pack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021 ACSONE SA/NV
# Copyright 2024 ACSONE SA/NV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from .common import ClusterPickingUnloadPackingCommonCase

Expand Down Expand Up @@ -34,6 +34,9 @@ def test_prepare_unload_all_same_dest_with_dest_package(self):
next_state="pack_picking_scan_pack",
data=data,
)
lines = picking.move_line_ids.filtered(
lambda ml: ml.result_package_id.is_internal
).sorted(key=lambda ml: ml.result_package_id.name)
# we scan the pack
response = self.service.dispatch(
"scan_packing_to_pack",
Expand All @@ -43,7 +46,8 @@ def test_prepare_unload_all_same_dest_with_dest_package(self):
"barcode": self.bin1.name,
},
)
data = self.data_detail.pack_picking_detail(picking)

data = self.data.select_package(picking, lines)
self.assert_response(
response,
next_state="select_package",
Expand All @@ -69,6 +73,9 @@ def test_prepare_unload_all_same_dest_with_dest_package(self):
self.assert_response(
response, next_state="pack_picking_scan_pack", data=data, message=message
)
lines = picking.move_line_ids.filtered(
lambda ml: ml.result_package_id.is_internal
).sorted(key=lambda ml: ml.result_package_id.name)
# we scan the pack
response = self.service.dispatch(
"scan_packing_to_pack",
Expand All @@ -78,10 +85,10 @@ def test_prepare_unload_all_same_dest_with_dest_package(self):
"barcode": self.bin2.name,
},
)
data = self.data_detail.pack_picking_detail(picking)
data = self.data.select_package(picking, lines)
self.assert_response(
response,
next_state="pack_picking_put_in_pack",
next_state="select_package",
data=data,
)
# we process to the put in pack
Expand Down

0 comments on commit bf53107

Please sign in to comment.