[19.0][MIG] crm: m2o->m2m promotion on crm.stage.team_id#5643
Open
dnplkndll wants to merge 2 commits into
Open
[19.0][MIG] crm: m2o->m2m promotion on crm.stage.team_id#5643dnplkndll wants to merge 2 commits into
dnplkndll wants to merge 2 commits into
Conversation
19.0 promotes crm.stage.team_id (many2one to crm.team) to team_ids (many2many to crm.team). Pre-migration renames the legacy FK column via get_legacy_name so it survives ORM init; post-migration INSERTs from the legacy column into crm_stage_crm_team_rel. Test asserts at least one stage has team_ids populated, plus that the legacy column remains for database_cleanup pickup. tests/data_crm_migration.py seeds 18.0 demo stages with team_id so the migration has data to exercise on the OCA seed. Other 19.0 changes left alone per pedrobaeza policy: - DEL crm.lead.mobile, crm.lead.title (denormalized — leave) - DEL res.users.target_sales_done, target_sales_won (counters — leave) - NEW crm.lead.commercial_partner_id (compute, stored: False) - NEW crm.lead.won_status (function-stored, auto-populated) - NEW crm.stage.color, rotting_threshold_days (additive)
Self-review fixes before OCA review:
- post-migration: add ON CONFLICT DO NOTHING to the m2m INSERT.
Re-runs (idempotent retries; OpenUpgrade partial-failure recovery)
hit the (crm_stage_id, crm_team_id) PK without it. Trim docstring.
- data seed: replace raw-SQL UPDATE-from-first-team-in-table with
env.ref('sales_team.team_sales_department') + ORM assignment. The
original UPDATE silently set all stages to NULL if crm_team was
empty in the seed DB. Drops the 4-line preamble comment.
72f6b98 to
66cc730
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
19.0 promotes `crm.stage.team_id` (many2one to `crm.team`) to `team_ids` (many2many). Without an explicit migration, the per-stage team assignment is lost (rendered as DEL old + NEW empty by OpenUpgrade's analysis).
Migration
Test coverage
`openupgrade_scripts/scripts/crm/19.0.1.9/tests/test_crm_migration.py`:
`openupgrade_scripts/scripts/crm/tests/data_crm_migration.py` — 18.0 demo seed: sets `team_id` on at least one stage so the migration UPDATE has rows.
What this PR does NOT touch
Per pedrobaeza policy, these 19.0 changes in `crm` are intentionally left alone:
Fork CI
Validated on fork's `Test OpenUpgrade migration` workflow (both base + enriched seeds passed): 2026-05-16T01:58Z.
docsource
`docsource/modules180-190.rst` updated — `crm` marked Done.