Skip to content

Commit

Permalink
[16.0][MIG] crm
Browse files Browse the repository at this point in the history
  • Loading branch information
marielejeune committed Mar 14, 2023
1 parent 1f8a1bd commit 0625e9f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
36 changes: 36 additions & 0 deletions openupgrade_scripts/scripts/crm/16.0.1.8/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2023 ACSONE SA/NV
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade

_column_renames = {
"crm_lead": [
("lost_reason", "lost_reason_id"),
],
}


def res_partner_compute_team_id(env):
openupgrade.logged_query(
env.cr,
"""
UPDATE res_partner as p
SET team_id = res.parent_team_id
FROM(
SELECT p.id, parent.team_id
FROM res_partner p
JOIN res_partner parent
ON p.parent_id = parent.id
WHERE p.team_id IS NULL
AND p.is_company='f'
AND parent.team_id IS NOT NULL
) as res(partner_id, parent_team_id)
WHERE p.id = res.partner_id
""",
)


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, _column_renames)
res_partner_compute_team_id(env)
19 changes: 19 additions & 0 deletions openupgrade_scripts/scripts/crm/16.0.1.8/upgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---Models in module 'crm'---
---Fields in module 'crm'---
crm / crm.lead / lead_properties (properties) : NEW hasdefault: compute
# NOTHING TO DO: new feature

crm / crm.lead / lost_reason (many2one) : DEL relation: crm.lost.reason
crm / crm.lead / lost_reason_id (many2one) : NEW relation: crm.lost.reason
# DONE: pre-migration: rename column

crm / crm.team / lead_properties_definition (properties_definition): NEW
# NOTHING TO DO: new feature

crm / res.partner / team_id (False) : NEW mode: modify, hasdefault: compute
# DONE: pre-migration: compute value in DB

---XML records in module 'crm'---
NEW ir.ui.view: crm.crm_lead_merge_summary
NEW ir.ui.view: crm.crm_lead_view_tree_reporting
# NOTHING TO DO

0 comments on commit 0625e9f

Please sign in to comment.