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 Dec 20, 2023
1 parent 73c8df2 commit 52d5646
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
30 changes: 30 additions & 0 deletions openupgrade_scripts/scripts/stock/16.0.1.1/post-migration.py
Original file line number Diff line number Diff line change
@@ -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)
25 changes: 25 additions & 0 deletions openupgrade_scripts/scripts/stock/16.0.1.1/pre-migration.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 52d5646

Please sign in to comment.