Skip to content
Open
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
2 changes: 1 addition & 1 deletion docsource/modules180-190.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Module coverage 18.0 -> 19.0
+---------------------------------------------------+----------------------+-------------------------------------------------+
| contacts | | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| crm | | |
| crm |Done | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
| crm_iap_enrich | |No DB layout changes. |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
12 changes: 12 additions & 0 deletions openupgrade_scripts/scripts/crm/19.0.1.9/post-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from openupgradelib import openupgrade


@openupgrade.migrate()
def migrate(env, version):
openupgrade.m2o_to_x2m(
env.cr,
env["crm.stage"],
"crm_stage",
"team_ids",
"team_id",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from odoo.tests import TransactionCase

from odoo.addons.openupgrade_framework import openupgrade_test


@openupgrade_test
class TestCrmMigration(TransactionCase):
def test_stage_team_m2m_populated(self):
"""The m2o→m2m promotion on crm.stage.team_id must preserve
relationships in the new team_ids m2m field.
"""
self.assertTrue(
self.env["crm.stage"].search([("team_ids", "!=", False)], limit=1),
"Migration should have populated crm.stage.team_ids from the "
"legacy team_id column.",
)

def test_legacy_column_remains(self):
"""Pre-migration renames the legacy FK column; it should still
be on disk so a later database_cleanup pass can drop it.
"""
self.env.cr.execute(
"""
SELECT column_name FROM information_schema.columns
WHERE table_name = 'crm_stage'
AND column_name = 'openupgrade_legacy_19_0_team_id'
"""
)
self.assertEqual(len(self.env.cr.fetchall()), 1)
34 changes: 34 additions & 0 deletions openupgrade_scripts/scripts/crm/19.0.1.9/upgrade_analysis_work.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---Models in module 'crm'---

# NOTHING TO DO

---Fields in module 'crm'---
crm / crm.lead / commercial_partner_id (many2one): NEW relation: res.partner, hasdefault: compute, stored: False
crm / crm.lead / mobile (char) : DEL
crm / crm.lead / title (many2one) : DEL relation: res.partner.title
crm / crm.lead / won_status (selection) : NEW selection_keys: ['lost', 'pending', 'won'], isfunction: function, stored
crm / crm.lead.scoring.frequency.field / color (integer) : NEW hasdefault: default
crm / crm.stage / color (integer) : NEW
crm / crm.stage / rotting_threshold_days (integer): NEW hasdefault: default

# NOTHING TO DO

crm / crm.stage / team_id (many2one) : DEL relation: crm.team
crm / crm.stage / team_ids (many2many) : NEW relation: crm.team

# DONE: post-migration: m2o_to_x2m promotes legacy team_id -> team_ids

crm / crm.team.member / assignment_domain_preferred (char): NEW
crm / res.users / target_sales_done (integer) : DEL
crm / res.users / target_sales_won (integer) : DEL

# NOTHING TO DO

---XML records in module 'crm'---
NEW ir.actions.act_window: crm.mail_followers_edit_action_from_lead
NEW ir.model.constraint: crm.constraint_crm_lead_create_date_team_id_idx
NEW ir.model.constraint: crm.constraint_crm_lead_default_order_idx
NEW ir.model.constraint: crm.constraint_crm_lead_user_id_team_id_type_index
DEL ir.ui.view: crm.crm_lead_partner_kanban_view

# NOTHING TO DO
7 changes: 7 additions & 0 deletions openupgrade_scripts/scripts/crm/tests/data_crm_migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
env = locals().get("env")
team = env.ref("sales_team.team_sales_department", raise_if_not_found=False)
if team:
stage = env["crm.stage"].search([("team_id", "=", False)], limit=1)
if stage:
stage.team_id = team
env.cr.commit()
Loading