From 9bb26bd1c160a01db4f39b9fe0f84c47be13fe37 Mon Sep 17 00:00:00 2001 From: mreficent Date: Thu, 22 Jul 2021 17:33:12 +0200 Subject: [PATCH] [MIG] coupon (from sale_coupon) --- docsource/modules130-140.rst | 4 +- .../scripts/coupon/14.0.1.0/post-migration.py | 11 ++ .../scripts/coupon/14.0.1.0/pre-migration.py | 117 +++++++++++++-- .../coupon/14.0.1.0/upgrade_analysis_work.txt | 134 ++++++++++++++++++ .../14.0.1.0/upgrade_analysis_work.txt | 6 + 5 files changed, 259 insertions(+), 13 deletions(-) create mode 100644 openupgrade_scripts/scripts/coupon/14.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/coupon/14.0.1.0/upgrade_analysis_work.txt create mode 100644 openupgrade_scripts/scripts/sale_coupon/14.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules130-140.rst b/docsource/modules130-140.rst index b102716da5b7..eb3782611ed0 100644 --- a/docsource/modules130-140.rst +++ b/docsource/modules130-140.rst @@ -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 | +--------------------------------------------+-------------------------------------------------+ @@ -582,7 +582,7 @@ Module coverage 13.0 -> 14.0 +--------------------------------------------+-------------------------------------------------+ |sale | | +--------------------------------------------+-------------------------------------------------+ -|sale_coupon | | +|sale_coupon | Done (split in coupon) | +--------------------------------------------+-------------------------------------------------+ |sale_coupon_delivery | | +--------------------------------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/coupon/14.0.1.0/post-migration.py b/openupgrade_scripts/scripts/coupon/14.0.1.0/post-migration.py new file mode 100644 index 000000000000..11321b5d9f50 --- /dev/null +++ b/openupgrade_scripts/scripts/coupon/14.0.1.0/post-migration.py @@ -0,0 +1,11 @@ +# Copyright 2021 ForgeFlow S.L. +# 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"] + ) diff --git a/openupgrade_scripts/scripts/coupon/14.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/coupon/14.0.1.0/pre-migration.py index a565414be9ae..35c9020d9347 100644 --- a/openupgrade_scripts/scripts/coupon/14.0.1.0/pre-migration.py +++ b/openupgrade_scripts/scripts/coupon/14.0.1.0/pre-migration.py @@ -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) diff --git a/openupgrade_scripts/scripts/coupon/14.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/coupon/14.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..db3673a97b79 --- /dev/null +++ b/openupgrade_scripts/scripts/coupon/14.0.1.0/upgrade_analysis_work.txt @@ -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 diff --git a/openupgrade_scripts/scripts/sale_coupon/14.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/sale_coupon/14.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..d605f04d3898 --- /dev/null +++ b/openupgrade_scripts/scripts/sale_coupon/14.0.1.0/upgrade_analysis_work.txt @@ -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'---