Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] coupon (from sale_coupon) #2861

Merged
merged 1 commit into from
Jul 21, 2022
Merged
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
4 changes: 2 additions & 2 deletions docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|contacts | Nothing to do |
+--------------------------------------------+-------------------------------------------------+
| |new| coupon | |
| |new| coupon | Done (split from sale_coupon) |
+--------------------------------------------+-------------------------------------------------+
|crm | Done |
+--------------------------------------------+-------------------------------------------------+
Expand Down Expand Up @@ -582,7 +582,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|sale | |
+--------------------------------------------+-------------------------------------------------+
|sale_coupon | |
|sale_coupon | Done (split in coupon) |
+--------------------------------------------+-------------------------------------------------+
|sale_coupon_delivery | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
11 changes: 11 additions & 0 deletions openupgrade_scripts/scripts/coupon/14.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.load_data(env.cr, "coupon", "14.0.1.0/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr, "coupon", ["mail_template_sale_coupon"]
)
117 changes: 106 additions & 11 deletions openupgrade_scripts/scripts/coupon/14.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,117 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openupgradelib import openupgrade

to_install = [
"sale_coupon",
_column_renames = {
"product_product_sale_coupon_reward_rel": [
("sale_coupon_reward_id", "coupon_reward_id"),
],
"sale_coupon_program_sale_order_rel": [
("sale_coupon_program_id", "coupon_program_id"),
],
}

_model_renames = [
("sale.coupon", "coupon.coupon"),
("sale.coupon.generate", "coupon.generate.wizard"),
("sale.coupon.program", "coupon.program"),
("sale.coupon.reward", "coupon.reward"),
("sale.coupon.rule", "coupon.rule"),
("report.sale_coupon.report_coupon", "report.coupon.report_coupon"),
]

_table_renames = [
("sale_coupon", "coupon_coupon"),
("sale_coupon_generate", "coupon_generate_wizard"),
("sale_coupon_program", "coupon_program"),
("sale_coupon_reward", "coupon_reward"),
("sale_coupon_rule", "coupon_rule"),
("product_product_sale_coupon_reward_rel", "coupon_reward_product_product_rel"),
("sale_coupon_program_sale_order_rel", "coupon_program_sale_order_rel"),
]

_xmlid_renames = [
# rename suffix:
("coupon.sale_coupon_action", "coupon.coupon_action"),
("coupon.sale_coupon_generate_action", "coupon.coupon_generate_action"),
(
"coupon.sale_coupon_program_action_coupon_program",
"coupon.coupon_program_action_coupon_program",
),
(
"coupon.sale_coupon_program_action_promo_program",
"coupon.coupon_program_action_promo_program",
),
("coupon.sale_coupon_generate_view_form", "coupon.coupon_generate_view_form"),
(
"coupon.sale_coupon_program_view_form_common",
"coupon.coupon_program_view_form_common",
),
("coupon.sale_coupon_view_form", "coupon.coupon_view_form"),
("coupon.sale_coupon_view_tree", "coupon.coupon_view_tree"),
(
"coupon.sale_coupon_program_view_promo_program_search",
"coupon.coupon_program_view_promo_program_search",
),
(
"coupon.sale_coupon_program_view_promo_program_tree",
"coupon.coupon_program_view_promo_program_tree",
),
(
"coupon.sale_coupon_program_view_form",
"coupon.coupon_program_view_coupon_program_form",
),
("coupon.sale_coupon_program_view_search", "coupon.coupon_program_view_search"),
("coupon.sale_coupon_program_view_tree", "coupon.coupon_program_view_tree"),
("coupon.view_sale_coupon_program_kanban", "coupon.view_coupon_program_kanban"),
(
"coupon.sale_coupon_program_view_promo_program_form",
"coupon.coupon_program_view_promo_program_form",
),
# rename prefix:
(
"coupon.sale_coupon_apply_code_action",
"sale_coupon.sale_coupon_apply_code_action",
),
("coupon.sale_order_action", "sale_coupon.sale_order_action"),
("coupon.access_applicability_manager", "sale_coupon.access_applicability_manager"),
(
"coupon.access_applicability_salesman",
"sale_coupon.access_applicability_salesman",
),
("coupon.access_coupon_manager", "sale_coupon.access_coupon_manager"),
("coupon.access_coupon_salesman", "sale_coupon.access_coupon_salesman"),
("coupon.access_program_manager", "sale_coupon.access_program_manager"),
("coupon.access_program_salesman", "sale_coupon.access_program_salesman"),
("coupon.access_reward_manager", "sale_coupon.access_reward_manager"),
("coupon.access_reward_salesman", "sale_coupon.access_reward_salesman"),
("coupon.menu_coupon_type_config", "sale_coupon.menu_coupon_type_config"),
("coupon.menu_promotion_type_config", "sale_coupon.menu_promotion_type_config"),
(
"coupon.res_config_settings_view_form",
"sale_coupon.res_config_settings_view_form",
),
(
"coupon.sale_coupon_apply_code_view_form",
"sale_coupon.sale_coupon_apply_code_view_form",
),
("coupon.sale_order_view_form", "sale_coupon.sale_order_view_form"),
]


def install_new_modules(cr):
sql = """
UPDATE ir_module_module
SET state='to install'
WHERE name = {} AND state='uninstalled'
""".format(
tuple(to_install),
def install_new_modules(env):
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_module_module
SET state='to install'
WHERE name = 'sale_coupon' AND state='uninstalled'""",
)
openupgrade.logged_query(cr, sql)


@openupgrade.migrate()
def migrate(env, version):
install_new_modules(env.cr)
openupgrade.rename_columns(env.cr, _column_renames)
openupgrade.rename_models(env.cr, _model_renames)
openupgrade.rename_tables(env.cr, _table_renames)
openupgrade.rename_xmlids(env.cr, _xmlid_renames)
install_new_modules(env)
134 changes: 134 additions & 0 deletions openupgrade_scripts/scripts/coupon/14.0.1.0/upgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---Models in module 'coupon'---
model sale.coupon.apply.code (moved to sale_coupon) [transient]
# NOTHING TO DO: this is due to the module rename

new model coupon.coupon (renamed from sale.coupon)
new model coupon.generate.wizard (renamed from sale.coupon.generate) [transient]
new model coupon.program (renamed from sale.coupon.program)
new model coupon.reward (renamed from sale.coupon.reward)
new model coupon.rule (renamed from sale.coupon.rule)
new model report.coupon.report_coupon (renamed from report.sale_coupon.report_coupon) [abstract]
obsolete model sale.coupon (renamed to coupon.coupon)
obsolete model sale.coupon.generate (renamed to coupon.generate.wizard) [transient]
obsolete model sale.coupon.program (renamed to coupon.program)
obsolete model sale.coupon.reward (renamed to coupon.reward)
obsolete model sale.coupon.rule (renamed to coupon.rule)
obsolete model report.sale_coupon.report_coupon (renamed to report.coupon.report_coupon) [abstract]
# DONE: pre-migration: renamed models and tables

---Fields in module 'coupon'---
sale_coupon / sale.coupon / program_id (many2one) : relation is now 'coupon.program' ('sale.coupon.program') [nothing to do]
sale_coupon / sale.coupon.program / coupon_ids (one2many) : relation is now 'coupon.coupon' ('sale.coupon') [nothing to do]
sale_coupon / sale.coupon.program / reward_id (many2one) : relation is now 'coupon.reward' ('sale.coupon.reward') [nothing to do]
sale_coupon / sale.coupon.program / rule_id (many2one) : relation is now 'coupon.rule' ('sale.coupon.rule') [nothing to do]
sale_coupon / sale.order / applied_coupon_ids (one2many) : relation is now 'coupon.coupon' ('sale.coupon') [nothing to do]
sale_coupon / sale.order / code_promo_program_id (many2one): relation is now 'coupon.program' ('sale.coupon.program') [nothing to do]
sale_coupon / sale.order / generated_coupon_ids (one2many): relation is now 'coupon.coupon' ('sale.coupon') [nothing to do]
sale_coupon / sale.order / no_code_promo_program_ids (many2many): relation is now 'coupon.program' ('sale.coupon.program') [nothing to do]
sale_coupon / sale.coupon.program / _inherits : _inherits is now '{'coupon.rule': 'rule_id', 'coupon.reward': 'reward_id'}' ('{'sale.coupon.rule': 'rule_id', 'sale.coupon.reward': 'reward_id'}')
# NOTHING TO DO: due to model renames

sale_coupon / sale.coupon / state (selection) : selection_keys is now '['cancel', 'expired', 'new', 'reserved', 'sent', 'used']' ('['expired', 'new', 'reserved', 'used']')
# NOTHING TO DO: new keys

sale_coupon / sale.coupon.reward / discount_specific_product_ids (many2many): column1 is now 'coupon_reward_id' ('sale_coupon_reward_id') [product_product_sale_coupon_reward_rel]
sale_coupon / sale.coupon.reward / discount_specific_product_ids (many2many): table is now 'coupon_reward_product_product_rel' ('product_product_sale_coupon_reward_rel')
sale_coupon / sale.order / no_code_promo_program_ids (many2many): column2 is now 'coupon_program_id' ('sale_coupon_program_id') [sale_coupon_program_sale_order_rel]
sale_coupon / sale.order / no_code_promo_program_ids (many2many): table is now 'coupon_program_sale_order_rel' ('sale_coupon_program_sale_order_rel')
# DONE: pre-migration: renamed columns and tables

---XML records in module 'coupon'---
NEW ir.actions.act_window: sale_coupon.sale_coupon_apply_code_action [moved from sale_coupon module]
DEL ir.actions.act_window: sale_coupon.sale_coupon_apply_code_action [moved to sale_coupon module]
NEW ir.actions.act_window: sale_coupon.sale_order_action [moved from sale_coupon module]
DEL ir.actions.act_window: sale_coupon.sale_order_action [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_applicability_manager [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_applicability_manager [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_applicability_salesman [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_applicability_salesman [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_coupon_manager [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_coupon_manager [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_coupon_salesman [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_coupon_salesman [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_program_manager [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_program_manager [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_program_salesman [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_program_salesman [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_reward_manager [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_reward_manager [moved to sale_coupon module]
NEW ir.model.access: sale_coupon.access_reward_salesman [moved from sale_coupon module]
DEL ir.model.access: sale_coupon.access_reward_salesman [moved to sale_coupon module]
NEW ir.ui.menu: sale_coupon.menu_coupon_type_config [moved from sale_coupon module]
DEL ir.ui.menu: sale_coupon.menu_coupon_type_config [moved to sale_coupon module]
NEW ir.ui.menu: sale_coupon.menu_promotion_type_config [moved from sale_coupon module]
DEL ir.ui.menu: sale_coupon.menu_promotion_type_config [moved to sale_coupon module]
NEW ir.ui.view: sale_coupon.res_config_settings_view_form [moved from sale_coupon module]
DEL ir.ui.view: sale_coupon.res_config_settings_view_form [moved to sale_coupon module]
NEW ir.ui.view: sale_coupon.sale_coupon_apply_code_view_form [moved from sale_coupon module]
DEL ir.ui.view: sale_coupon.sale_coupon_apply_code_view_form [moved to sale_coupon module]
NEW ir.ui.view: sale_coupon.sale_order_view_form [moved from sale_coupon module]
DEL ir.ui.view: sale_coupon.sale_order_view_form [moved to sale_coupon module]
# DONE: pre-migration: rename prefix to sale_coupon


NEW ir.model.access: sale_coupon.access_sale_coupon_apply_code
NEW ir.model.access: sale_coupon.access_sale_coupon_generate
NEW ir.rule: sale_coupon.sale_coupon_apply_code_rule (noupdate)
NEW ir.ui.view: sale_coupon.sale_coupon_program_view_promo_program_form [moved from sale_coupon module]
NEW ir.ui.view: sale_coupon.sale_coupon_view_form [moved from sale_coupon module]
NEW ir.ui.view: sale_coupon.sale_coupon_view_tree [moved from sale_coupon module]
NEW ir.ui.view: sale_coupon.sale_coupon_program_view_coupon_program_form
NEW ir.ui.view: sale_coupon.sale_coupon_view_coupon_program_kanban
# NOTHING TO DO: new things in sale_coupon

NEW ir.actions.report: coupon.report_coupon_code [renamed from sale_coupon module]
DEL ir.actions.report: sale_coupon.report_coupon_code [renamed to coupon module]
NEW ir.cron: coupon.expire_coupon_cron [renamed from sale_coupon module] (noupdate)
DEL ir.cron: sale_coupon.expire_coupon_cron [renamed to coupon module] (noupdate)
NEW mail.template: coupon.mail_template_sale_coupon [renamed from sale_coupon module] (noupdate)
DEL mail.template: sale_coupon.mail_template_sale_coupon [renamed to coupon module] (noupdate)
NEW ir.ui.view: coupon.report_coupon
DEL ir.ui.view: sale_coupon.report_coupon
NEW ir.ui.view: coupon.report_coupon_i18n
DEL ir.ui.view: sale_coupon.report_coupon_i18n
# NOTHING TO DO: because the prefix is corrected when doing the module rename

NEW ir.model.access: coupon.access_coupon_coupon
NEW ir.model.access: coupon.access_coupon_generate_wizard
NEW ir.model.access: coupon.access_coupon_program
NEW ir.model.access: coupon.access_coupon_reward
NEW ir.model.access: coupon.access_coupon_rule
NEW ir.rule: coupon.sale_coupon_generate_rule (noupdate)
# NOTHING TO DO: new things in coupon

NEW ir.actions.act_window: coupon.coupon_action
DEL ir.actions.act_window: sale_coupon.sale_coupon_action
NEW ir.actions.act_window: coupon.coupon_generate_action
DEL ir.actions.act_window: sale_coupon.sale_coupon_generate_action
NEW ir.actions.act_window: coupon.coupon_program_action_coupon_program
DEL ir.actions.act_window: sale_coupon.sale_coupon_program_action_coupon_program
NEW ir.actions.act_window: coupon.coupon_program_action_promo_program
DEL ir.actions.act_window: sale_coupon.sale_coupon_program_action_promo_program
NEW ir.ui.view: coupon.coupon_generate_view_form
DEL ir.ui.view: sale_coupon.sale_coupon_generate_view_form
NEW ir.ui.view: coupon.coupon_program_view_form_common
DEL ir.ui.view: sale_coupon.sale_coupon_program_view_form_common
NEW ir.ui.view: coupon.coupon_view_form
DEL ir.ui.view: sale_coupon.sale_coupon_view_form [moved to sale_coupon module]
NEW ir.ui.view: coupon.coupon_view_tree
DEL ir.ui.view: sale_coupon.sale_coupon_view_tree [moved to sale_coupon module]
NEW ir.ui.view: coupon.coupon_program_view_promo_program_search
DEL ir.ui.view: sale_coupon.sale_coupon_program_view_promo_program_search
NEW ir.ui.view: coupon.coupon_program_view_promo_program_tree
DEL ir.ui.view: sale_coupon.sale_coupon_program_view_promo_program_tree
NEW ir.ui.view: coupon.coupon_program_view_coupon_program_form
DEL ir.ui.view: sale_coupon.sale_coupon_program_view_form
NEW ir.ui.view: coupon.coupon_program_view_search
DEL ir.ui.view: sale_coupon.sale_coupon_program_view_search
NEW ir.ui.view: coupon.coupon_program_view_tree
DEL ir.ui.view: sale_coupon.sale_coupon_program_view_tree
NEW ir.ui.view: coupon.view_coupon_program_kanban
DEL ir.ui.view: sale_coupon.view_sale_coupon_program_kanban
NEW ir.ui.view: coupon.coupon_program_view_promo_program_form
DEL ir.ui.view: sale_coupon.sale_coupon_program_view_promo_program_form [moved to sale_coupon module]
# DONE: pre-migration: renamed xmlids
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---Models in module 'sale_coupon'---
model sale.coupon.apply.code (moved from sale_coupon) [transient]
# NOTHING TO DO

---Fields in module 'sale_coupon'---
---XML records in module 'sale_coupon'---