diff --git a/openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py b/openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py new file mode 100644 index 000000000000..ededf705d279 --- /dev/null +++ b/openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py @@ -0,0 +1,30 @@ +# Copyright (C) 2023-Today GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openupgradelib import openupgrade + + +def handle_stock_picking_backorder_strategy(env): + # Handle the merge of OCA/stock-logistics-workflow/stock_picking_backorder_strategy + # feature in odoo/stock V16 module. + if openupgrade.column_exists( + env.cr, "stock_picking_type", openupgrade.get_legacy_name("backorder_strategy") + ): + openupgrade.map_values( + env.cr, + openupgrade.get_legacy_name("backorder_strategy"), + "create_backorder", + [ + ("manual", "ask"), + ("create", "always"), + ("no_create", "never"), + ("cancel", "never"), + ], + table="stock_picking_type", + ) + + +@openupgrade.migrate() +def migrate(env, version): + handle_stock_picking_backorder_strategy(env) diff --git a/openupgrade_scripts/scripts/stock/16.0.1.1/pre-migration.py b/openupgrade_scripts/scripts/stock/16.0.1.1/pre-migration.py new file mode 100644 index 000000000000..b6d4692f8cc1 --- /dev/null +++ b/openupgrade_scripts/scripts/stock/16.0.1.1/pre-migration.py @@ -0,0 +1,25 @@ +# Copyright (C) 2023-Today GRAP (http://www.grap.coop) +# @author Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openupgradelib import openupgrade + + +def handle_stock_picking_backorder_strategy(env): + # Handle the merge of OCA/stock-logistics-workflow/stock_picking_backorder_strategy + # feature in odoo/stock V16 module. + if openupgrade.column_exists(env.cr, "stock_picking_type", "backorder_strategy"): + # Rename column + openupgrade.rename_columns( + env.cr, + { + "stock_picking_type": [ + ("backorder_strategy", None), + ], + }, + ) + + +@openupgrade.migrate() +def migrate(env, version): + handle_stock_picking_backorder_strategy(env)