From a2d266ec9a26209e108ae6402b6e43eda733bad9 Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Fri, 23 Feb 2024 09:45:18 +0100 Subject: [PATCH] shopfloor: display picking partner note in cluster picking scenario --- shopfloor/actions/data.py | 12 ++++++++++++ shopfloor/services/checkout.py | 10 +--------- shopfloor/services/cluster_picking.py | 6 +++++- .../tests/test_checkout_list_delivery_packaging.py | 2 +- shopfloor/tests/test_checkout_scan_package_action.py | 2 +- .../static/wms/src/scenario/cluster_picking.js | 3 +++ 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/shopfloor/actions/data.py b/shopfloor/actions/data.py index aaefbc06dc..91dfa76daf 100644 --- a/shopfloor/actions/data.py +++ b/shopfloor/actions/data.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). +import os + from odoo import fields from odoo.addons.component.core import Component @@ -369,3 +371,13 @@ def _get_operation_progress(self, domain): "done": operations_done, "to_do": operations_to_do, } + + @ensure_model("stock.picking") + def packing_info(self, record): + """Return the packing information""" + + record.ensure_one() + note = record.note + if note: + return "{}{}".format(os.linesep, note).strip() + return "" diff --git a/shopfloor/services/checkout.py b/shopfloor/services/checkout.py index 01b8b6c81b..b211261e2b 100644 --- a/shopfloor/services/checkout.py +++ b/shopfloor/services/checkout.py @@ -100,7 +100,7 @@ def _response_for_select_package(self, picking, lines, message=None): data={ "selected_move_lines": self._data_for_move_lines(lines.sorted()), "picking": self.data.picking(picking), - "packing_info": self._data_for_packing_info(picking), + "packing_info": self.data.packing_info(picking), "no_package_enabled": not self.options.get( "checkout__disable_no_package" ), @@ -108,14 +108,6 @@ def _response_for_select_package(self, picking, lines, message=None): message=message, ) - 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 _response_for_select_dest_package(self, picking, move_lines, message=None): packages = picking.mapped("move_line_ids.result_package_id").filtered( "packaging_id" diff --git a/shopfloor/services/cluster_picking.py b/shopfloor/services/cluster_picking.py index 721f835c72..4b2afd5771 100644 --- a/shopfloor/services/cluster_picking.py +++ b/shopfloor/services/cluster_picking.py @@ -402,6 +402,7 @@ def _data_move_line(self, line, **kw): data["package_dest"] = None data["batch"] = self.data.picking_batch(batch) data["picking"] = self.data.picking(picking) + data["packing_info"] = self.data.packing_info(picking) data["postponed"] = line.shopfloor_postponed data["product"]["qty_available"] = product.with_context( location=line.location_id.id @@ -1418,7 +1419,10 @@ def _states(self): """ return { "confirm_start": self._schema_for_batch_details, - "start_line": self._schema_for_single_line_details, + "start_line": dict( + self._schema_for_single_line_details, + packing_info={"type": "string", "nullable": True}, + ), "start": {}, "manual_selection": self._schema_for_batch_selection, "scan_destination": self._schema_for_scan_destination, diff --git a/shopfloor/tests/test_checkout_list_delivery_packaging.py b/shopfloor/tests/test_checkout_list_delivery_packaging.py index 48fc87c446..4f5b0241e8 100644 --- a/shopfloor/tests/test_checkout_list_delivery_packaging.py +++ b/shopfloor/tests/test_checkout_list_delivery_packaging.py @@ -111,7 +111,7 @@ def test_list_delivery_packaging_not_available(self): "selected_move_lines": [ self._move_line_data(ml) for ml in selected_lines.sorted() ], - "packing_info": self.service._data_for_packing_info(self.picking), + "packing_info": self.service.data.packing_info(self.picking), "no_package_enabled": not self.service.options.get( "checkout__disable_no_package" ), diff --git a/shopfloor/tests/test_checkout_scan_package_action.py b/shopfloor/tests/test_checkout_scan_package_action.py index 446f50debd..dcd0bfe573 100644 --- a/shopfloor/tests/test_checkout_scan_package_action.py +++ b/shopfloor/tests/test_checkout_scan_package_action.py @@ -172,7 +172,7 @@ def test_scan_package_action_scan_package_keep_source_package_error(self): data={ "picking": self.data.picking(picking), "selected_move_lines": self.data.move_lines(selected_lines), - "packing_info": self.service._data_for_packing_info(picking), + "packing_info": self.service.data.packing_info(picking), "no_package_enabled": not self.service.options.get( "checkout__disable_no_package" ), diff --git a/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js b/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js index b85426a68a..2757f17f92 100644 --- a/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js +++ b/shopfloor_mobile/static/wms/src/scenario/cluster_picking.js @@ -30,6 +30,9 @@ const ClusterPicking = { v-on:confirm="state.on_confirm" v-on:cancel="state.on_cancel" /> + +

+