Skip to content

[19.0][OU-ADD] event: slots + question m2m promotion#5637

Open
dnplkndll wants to merge 1 commit into
OCA:19.0from
ledoent:19.0-mig-event-slots-questions
Open

[19.0][OU-ADD] event: slots + question m2m promotion#5637
dnplkndll wants to merge 1 commit into
OCA:19.0from
ledoent:19.0-mig-event-slots-questions

Conversation

@dnplkndll
Copy link
Copy Markdown

@dnplkndll dnplkndll commented May 15, 2026

19.0 reshapes event.question: event_id (m2o) → event_ids (m2m), event_type_id (m2o) → event_type_ids (m2m). Reverse sides on event.event and event.type also flip to m2m, sharing new join tables event_event_event_question_rel and event_question_event_type_rel. Since new field names differ from old, OpenUpgrade preserves the old columns automatically — no pre-migration rename needed.

  • pre-migration.py — direct SQL DELETE of the (noupdate) event_stage_cancelled record removed in 19.0.
  • post-migration.pyopenupgrade.m2o_to_x2m() ×2 (one per renamed field). Helper reads the preserved old m2o column and populates the new m2m relation table.

Two pure-addition models (event.slot, event.mail.slot) are created by ORM at init. Selection-key shrink on event.event.badge_format and DEL event.stage legend_* fields left to database_cleanup per maintainer policy.

Sibling: #5636 (6 simple event_* submodules).

@OCA-git-bot OCA-git-bot added mod:openupgrade_scripts Module openupgrade_scripts series:19.0 labels May 15, 2026
@dnplkndll dnplkndll force-pushed the 19.0-mig-event-slots-questions branch 2 times, most recently from 7ab2ce2 to 753bcc9 Compare May 19, 2026 01:16
@dnplkndll dnplkndll marked this pull request as ready for review May 19, 2026 01:16
@dnplkndll dnplkndll force-pushed the 19.0-mig-event-slots-questions branch from 753bcc9 to 496a78a Compare May 19, 2026 13:52
@dnplkndll dnplkndll changed the title [19.0][MIG] event: slots + question m2m promotion [19.0][OU-ADD] event: slots + question m2m promotion May 19, 2026
@dnplkndll dnplkndll force-pushed the 19.0-mig-event-slots-questions branch from 496a78a to 0034427 Compare May 19, 2026 14:13
NEW event.question: event.event_question_email (noupdate)
NEW event.question: event.event_question_name (noupdate)
NEW event.question: event.event_question_phone (noupdate)
DEL event.stage: event.event_stage_cancelled (noupdate)
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 need to manually delete this noupdate stage (or explain why you prefer to keep it (and if this is the case you probably need to remove the XML-id from that stage))

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 22c419b — pre-migration deletes the noupdate event_stage_cancelled record via direct SQL.

Comment on lines +58 to +64
# DONE: event.question.event_id / event_type_id m2o->m2m promotion handled by
# pre-migration rename_columns (preserve as legacy) + post-migration INSERTs
# into event_event_event_question_rel and event_question_event_type_rel.
# Reverse o2m->m2m on event.event.question_ids (and siblings) and
# event.type.question_ids reads from the same m2m tables — no extra work.
# All NEW fields are additive (defaults / compute). Selection key changes
# additive or shrink — pedrobaeza: leave residuals to database_cleanup.
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 need to put comments only related to specific lines that need upgrade script, the other ones should be marked 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 22c419b — per-group markers throughout the work doc. # DONE only next to the m2o→m2m promotion lines (event.question.event_id / event_type_id and their reverse sides). All other lines under # NOTHING TO DO.

Comment on lines +3 to +13
_renamed_columns = {
"event_question": [
("event_id", None),
("event_type_id", None),
],
}


@openupgrade.migrate()
def migrate(env, version):
openupgrade.rename_columns(env.cr, _renamed_columns)
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.

This should not be needed since OpenUpgrade will keep the old columns (since new fields do not have the same name)

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.

You're right — dropped the column rename in 22c419b. Since new field names differ (event_ids vs event_id, event_type_ids vs event_type_id), OpenUpgrade preserves the old columns automatically. Post-migration now uses openupgrade.m2o_to_x2m() ×2 — one per promotion.

@dnplkndll
Copy link
Copy Markdown
Author

@remi-filament — addressed all three threads in 22c419b:

  • Dropped pre-migration column rename. Post-migration now uses openupgrade.m2o_to_x2m() ×2 against the auto-preserved columns.
  • Pre-migration adds direct-SQL deletion of the noupdate event_stage_cancelled record.
  • Work-doc terseness applied throughout — per-group markers, no multi-line authorial blocks.

Fork CI green on both seeds. Body refreshed to match v2 shape. Ready for re-review.

@dnplkndll dnplkndll force-pushed the 19.0-mig-event-slots-questions branch from 22c419b to 42b539a Compare May 21, 2026 12:11
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.

3 participants