Skip to content

[19.0][OU-ADD] crm: stage.team_id m2o→m2m promotion#5643

Open
dnplkndll wants to merge 1 commit into
OCA:19.0from
ledoent:19.0-mig-crm-stage-teams
Open

[19.0][OU-ADD] crm: stage.team_id m2o→m2m promotion#5643
dnplkndll wants to merge 1 commit into
OCA:19.0from
ledoent:19.0-mig-crm-stage-teams

Conversation

@dnplkndll
Copy link
Copy Markdown

@dnplkndll dnplkndll commented May 18, 2026

19.0 promotes crm.stage.team_id (m2o to crm.team) to team_ids (m2m). Without explicit migration the per-stage team assignment is lost (rendered as DEL old + NEW empty in the analysis). Since the new field has a different name, OpenUpgrade preserves the old column automatically — no pre-migration rename needed.

  • post-migration.pyopenupgrade.m2o_to_x2m() reads the preserved team_id column and populates crm_stage_crm_team_rel.
  • No pre-migration (helper handles the full m2o → m2m promotion).

Test: asserts at least one stage has team_ids populated post-migration.

DEL fields on crm.lead (mobile, title) and res.users (target_sales_done, target_sales_won) left to database_cleanup per maintainer policy.

@OCA-git-bot OCA-git-bot added mod:openupgrade_scripts Module openupgrade_scripts series:19.0 labels May 18, 2026
@dnplkndll dnplkndll force-pushed the 19.0-mig-crm-stage-teams branch from 72f6b98 to 66cc730 Compare May 19, 2026 01:16
@dnplkndll dnplkndll marked this pull request as ready for review May 19, 2026 01:16
@pedrobaeza pedrobaeza changed the title [19.0][MIG] crm: m2o->m2m promotion on crm.stage.team_id [19.0][OU-ADD] crm: Migration scripts May 19, 2026
@pedrobaeza
Copy link
Copy Markdown
Member

/ocabot migration crm

@dnplkndll Please avoid:

  • Several commits for the same task.
  • The commit message shouldn't include the version [19.0], and this is not [MIG], but adding a migration script. I use [OU-ADD] for that (on contrast by [OU-FIX] and [OU-IMP] for submitting patches or improvements over existing scripts) .

@OCA-git-bot OCA-git-bot added this to the 19.0 milestone May 19, 2026
@OCA-git-bot OCA-git-bot mentioned this pull request May 19, 2026
50 tasks
@dnplkndll dnplkndll force-pushed the 19.0-mig-crm-stage-teams branch from 66cc730 to bc17267 Compare May 19, 2026 13:28
Copy link
Copy Markdown
Contributor

@remi-filament remi-filament left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dnplkndll for your PR

crm / res.users / target_sales_done (integer) : DEL
crm / res.users / target_sales_won (integer) : DEL

# DONE: crm.stage.team_id (m2o) -> team_ids (m2m) promotion handled by
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should be just after concerned lines, marking the other ones as NOTHING TO DO

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restructured in bea32d3 — per-group markers in the work doc. # DONE only next to the m2o→m2m promotion lines (event.question.event_id / event_type_id); other lines under # NOTHING TO DO.

def migrate(env, version):
"""Populate crm.stage.team_ids m2m from legacy team_id (m2o -> m2m promotion)."""
legacy = openupgrade.get_legacy_name("team_id")
openupgrade.logged_query(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have an helper method on openupgradelib doing the same m2o_to_x2m()

I do not think that you need to rename the field beforehand anyhow since they do not have the same name it should be preserved by OpenUpgrade

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in bea32d3 — pre-migration removed entirely. Post-migration now uses openupgrade.m2o_to_x2m(env.cr, env['crm.stage'], 'crm_stage', 'team_ids', 'team_id') against the auto-preserved team_id column. Single 5-line function.

@dnplkndll dnplkndll changed the title [19.0][OU-ADD] crm: Migration scripts [19.0][OU-ADD] crm: stage.team_id m2o→m2m promotion May 20, 2026
Promote crm.stage.team_id (m2o crm.team) to team_ids (m2m).
pre-migration preserves the legacy FK column via rename_columns;
post-migration inserts rows into crm_stage_crm_team_rel from it.
Legacy column left for database_cleanup.
@dnplkndll dnplkndll force-pushed the 19.0-mig-crm-stage-teams branch from bc17267 to bea32d3 Compare May 20, 2026 23:28
@dnplkndll
Copy link
Copy Markdown
Author

@remi-filament — addressed both threads in bea32d3:

  • Pre-migration removed entirely (column rename was unnecessary since new field name differs).
  • Post-migration now uses openupgrade.m2o_to_x2m() helper — single call replaces the manual INSERT.
  • Work-doc terseness applied throughout.

Title also tightened (crm: stage.team_id m2o→m2m promotion vs the prior vague Migration scripts). Fork CI green on both seeds. Ready for re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:openupgrade_scripts Module openupgrade_scripts series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants