From 6b99285279bb18e0ef390409fa4a5b1de69aa21c Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 14 Jul 2021 14:55:08 +0200 Subject: [PATCH 1/2] [MIG] crm --- docsource/modules130-140.rst | 2 +- .../scripts/crm/14.0.1.2/noupdate_changes.xml | 2 +- .../scripts/crm/14.0.1.2/post-migration.py | 11 ++ .../scripts/crm/14.0.1.2/pre-migration.py | 15 +++ .../crm/14.0.1.2/upgrade_analysis_work.txt | 110 ++++++++++++++++++ 5 files changed, 138 insertions(+), 2 deletions(-) create mode 100644 openupgrade_scripts/scripts/crm/14.0.1.2/post-migration.py create mode 100644 openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py create mode 100644 openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt diff --git a/docsource/modules130-140.rst b/docsource/modules130-140.rst index 0acc2741a7ef..3b4532347559 100644 --- a/docsource/modules130-140.rst +++ b/docsource/modules130-140.rst @@ -106,7 +106,7 @@ Module coverage 13.0 -> 14.0 +--------------------------------------------+-------------------------------------------------+ | |new| coupon | | +--------------------------------------------+-------------------------------------------------+ -|crm | | +|crm | Done | +--------------------------------------------+-------------------------------------------------+ |crm_iap_lead | | +--------------------------------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml b/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml index aee66b217e77..7ebd152db694 100644 --- a/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml +++ b/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml @@ -1,7 +1,7 @@ - + diff --git a/openupgrade_scripts/scripts/crm/14.0.1.2/post-migration.py b/openupgrade_scripts/scripts/crm/14.0.1.2/post-migration.py new file mode 100644 index 000000000000..06d5135c1a85 --- /dev/null +++ b/openupgrade_scripts/scripts/crm/14.0.1.2/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, "crm", "14.0.1.2/noupdate_changes.xml") + openupgrade.delete_records_safely_by_xml_id( + env, [("crm.crm_pls_rebuild_threshold_param")] + ) diff --git a/openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py new file mode 100644 index 000000000000..02e8bd60bcc2 --- /dev/null +++ b/openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py @@ -0,0 +1,15 @@ +# 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.rename_fields( + env, + [ + ("crm.lead", "crm_lead", "expected_revenue", "prorated_revenue"), + ("crm.lead", "crm_lead", "planned_revenue", "expected_revenue"), + ], + ) + openupgrade.rename_tables(env.cr, [("crm_lead_tag_rel", "crm_tag_rel")]) diff --git a/openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt new file mode 100644 index 000000000000..cdde2d0f7d29 --- /dev/null +++ b/openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt @@ -0,0 +1,110 @@ +---Models in module 'crm'--- +obsolete model crm.lead.tag (renamed to crm.tag in module sales_team) +obsolete model crm.partner.binding [transient] +new model crm.recurring.plan +# NOTHING TO DO + +---Fields in module 'crm'--- +crm / crm.lead / automated_probability (float) : now a function +crm / crm.lead / city (char) : now a function +crm / crm.lead / contact_name (char) : now a function +crm / crm.lead / country_id (many2one) : now a function +crm / crm.lead / date_last_stage_update (datetime): now a function +crm / crm.lead / date_open (datetime) : now a function +crm / crm.lead / email_from (char) : now a function +crm / crm.lead / function (char) : now a function +crm / crm.lead / mobile (char) : now a function +crm / crm.lead / name (char) : now a function +crm / crm.lead / partner_name (char) : now a function +crm / crm.lead / phone (char) : now a function +crm / crm.lead / phone_sanitized (char) : NEW isfunction: function, stored +crm / crm.lead / probability (float) : now a function +crm / crm.lead / recurring_revenue_monthly (float): NEW isfunction: function, stored +crm / crm.lead / recurring_revenue_monthly_prorated (float): NEW isfunction: function, stored +crm / crm.lead / stage_id (many2one) : now a function +crm / crm.lead / state_id (many2one) : now a function +crm / crm.lead / street (char) : now a function +crm / crm.lead / street2 (char) : now a function +crm / crm.lead / team_id (many2one) : now a function +crm / crm.lead / title (many2one) : now a function +crm / crm.lead / website (char) : now a function +crm / crm.lead / zip (char) : now a function +# NOTHING TO DO: computed in load + +crm / crm.lead / phone_mobile_search (char) : NEW +# NOTHING TO DO: it has store=False + +crm / crm.lead / expected_revenue (float) : not a function anymore +crm / crm.lead / planned_revenue (float) : DEL +crm / crm.lead / prorated_revenue (float) : NEW isfunction: function, stored +# DONE: pre-migration: renamed fields + +crm / crm.lead / recurring_plan (many2one) : NEW relation: crm.recurring.plan +crm / crm.lead / recurring_revenue (float) : NEW +# NOTHING TO DO: related to new crm.recurring.plan model + +crm / crm.lead / tag_ids (many2many) : relation is now 'crm.tag' ('crm.lead.tag') [nothing to do] +crm / crm.lead / tag_ids (many2many) : table is now 'crm_tag_rel' ('crm_lead_tag_rel') +# DONE: pre-migration: renamed table + +crm / crm.lead.tag / __last_update (datetime) : module is now 'sales_team' ('crm') +crm / crm.lead.tag / _order : module is now 'sales_team' ('crm') +crm / crm.lead.tag / color (integer) : module is now 'sales_team' ('crm') +crm / crm.lead.tag / display_name (char) : module is now 'sales_team' ('crm') +crm / crm.lead.tag / name (char) : module is now 'sales_team' ('crm') +# NOTHING TO DO (done in sales_team) + +crm / crm.recurring.plan / active (boolean) : NEW hasdefault +crm / crm.recurring.plan / name (char) : NEW required +crm / crm.recurring.plan / number_of_months (integer) : NEW required +crm / crm.recurring.plan / sequence (integer) : NEW hasdefault +# NOTHING TO DO: new feature + +crm / crm.team / opportunities_amount (integer): type is now 'float' ('integer') +# NOTHING TO DO + +---XML records in module 'crm'--- +NEW crm.recurring.plan: crm.crm_recurring_plan_monthly (noupdate) +NEW crm.recurring.plan: crm.crm_recurring_plan_over_3_years (noupdate) +NEW crm.recurring.plan: crm.crm_recurring_plan_over_5_years (noupdate) +NEW crm.recurring.plan: crm.crm_recurring_plan_yearly (noupdate) +NEW digest.tip: crm.digest_tip_crm_1 +NEW digest.tip: crm.digest_tip_crm_2 +NEW digest.tip: crm.digest_tip_crm_3 +NEW digest.tip: crm.digest_tip_crm_4 +NEW digest.tip: crm.digest_tip_crm_5 +NEW ir.actions.act_window: crm.crm_lead_act_window_compose +NEW ir.actions.act_window: crm.crm_lead_action_my_activities +NEW ir.actions.act_window: crm.crm_recurring_plan_action +DEL ir.actions.act_window: crm.crm_lead_tag_action +DEL ir.actions.act_window: crm.crm_team_act_tree +DEL ir.actions.act_window: crm.relate_partner_opportunities +NEW ir.actions.act_window.view: crm.crm_lead_action_my_activities_view_tree +DEL ir.actions.act_window.view: crm.relate_partner_opportunities_kanban +DEL ir.actions.act_window.view: crm.relate_partner_opportunities_tree +# NOTHING TO DO + +DEL ir.config_parameter: crm.crm_pls_rebuild_threshold_param (noupdate) +# DONE: post-migration: safely deleted xmlid + +NEW ir.model.access: crm.access_crm_lead2opportunity_partner +NEW ir.model.access: crm.access_crm_lead2opportunity_partner_mass +NEW ir.model.access: crm.access_crm_lead_lost +NEW ir.model.access: crm.access_crm_merge_opportunity +NEW ir.model.access: crm.crm_recurring_plan_access_manager +NEW ir.model.access: crm.crm_recurring_plan_access_salesman +DEL ir.model.access: crm.access_crm_lead_tag +DEL ir.model.access: crm.access_crm_lead_tag_manager +DEL ir.model.access: crm.access_crm_lead_tag_salesman +NEW ir.ui.menu: crm.crm_lead_menu_my_activities +NEW ir.ui.menu: crm.crm_recurring_plan_menu_config +NEW ir.ui.view: crm.crm_lead_view_list_activities +NEW ir.ui.view: crm.crm_recurring_plan_view_search +NEW ir.ui.view: crm.crm_recurring_plan_view_tree +NEW ir.ui.view: crm.qunit_suite +NEW ir.ui.view: crm.view_crm_case_my_activities_filter +DEL ir.ui.view: crm.crm_lead_tag_form +DEL ir.ui.view: crm.crm_lead_tag_tree +DEL ir.ui.view: crm.crm_lead_view_tree_activity +NEW res.groups: crm.group_use_recurring_revenues +# NOTHING TO DO From be49b05a12da487db58b01db30399b036f0401af Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 19 Jul 2021 20:14:55 +0200 Subject: [PATCH 2/2] [FIX+IMP] crm + sales_team: Finish migration scripts --- .../scripts/crm/14.0.1.2/noupdate_changes.xml | 10 +-- .../scripts/crm/14.0.1.2/pre-migration.py | 7 ++ .../crm/14.0.1.2/upgrade_analysis_work.txt | 64 +++++++++++-------- .../sales_team/14.0.1.0/pre-migration.py | 12 ++++ .../14.0.1.0/upgrade_analysis_work.txt | 8 +-- 5 files changed, 63 insertions(+), 38 deletions(-) diff --git a/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml b/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml index 7ebd152db694..614d8d92e2fb 100644 --- a/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml +++ b/openupgrade_scripts/scripts/crm/14.0.1.2/noupdate_changes.xml @@ -1,8 +1,8 @@ - - - + @@ -39,8 +39,8 @@ - + diff --git a/openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py b/openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py index 02e8bd60bcc2..b19b5514f1be 100644 --- a/openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py +++ b/openupgrade_scripts/scripts/crm/14.0.1.2/pre-migration.py @@ -1,10 +1,17 @@ # Copyright 2021 ForgeFlow S.L. +# Copyright 2021 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade @openupgrade.migrate() def migrate(env, version): + openupgrade.logged_query( + env.cr, "ALTER TABLE crm_lead ADD recurring_revenue_monthly NUMERIC" + ) + openupgrade.logged_query( + env.cr, "ALTER TABLE crm_lead ADD recurring_revenue_monthly_prorated NUMERIC" + ) openupgrade.rename_fields( env, [ diff --git a/openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt index cdde2d0f7d29..87eca2ebbbeb 100644 --- a/openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/crm/14.0.1.2/upgrade_analysis_work.txt @@ -5,12 +5,13 @@ new model crm.recurring.plan # NOTHING TO DO ---Fields in module 'crm'--- +crm / crm.lead / probability (float) : now a function crm / crm.lead / automated_probability (float) : now a function +# NOTHING TO DO: Computed writable field + already stored field + crm / crm.lead / city (char) : now a function crm / crm.lead / contact_name (char) : now a function crm / crm.lead / country_id (many2one) : now a function -crm / crm.lead / date_last_stage_update (datetime): now a function -crm / crm.lead / date_open (datetime) : now a function crm / crm.lead / email_from (char) : now a function crm / crm.lead / function (char) : now a function crm / crm.lead / mobile (char) : now a function @@ -18,26 +19,31 @@ crm / crm.lead / name (char) : now a crm / crm.lead / partner_name (char) : now a function crm / crm.lead / phone (char) : now a function crm / crm.lead / phone_sanitized (char) : NEW isfunction: function, stored -crm / crm.lead / probability (float) : now a function -crm / crm.lead / recurring_revenue_monthly (float): NEW isfunction: function, stored -crm / crm.lead / recurring_revenue_monthly_prorated (float): NEW isfunction: function, stored -crm / crm.lead / stage_id (many2one) : now a function crm / crm.lead / state_id (many2one) : now a function crm / crm.lead / street (char) : now a function crm / crm.lead / street2 (char) : now a function -crm / crm.lead / team_id (many2one) : now a function crm / crm.lead / title (many2one) : now a function crm / crm.lead / website (char) : now a function crm / crm.lead / zip (char) : now a function -# NOTHING TO DO: computed in load +crm / crm.lead / stage_id (many2one) : now a function +crm / crm.lead / team_id (many2one) : now a function +# NOTHING TO DO: Switched to computed writable fields (replacement of onchanges) + +crm / crm.lead / date_last_stage_update (datetime): now a function +crm / crm.lead / date_open (datetime) : now a function +# NOTHING TO DO: Already stored fields + +crm / crm.lead / recurring_revenue_monthly (float): NEW isfunction: function, stored +crm / crm.lead / recurring_revenue_monthly_prorated (float): NEW isfunction: function, stored +# DONE: pre-migration: pre-create fields for not having any useless computation crm / crm.lead / phone_mobile_search (char) : NEW -# NOTHING TO DO: it has store=False +# NOTHING TO DO: it has store=False and it's only for searching purposes crm / crm.lead / expected_revenue (float) : not a function anymore crm / crm.lead / planned_revenue (float) : DEL crm / crm.lead / prorated_revenue (float) : NEW isfunction: function, stored -# DONE: pre-migration: renamed fields +# DONE: pre-migration: renamed fields in the proper order: expected > prorrated; planned > expected crm / crm.lead / recurring_plan (many2one) : NEW relation: crm.recurring.plan crm / crm.lead / recurring_revenue (float) : NEW @@ -52,7 +58,7 @@ crm / crm.lead.tag / _order : module crm / crm.lead.tag / color (integer) : module is now 'sales_team' ('crm') crm / crm.lead.tag / display_name (char) : module is now 'sales_team' ('crm') crm / crm.lead.tag / name (char) : module is now 'sales_team' ('crm') -# NOTHING TO DO (done in sales_team) +# NOTHING TO DO: handled by ORM crm / crm.recurring.plan / active (boolean) : NEW hasdefault crm / crm.recurring.plan / name (char) : NEW required @@ -61,7 +67,7 @@ crm / crm.recurring.plan / sequence (integer) : NEW ha # NOTHING TO DO: new feature crm / crm.team / opportunities_amount (integer): type is now 'float' ('integer') -# NOTHING TO DO +# NOTHING TO DO: It's not stored ---XML records in module 'crm'--- NEW crm.recurring.plan: crm.crm_recurring_plan_monthly (noupdate) @@ -76,26 +82,13 @@ NEW digest.tip: crm.digest_tip_crm_5 NEW ir.actions.act_window: crm.crm_lead_act_window_compose NEW ir.actions.act_window: crm.crm_lead_action_my_activities NEW ir.actions.act_window: crm.crm_recurring_plan_action -DEL ir.actions.act_window: crm.crm_lead_tag_action -DEL ir.actions.act_window: crm.crm_team_act_tree -DEL ir.actions.act_window: crm.relate_partner_opportunities NEW ir.actions.act_window.view: crm.crm_lead_action_my_activities_view_tree -DEL ir.actions.act_window.view: crm.relate_partner_opportunities_kanban -DEL ir.actions.act_window.view: crm.relate_partner_opportunities_tree -# NOTHING TO DO - -DEL ir.config_parameter: crm.crm_pls_rebuild_threshold_param (noupdate) -# DONE: post-migration: safely deleted xmlid - NEW ir.model.access: crm.access_crm_lead2opportunity_partner NEW ir.model.access: crm.access_crm_lead2opportunity_partner_mass NEW ir.model.access: crm.access_crm_lead_lost NEW ir.model.access: crm.access_crm_merge_opportunity NEW ir.model.access: crm.crm_recurring_plan_access_manager NEW ir.model.access: crm.crm_recurring_plan_access_salesman -DEL ir.model.access: crm.access_crm_lead_tag -DEL ir.model.access: crm.access_crm_lead_tag_manager -DEL ir.model.access: crm.access_crm_lead_tag_salesman NEW ir.ui.menu: crm.crm_lead_menu_my_activities NEW ir.ui.menu: crm.crm_recurring_plan_menu_config NEW ir.ui.view: crm.crm_lead_view_list_activities @@ -103,8 +96,23 @@ NEW ir.ui.view: crm.crm_recurring_plan_view_search NEW ir.ui.view: crm.crm_recurring_plan_view_tree NEW ir.ui.view: crm.qunit_suite NEW ir.ui.view: crm.view_crm_case_my_activities_filter +NEW res.groups: crm.group_use_recurring_revenues +# NOTHING TO DO: New records + +DEL ir.config_parameter: crm.crm_pls_rebuild_threshold_param (noupdate) +# DONE: post-migration: safely deleted xmlid + +DEL ir.actions.act_window: crm.crm_team_act_tree +DEL ir.actions.act_window: crm.relate_partner_opportunities +DEL ir.actions.act_window.view: crm.relate_partner_opportunities_kanban +DEL ir.actions.act_window.view: crm.relate_partner_opportunities_tree +DEL ir.ui.view: crm.crm_lead_view_tree_activity +# NOTHING TO DO: Delete records with no correspondence + +DEL ir.actions.act_window: crm.crm_lead_tag_action DEL ir.ui.view: crm.crm_lead_tag_form DEL ir.ui.view: crm.crm_lead_tag_tree -DEL ir.ui.view: crm.crm_lead_view_tree_activity -NEW res.groups: crm.group_use_recurring_revenues -# NOTHING TO DO +DEL ir.model.access: crm.access_crm_lead_tag +DEL ir.model.access: crm.access_crm_lead_tag_manager +DEL ir.model.access: crm.access_crm_lead_tag_salesman +# NOTHING TO DO: Renamed in sales_team \ No newline at end of file diff --git a/openupgrade_scripts/scripts/sales_team/14.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/sales_team/14.0.1.0/pre-migration.py index 0ded3e424e4f..ef2d88caa41b 100644 --- a/openupgrade_scripts/scripts/sales_team/14.0.1.0/pre-migration.py +++ b/openupgrade_scripts/scripts/sales_team/14.0.1.0/pre-migration.py @@ -1,4 +1,5 @@ # Copyright 2021 ForgeFlow S.L. +# Copyright 2021 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade @@ -21,3 +22,14 @@ def migrate(env, version): openupgrade.set_xml_ids_noupdate_value( env, "sales_team", ["crm_rule_all_salesteam", "sale_team_comp_rule"], True ) + openupgrade.rename_xmlids( + env.cr, + [ + ("crm.crm_lead_tag_action", "sales_team.sales_team_crm_tag_action"), + ("crm.crm_lead_tag_form", "sales_team.sales_team_crm_tag_view_form"), + ("crm.crm_lead_tag_tree", "sales_team.sales_team_crm_tag_view_tree"), + ("crm.access_crm_lead_tag", "sales_team.access_crm_tag"), + ("crm.access_crm_lead_tag_manager", "sales_team.access_crm_tag_manager"), + ("crm.access_crm_lead_tag_salesman", "sales_team.access_crm_tag_salesman"), + ], + ) diff --git a/openupgrade_scripts/scripts/sales_team/14.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/sales_team/14.0.1.0/upgrade_analysis_work.txt index 75d5500dd507..8ba1c884fb84 100644 --- a/openupgrade_scripts/scripts/sales_team/14.0.1.0/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/sales_team/14.0.1.0/upgrade_analysis_work.txt @@ -12,15 +12,13 @@ sales_team / crm.lead.tag / name (char) : previo ---XML records in module 'sales_team'--- NEW ir.actions.act_window: sales_team.sales_team_crm_tag_action +NEW ir.ui.view: sales_team.sales_team_crm_tag_view_form +NEW ir.ui.view: sales_team.sales_team_crm_tag_view_tree NEW ir.model.access: sales_team.access_crm_tag NEW ir.model.access: sales_team.access_crm_tag_manager NEW ir.model.access: sales_team.access_crm_tag_salesman -# NOTHING TO DO +# DONE: pre-migration: Renamed from crm module ir.rule: sales_team.crm_rule_all_salesteam (noupdate) (noupdate switched) ir.rule: sales_team.sale_team_comp_rule (noupdate) (noupdate switched) # DONE: pre-migration: switched noupdate - -NEW ir.ui.view: sales_team.sales_team_crm_tag_view_form -NEW ir.ui.view: sales_team.sales_team_crm_tag_view_tree -# NOTHING TO DO