From 7492beaeae87dcaca3e4b490846143b0d54c3826 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 8 Apr 2023 11:40:23 +0200 Subject: [PATCH] [ADD] Apriori: 'stock_picking_backorder_strategy' merged into 'stock'. [MIG] stock: - Rename stock_picking_type field 'backorder_strategy' -> 'create_backorder'; - Map values : {'manual': 'ask', 'no_create': 'never', 'cancel': never', 'create': 'always'} --- .../scripts/stock/16.0.1.1/post-migration.py | 19 +++++++++++++++++++ .../scripts/stock/16.0.1.1/pre-migration.py | 15 +++++++++++++++ 2 files changed, 34 insertions(+) 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 index 934b4812dd0d..d1756de9e178 100644 --- a/openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py +++ b/openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py @@ -1,6 +1,25 @@ 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) openupgrade.load_data(env.cr, "stock", "16.0.1.1/noupdate_changes.xml") 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 index 548d40875c6e..884de5078c02 100644 --- a/openupgrade_scripts/scripts/stock/16.0.1.1/pre-migration.py +++ b/openupgrade_scripts/scripts/stock/16.0.1.1/pre-migration.py @@ -111,6 +111,20 @@ def _update_stock_quant_package_pack_date(env): """, ) +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): @@ -122,3 +136,4 @@ def migrate(env, version): _update_stock_quant_package_pack_date(env) _update_sol_product_category_name(env) _compute_stock_location_replenish_location(env) + _handle_stock_picking_backorder_strategy(env)