From c68afe352890c2a62dce82384b80197b602b827a Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Mon, 4 Mar 2024 15:45:24 +0100 Subject: [PATCH 1/4] shopfloor_packing_info: deprecate --- shopfloor/services/checkout.py | 9 --- shopfloor/tests/test_checkout_base.py | 1 - .../test_checkout_list_delivery_packaging.py | 1 - .../test_checkout_scan_package_action.py | 1 - .../test_checkout_select_package_base.py | 1 - shopfloor_packing_info/__manifest__.py | 4 +- .../migrations/14.0.1.2.0/post-migrate.py | 56 +++++++++++++++++++ shopfloor_packing_info/readme/DESCRIPTION.rst | 4 ++ 8 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py diff --git a/shopfloor/services/checkout.py b/shopfloor/services/checkout.py index ec7bd1cb8d..9fee3d3f52 100644 --- a/shopfloor/services/checkout.py +++ b/shopfloor/services/checkout.py @@ -103,7 +103,6 @@ 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, @@ -116,14 +115,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/tests/test_checkout_base.py b/shopfloor/tests/test_checkout_base.py index 2cc8a54248..adf94d951c 100644 --- a/shopfloor/tests/test_checkout_base.py +++ b/shopfloor/tests/test_checkout_base.py @@ -68,7 +68,6 @@ def _assert_select_package_qty_above(self, response, picking): self._move_line_data(ml) for ml in picking.move_line_ids.sorted() ], "picking": self._picking_summary_data(picking), - "packing_info": "", "no_package_enabled": True, "package_allowed": True, }, diff --git a/shopfloor/tests/test_checkout_list_delivery_packaging.py b/shopfloor/tests/test_checkout_list_delivery_packaging.py index 8097aca08e..4ad20687ef 100644 --- a/shopfloor/tests/test_checkout_list_delivery_packaging.py +++ b/shopfloor/tests/test_checkout_list_delivery_packaging.py @@ -111,7 +111,6 @@ 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), "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 5d76da56e4..f287d29e0e 100644 --- a/shopfloor/tests/test_checkout_scan_package_action.py +++ b/shopfloor/tests/test_checkout_scan_package_action.py @@ -172,7 +172,6 @@ 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), "no_package_enabled": not self.service.options.get( "checkout__disable_no_package" ), diff --git a/shopfloor/tests/test_checkout_select_package_base.py b/shopfloor/tests/test_checkout_select_package_base.py index 82e532a9c3..78fd239b72 100644 --- a/shopfloor/tests/test_checkout_select_package_base.py +++ b/shopfloor/tests/test_checkout_select_package_base.py @@ -21,7 +21,6 @@ def _assert_selected_response( self._move_line_data(ml) for ml in selected_lines.sorted() ], "picking": self._picking_summary_data(picking), - "packing_info": packing_info, "no_package_enabled": no_package_enabled, "package_allowed": package_allowed, }, diff --git a/shopfloor_packing_info/__manifest__.py b/shopfloor_packing_info/__manifest__.py index 194d818bc2..2ae1506e2f 100644 --- a/shopfloor_packing_info/__manifest__.py +++ b/shopfloor_packing_info/__manifest__.py @@ -3,14 +3,14 @@ { "name": "Shopfloor Packing Info", "summary": "Allows to predefine packing information messages per partner.", - "version": "14.0.1.1.0", + "version": "14.0.1.2.0", "development_status": "Alpha", "category": "Inventory", "website": "https://github.com/OCA/wms", "author": "Camptocamp, Odoo Community Association (OCA)", "license": "AGPL-3", "application": False, - "depends": ["shopfloor", "sales_team"], + "depends": ["shopfloor", "sales_team", "stock_picking_partner_note"], "data": [ "security/ir.model.access.csv", "views/res_partner_views.xml", diff --git a/shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py b/shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py new file mode 100644 index 0000000000..913549805c --- /dev/null +++ b/shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py @@ -0,0 +1,56 @@ +# Copyright 2024 Camptocamp SA +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl) + +import logging + +from odoo import SUPERUSER_ID, api + +_logger = logging.getLogger(__name__) + +# NOTE: This module is deprecated in favor of stock_picking_partner_note. +# Here, we migrate the data from shopfloor.packing.info to stock.picking.note. + + +def setup_stock_picking_note__packing(env): + """Create a new packing note type named 'packing'.""" + + _logger.info("Create a new picking note type named 'packing'") + packing_note_type = env["stock.picking.note.type"].search( + [("name", "=", "packing")], limit=1 + ) + if not packing_note_type: + packing_note_type = env["stock.picking.note.type"].create({"name": "packing"}) + return packing_note_type + + +def populate_stock_picking_note__packing(env): + """Migrate data from shopfloor.packing.info to stock.picking.note of type 'packing'. + + We also update the stock_picking_note_ids of the partners + based on their existing shopfloor_packing_info_id values.""" + + _logger.info( + "Migrate data from shopfloor.packing.info to stock.picking.note of type 'packing'" + ) + packing_note_type = setup_stock_picking_note__packing(env) + existing_packing_infos = env["shopfloor.packing.info"].search([]) + for packing_info in existing_packing_infos: + note = env["stock.picking.note"].create( + { + "name": packing_info.text, + "note_type_id": packing_note_type.id, + } + ) + partner = env["res.partner"].search( + [("shopfloor_packing_info_id", "=", packing_info.id)], limit=1 + ) + if partner: + partner.stock_picking_note_ids |= note + + +def migrate(cr, version): + if not version: + return + + env = api.Environment(cr, SUPERUSER_ID, {}) + populate_stock_picking_note__packing(env) diff --git a/shopfloor_packing_info/readme/DESCRIPTION.rst b/shopfloor_packing_info/readme/DESCRIPTION.rst index 14deabd5ed..430d7d6bf7 100644 --- a/shopfloor_packing_info/readme/DESCRIPTION.rst +++ b/shopfloor_packing_info/readme/DESCRIPTION.rst @@ -1,3 +1,7 @@ +DEPRECATED: This module is deprecated in favor of stock_picking_partner_note, +which is now used in shopfloor to display notes in the app. + + Adds the option to choose predefined messages for the parameter "Checkout Packing Info", that is set on Customers and reused in other places, mainly pickings. These new messages From 0cae7fdf8ef2c149a1e78179f8cf3d208ef8a3fe Mon Sep 17 00:00:00 2001 From: JuMiSanAr Date: Mon, 4 Mar 2024 15:46:51 +0100 Subject: [PATCH 2/4] shopfloor_mobile: display picking partner note in frontend --- shopfloor_mobile/static/wms/src/scenario/checkout.js | 4 ++-- shopfloor_mobile/static/wms/src/scenario/cluster_picking.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/shopfloor_mobile/static/wms/src/scenario/checkout.js b/shopfloor_mobile/static/wms/src/scenario/checkout.js index fe463fa21e..dea283759b 100644 --- a/shopfloor_mobile/static/wms/src/scenario/checkout.js +++ b/shopfloor_mobile/static/wms/src/scenario/checkout.js @@ -76,8 +76,8 @@ const Checkout = {
- -

+ +

+ +

+ Date: Wed, 10 Apr 2024 08:28:35 +0200 Subject: [PATCH 3/4] shopfloor_mobile: split picking note correctly --- shopfloor_mobile/static/wms/src/css/main.css | 7 +++++++ shopfloor_mobile/static/wms/src/scenario/checkout.js | 2 +- .../static/wms/src/scenario/cluster_picking.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/shopfloor_mobile/static/wms/src/css/main.css b/shopfloor_mobile/static/wms/src/css/main.css index 7adb202473..035856c025 100644 --- a/shopfloor_mobile/static/wms/src/css/main.css +++ b/shopfloor_mobile/static/wms/src/css/main.css @@ -71,3 +71,10 @@ I tested only w/ checkout/select_package for now top: 5px; right: 5px; } + +/* +Split the lines correctly if there are multiple lines separated by \n in a v-text. +*/ +.split-text-lines { + white-space: pre-line; +} diff --git a/shopfloor_mobile/static/wms/src/scenario/checkout.js b/shopfloor_mobile/static/wms/src/scenario/checkout.js index dea283759b..bfda2612bb 100644 --- a/shopfloor_mobile/static/wms/src/scenario/checkout.js +++ b/shopfloor_mobile/static/wms/src/scenario/checkout.js @@ -77,7 +77,7 @@ const Checkout = {

-

+

-

+

Date: Mon, 29 Apr 2024 14:59:00 +0200 Subject: [PATCH 4/4] fixup! shopfloor_packing_info: deprecate --- .../migrations/14.0.1.2.0/post-migrate.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py b/shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py index 913549805c..4848248697 100644 --- a/shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py +++ b/shopfloor_packing_info/migrations/14.0.1.2.0/post-migrate.py @@ -41,11 +41,12 @@ def populate_stock_picking_note__packing(env): "note_type_id": packing_note_type.id, } ) - partner = env["res.partner"].search( - [("shopfloor_packing_info_id", "=", packing_info.id)], limit=1 + partners = env["res.partner"].search( + [("shopfloor_packing_info_id", "=", packing_info.id)] ) - if partner: - partner.stock_picking_note_ids |= note + if partners: + for partner in partners: + partner.stock_picking_note_ids |= note def migrate(cr, version):