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