diff --git a/docsource/modules180-190.rst b/docsource/modules180-190.rst index 75cff9999460..db48b6ee65b5 100644 --- a/docsource/modules180-190.rst +++ b/docsource/modules180-190.rst @@ -1094,7 +1094,7 @@ Module coverage 18.0 -> 19.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | stock_dropshipping |Nothing to do |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| stock_fleet | | | +| stock_fleet |Done | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | stock_landed_costs | | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/post-migration.py b/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/post-migration.py new file mode 100644 index 000000000000..b87aeebe8a3c --- /dev/null +++ b/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/post-migration.py @@ -0,0 +1,66 @@ +# Copyright 2026 Heliconia Solutions Pvt. Ltd. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + migrate_dock_locations(env) + set_dispatch_management(env) + drop_legacy_columns(env) + + +def migrate_dock_locations(env): + """Link legacy is_a_dock locations to the warehouse's outgoing picking + type, matching stock_warehouse._get_picking_type_update_values.""" + if not openupgrade.column_exists( + env.cr, "stock_location", "openupgrade_legacy_is_a_dock" + ): + return + env.cr.execute( + """ + INSERT INTO dock_location_stock_picking_type_rel ( + stock_picking_type_id, stock_location_id + ) + SELECT spt.id, sl.id + FROM stock_location sl + JOIN stock_picking_type spt + ON spt.warehouse_id = sl.warehouse_id + AND spt.code = 'outgoing' + WHERE sl.openupgrade_legacy_is_a_dock IS TRUE + ON CONFLICT DO NOTHING + """ + ) + + +def set_dispatch_management(env): + """Enable dispatch_management per stock_warehouse's own defaults + (incoming/outgoing always, pick/pack per delivery_steps), plus picking + types that received a dock link from legacy is_a_dock data.""" + env.cr.execute( + """ + UPDATE stock_picking_type spt + SET dispatch_management = TRUE + FROM stock_warehouse sw + WHERE spt.warehouse_id = sw.id + AND ( + spt.code IN ('incoming', 'outgoing') + OR (sw.delivery_steps = 'pick_pack_ship' AND spt.id = sw.pack_type_id) + OR (sw.delivery_steps = 'pick_ship' AND spt.id = sw.pick_type_id) + OR spt.id IN ( + SELECT stock_picking_type_id + FROM dock_location_stock_picking_type_rel + ) + ) + """ + ) + + +def drop_legacy_columns(env): + if openupgrade.column_exists( + env.cr, "stock_location", "openupgrade_legacy_is_a_dock" + ): + openupgrade.drop_columns( + env.cr, [("stock_location", "openupgrade_legacy_is_a_dock")] + ) diff --git a/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/pre-migration.py new file mode 100644 index 000000000000..a8eac4fac54a --- /dev/null +++ b/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/pre-migration.py @@ -0,0 +1,15 @@ +# Copyright 2026 Heliconia Solutions Pvt. Ltd. +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from openupgradelib import openupgrade + +column_renames = { + "stock_location": [ + ("is_a_dock", "openupgrade_legacy_is_a_dock"), + ], +} + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_columns(env.cr, column_renames) diff --git a/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..e99206f4e8d0 --- /dev/null +++ b/openupgrade_scripts/scripts/stock_fleet/19.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,24 @@ +---Models in module 'stock_fleet'--- + +---Fields in module 'stock_fleet'--- +stock_fleet / stock.location / is_a_dock (boolean) : DEL + +# DONE: legacy value preserved in pre-migration, backfilled into dock_ids in post-migration + +stock_fleet / stock.picking.batch / end_date (datetime) : now a function + +# NOTHING TO DO: non-stored + +stock_fleet / stock.picking.type / dispatch_management (boolean) : NEW + +# DONE: set in post-migration per stock_warehouse's own defaults + +stock_fleet / stock.picking.type / dock_ids (many2many) : NEW relation: stock.location, hasdefault: compute + +# DONE: backfilled from legacy is_a_dock locations in post-migration + +---XML records in module 'stock_fleet'--- +NEW ir.ui.view: stock_fleet.view_picking_type_form +DEL ir.ui.view: stock_fleet.stock_location_tree_stock_fleet + +# NOTHING TO DO