Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions addons/crm/migrations/9.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
],
'crm_lead': [
('section_id', 'team_id'),
('ref', None),
('ref2', None),
],
'section_stage_rel': [
('section_id', 'team_id'),
Expand Down
22 changes: 22 additions & 0 deletions addons/sale_crm/migrations/9.0.1.0/openupgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions addons/sale_crm/migrations/9.0.1.0/post-migrate.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 17 additions & 0 deletions addons/sale_crm/migrations/9.0.1.0/pre-migrate.py
Original file line number Diff line number Diff line change
@@ -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),
]})
2 changes: 1 addition & 1 deletion openerp/openupgrade/doc/source/modules80-90.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Status :
+-----------------------------------+-----------------------------------+
|sale | Done |
+-----------------------------------+-----------------------------------+
|sale_crm | |
|sale_crm | Done |
+-----------------------------------+-----------------------------------+
|sale_expense | |
+-----------------------------------+-----------------------------------+
Expand Down