Skip to content

Commit

Permalink
[ADD] Apriori: 'stock_picking_backorder_strategy' merged into 'stock'.
Browse files Browse the repository at this point in the history
[MIG] stock:
- Rename stock_picking_type field 'backorder_strategy' -> 'create_backorder';
- Map values : {'manual': 'ask', 'no_create': 'never', 'cancel': never', 'create': 'always'}
  • Loading branch information
legalsylvain committed Oct 9, 2024
1 parent 47eb453 commit bcb8d61
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
21 changes: 21 additions & 0 deletions openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,28 @@ def _handle_multi_location_visibility(env):
view.active = False


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_multi_location_visibility(env)
_handle_stock_picking_backorder_strategy(env)
openupgrade.load_data(env.cr, "stock", "16.0.1.1/noupdate_changes.xml")
16 changes: 16 additions & 0 deletions openupgrade_scripts/scripts/stock/16.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ 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):
openupgrade.rename_tables(env.cr, _tables_renames)
Expand All @@ -122,3 +137,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)

0 comments on commit bcb8d61

Please sign in to comment.