diff --git a/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js b/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js index 91ff499d2fb..d947ce366f6 100644 --- a/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js +++ b/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js @@ -86,6 +86,19 @@ const ClusterPicking = { +
+ + +
+
+ Destination: + {{ state.data.location_dest.name }} +
+
+
+
+
+
+
+ + Test + + + +
+
+ Package: + {{ state.data.package.name }} +
+
+
+
+ + +
+
+ Destination: + {{ state.data.location_dest.name }} +
+
+
+
+
+
- + diff --git a/shopfloor_mobile_packing/static/src/js/cluster-picking.js b/shopfloor_mobile_packing/static/src/js/cluster-picking.js index e9f96fc12cc..782eab4fe06 100644 --- a/shopfloor_mobile_packing/static/src/js/cluster-picking.js +++ b/shopfloor_mobile_packing/static/src/js/cluster-picking.js @@ -121,6 +121,10 @@ ClusterPickingBase.component.methods.selected_line_ids = function () { return this.selected_lines().map(_.property("id")); }; +ClusterPickingBase.component.methods.selected_line_ids_for_packing = function () { + return this.selectable_lines_for_packing().map(_.property("id")); +}; + ClusterPickingBase.component.methods.selectable_lines = function () { const stored = this.state_get_data("select_package"); return _.result(stored, "selected_move_lines", []); @@ -136,6 +140,11 @@ ClusterPickingBase.component.methods.selected_lines = function () { }); }; +ClusterPickingBase.component.methods.selectable_lines_for_packing = function () { + const lines = this.state.data.selected_lines_for_packing; + return lines; +}; + // Replace the data method with our new method to add // our new state let component = ClusterPickingBase.component; @@ -314,11 +323,12 @@ let data = function () { on_select: (selected) => { const picking = this.current_doc().record; const data = this.state.data.picking; + const ids = this.selected_line_ids_for_packing(); this.wait_call( this.odoo.call("put_in_pack", { picking_batch_id: this.current_batch().id, picking_id: data.id, - selected_line_ids: this.selected_line_ids(), + selected_line_ids: ids, package_type_id: selected.id, }) ); diff --git a/shopfloor_packing/actions/schema_detail.py b/shopfloor_packing/actions/schema_detail.py index ce5725e298a..16f9dcd3f43 100644 --- a/shopfloor_packing/actions/schema_detail.py +++ b/shopfloor_packing/actions/schema_detail.py @@ -46,3 +46,29 @@ def pack_picking_detail(self): }, } return schema + + def move_line_for_packing_detail(self) -> dict: + schema = { + "type": "list", + "schema": { + "type": "dict", + "schema": { + "id": {"required": True, "type": "integer"}, + "qty_done": {"type": "float", "required": True}, + "lot": { + "type": "dict", + "required": False, + "nullable": True, + "schema": self.lot(), + }, + "package_dest": self._schema_dict_of( + self.package(with_packaging=False), required=False + ), + "package_src": self._schema_dict_of( + self.package(with_packaging=False), required=False + ), + "product": self._schema_dict_of(self.product()), + }, + }, + } + return schema diff --git a/shopfloor_packing/services/cluster_picking.py b/shopfloor_packing/services/cluster_picking.py index 2c6c283c9d4..a3c5fcaf90c 100644 --- a/shopfloor_packing/services/cluster_picking.py +++ b/shopfloor_packing/services/cluster_picking.py @@ -45,7 +45,7 @@ def list_delivery_package_types( if response: return response return self._response_for_select_delivery_package_type( - picking, delivery_packaging + picking, delivery_packaging, selected_lines ) def scan_package_action(self, picking_id, selected_line_ids, barcode) -> dict: @@ -179,7 +179,12 @@ def prepare_unload(self, picking_batch_id) -> dict: return self._prepare_pack_picking(batch) def put_in_pack( - self, picking_batch_id, picking_id, nbr_packages=None, package_type_id=None + self, + picking_batch_id, + picking_id, + selected_line_ids, + nbr_packages=None, + package_type_id=None, ) -> dict: batch = self.env["stock.picking.batch"].browse(picking_batch_id) if not batch.exists(): @@ -200,8 +205,9 @@ def put_in_pack( if result: return result + lines = self.env["stock.move.line"].browse(selected_line_ids).exists() savepoint = self._actions_for("savepoint").new() - pack = self._put_in_pack(picking, nbr_packages, package_type_id) + pack = self._put_in_pack(picking, lines, nbr_packages, package_type_id) picking._reset_packing_packs_scanned() if not pack: savepoint.rollback() @@ -280,10 +286,16 @@ def _get_next_picking_to_pack(self, batch) -> Picking: def _get_move_lines_to_pack(self, picking) -> StockMoveLine: """ This returns the lines that have an internal package + and the same destination """ - return picking.move_line_ids.filtered( + move_lines = picking.move_line_ids.filtered( lambda ml: ml.result_package_id.is_internal ).sorted(key=lambda ml: ml.result_package_id.name) + # Take the first line to filter then the lines per destination + first_line = fields.first(move_lines) + return move_lines.filtered( + lambda line: line.location_dest_id == first_line.location_dest_id + ) def _prepare_pack_picking(self, batch, message=None) -> dict: picking = self._get_next_picking_to_pack(batch) @@ -308,16 +320,13 @@ def _postprocess_put_in_pack(self, picking, pack): return def _put_in_pack( - self, picking, number_of_parcels=None, package_type_id=None + self, picking, move_lines, number_of_parcels=None, package_type_id=None ) -> QuantPackage: """ This will enhance the put in pack flow by adding the number of parcels or the package type to the generated package. """ - move_lines_to_pack = picking.move_line_ids.filtered( - lambda l: l.result_package_id and l.result_package_id.is_internal - ) - pack = picking._put_in_pack(move_lines_to_pack) + pack = picking._put_in_pack(move_lines) if ( isinstance(pack, dict) and pack.get("res_model") == "stock.quant.package" @@ -412,12 +421,15 @@ def _response_for_select_dest_package(self, picking, message=None) -> dict: ) def _response_for_select_delivery_package_type( - self, picking, packaging, message=None + self, picking, packaging, selected_lines, message=None ) -> dict: return self._response( next_state="select_delivery_packaging", data={ "picking": self.data.picking(picking), + "selected_lines_for_packing": self.data_detail.move_lines( + selected_lines + ), "packaging": self._data_for_delivery_package_type(packaging), }, message=message, @@ -446,6 +458,11 @@ def put_in_pack(self) -> dict: "type": "integer", }, "picking_id": {"coerce": to_int, "required": True, "type": "integer"}, + "selected_line_ids": { + "type": "list", + "required": True, + "schema": {"coerce": to_int, "required": True, "type": "integer"}, + }, "nbr_packages": {"coerce": to_int, "required": False, "type": "integer"}, "package_type_id": {"coerce": to_int, "required": False, "type": "integer"}, } @@ -561,6 +578,7 @@ def list_delivery_package_types(self) -> dict: def _schema_select_delivery_packaging(self) -> dict: return { "picking": {"type": "dict", "schema": self.schemas.picking()}, + "selected_lines_for_packing": self.schemas_detail.move_line_for_packing_detail(), "packaging": self.schemas._schema_list_of( self.schemas.delivery_packaging() ),