Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsource/modules180-190.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
66 changes: 66 additions & 0 deletions openupgrade_scripts/scripts/stock_fleet/19.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -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")]
)
15 changes: 15 additions & 0 deletions openupgrade_scripts/scripts/stock_fleet/19.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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
Loading