diff --git a/addons/crm/migrations/9.0.1.0/openupgrade_analysis_work.txt b/addons/crm/migrations/9.0.1.0/openupgrade_analysis_work.txt index a91537a1dd50..1c45011c00c0 100644 --- a/addons/crm/migrations/9.0.1.0/openupgrade_analysis_work.txt +++ b/addons/crm/migrations/9.0.1.0/openupgrade_analysis_work.txt @@ -46,7 +46,7 @@ crm / crm.lead / priority (selection) : select crm / crm.lead / ref (reference) : DEL crm / crm.lead / ref2 (reference) : DEL -# Nothing to do +# Migrated to sale order's opportunity field in sale_crm where applicable crm / crm.lead / section_id (many2one) : relation is now 'crm.team' ('crm.case.section') crm / crm.lead / section_id (many2one) : was renamed to team_id [nothing to to] diff --git a/addons/crm/migrations/9.0.1.0/pre-migration.py b/addons/crm/migrations/9.0.1.0/pre-migration.py index ab4d0d740a3e..dcd98a0e83b4 100644 --- a/addons/crm/migrations/9.0.1.0/pre-migration.py +++ b/addons/crm/migrations/9.0.1.0/pre-migration.py @@ -19,6 +19,8 @@ ], 'crm_lead': [ ('section_id', 'team_id'), + ('ref', None), + ('ref2', None), ], 'section_stage_rel': [ ('section_id', 'team_id'), diff --git a/addons/sale_crm/migrations/9.0.1.0/openupgrade_analysis_work.txt b/addons/sale_crm/migrations/9.0.1.0/openupgrade_analysis_work.txt new file mode 100644 index 000000000000..2b1d027e85b3 --- /dev/null +++ b/addons/sale_crm/migrations/9.0.1.0/openupgrade_analysis_work.txt @@ -0,0 +1,22 @@ +---Fields in module 'sale_crm'--- +sale_crm / crm.lead / order_ids (one2many) : NEW relation: sale.order +sale_crm / sale.order / opportunity_id (many2one) : NEW relation: crm.lead +# Done: migrate sale orders referenced in crm lead model +sale_crm / sale.order / categ_ids (many2many) : DEL relation: crm.case.categ +sale_crm / sale.order / tag_ids (many2many) : NEW relation: crm.lead.tag +# Done: renamed reference table and column name +sale_crm / sale.order / campaign_id (many2one) : relation is now 'utm.campaign' ('crm.tracking.campaign') +sale_crm / sale.order / medium_id (many2one) : relation is now 'utm.medium' ('crm.tracking.medium') +sale_crm / sale.order / source_id (many2one) : relation is now 'utm.source' ('crm.tracking.source') +# Done: select link ids from tables migrated in crm module +sale_crm / res.users / target_sales_invoiced (integer): NEW +# Nothing to do: new field with no logic associated to it, just for reference purposes. +---XML records in module 'sale_crm'--- +NEW ir.actions.act_window: crm.crm_lead_opportunities +NEW ir.actions.act_window: sale_crm.sale_action_quotations +NEW ir.actions.act_window: sale_crm.sale_action_quotations_new +DEL ir.actions.act_window: crm.crm_case_category_act_oppor11 +DEL ir.actions.act_window: sale_crm.action_crm_make_sale +NEW ir.ui.view: sale_crm.crm_team_salesteams_view_kanban +NEW ir.ui.view: sale_crm.res_partner_address_type +DEL ir.ui.view: sale_crm.view_crm_make_sale diff --git a/addons/sale_crm/migrations/9.0.1.0/post-migrate.py b/addons/sale_crm/migrations/9.0.1.0/post-migrate.py new file mode 100644 index 000000000000..31a41769f474 --- /dev/null +++ b/addons/sale_crm/migrations/9.0.1.0/post-migrate.py @@ -0,0 +1,38 @@ +# coding: utf-8 +# © 2016 Opener B.V. - Stefan Rijnhart +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade +from psycopg2.extensions import AsIs + + +def get_sale_order_opportunity_id(env): + """ Fetch sale order references from the obsolete reference + fields from the crm module """ + env.cr.execute( + """UPDATE sale_order so + SET opportunity_id = cl.id + FROM crm_lead cl + WHERE cl.%s = 'sale.order,'||so.id + OR cl.%s = 'sale.order,'||so.id""", + (AsIs(openupgrade.get_legacy_name('ref')), + AsIs(openupgrade.get_legacy_name('ref2')))) + + +def get_sale_order_link_id(env, link): + openupgrade.logged_query( + env.cr, """\ + UPDATE sale_order so + SET %(link)s_id = uc.id + FROM utm_%(link)s uc + WHERE so.%(legacy)s IS NOT NULL + AND so.%(legacy)s = uc.crm_tracking_%(link)s_id""", { + 'link': AsIs(link), + 'legacy': AsIs(openupgrade.get_legacy_name('%s_id' % link)), + }) + + +@openupgrade.migrate(use_env=True) +def migrate(env, version): + get_sale_order_opportunity_id(env) + for link in 'campaign', 'medium', 'source': + get_sale_order_link_id(env, link) diff --git a/addons/sale_crm/migrations/9.0.1.0/pre-migrate.py b/addons/sale_crm/migrations/9.0.1.0/pre-migrate.py new file mode 100644 index 000000000000..ed1d28c25394 --- /dev/null +++ b/addons/sale_crm/migrations/9.0.1.0/pre-migrate.py @@ -0,0 +1,17 @@ +# coding: utf-8 +# © 2016 Opener B.V. - Stefan Rijnhart +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(cr, version): + openupgrade.rename_tables( + cr, [('sale_order_category_rel', 'sale_order_tag_rel')]) + openupgrade.rename_columns(cr, { + 'sale_order_tag_rel': [('category_id', 'tag_id')], + 'sale_order': [ + ('campaign_id', None), + ('medium_id', None), + ('source_id', None), + ]}) diff --git a/openerp/openupgrade/doc/source/modules80-90.rst b/openerp/openupgrade/doc/source/modules80-90.rst index c3c103ab497b..dc2b5d48f052 100644 --- a/openerp/openupgrade/doc/source/modules80-90.rst +++ b/openerp/openupgrade/doc/source/modules80-90.rst @@ -394,7 +394,7 @@ Status : +-----------------------------------+-----------------------------------+ |sale | Done | +-----------------------------------+-----------------------------------+ -|sale_crm | | +|sale_crm | Done | +-----------------------------------+-----------------------------------+ |sale_expense | | +-----------------------------------+-----------------------------------+