-
-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2836 from ForgeFlow/14.0-mig-event
[14.0][MIG] event
- Loading branch information
Showing
5 changed files
with
313 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
41 changes: 41 additions & 0 deletions
41
openupgrade_scripts/scripts/event/14.0.1.3/post-migration.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# Copyright 2021 Tecnativa - Pedro M. Baeza | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def map_event_event_states_to_stages(env): | ||
def _map_state_to_stage(state, stage_xmlid): | ||
query = """ | ||
UPDATE event_event event SET stage_id = imd.res_id | ||
FROM ir_model_data imd | ||
WHERE imd.module = 'event' AND imd.name = %s AND event.state = %s""" | ||
openupgrade.logged_query(env.cr, query, (stage_xmlid, state)) | ||
|
||
_map_state_to_stage("draft", "event_stage_new") | ||
_map_state_to_stage("done", "event_stage_done") | ||
_map_state_to_stage("cancel", "event_stage_cancelled") | ||
_map_state_to_stage("confirm", "event_stage_announced") | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
map_event_event_states_to_stages(env) | ||
openupgrade.load_data(env.cr, "event", "14.0.1.3/noupdate_changes.xml") | ||
openupgrade.delete_records_safely_by_xml_id( | ||
env, | ||
[ | ||
"event.event_type_data_online", | ||
"event.event_type_data_physical", | ||
"event.event_registration_portal", | ||
], | ||
) | ||
openupgrade.delete_record_translations( | ||
env.cr, | ||
"event", | ||
[ | ||
"event_registration_mail_template_badge", | ||
"event_reminder", | ||
"event_subscription", | ||
], | ||
) |
76 changes: 76 additions & 0 deletions
76
openupgrade_scripts/scripts/event/14.0.1.3/pre-migration.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). | ||
from openupgradelib import openupgrade | ||
|
||
_field_renames = [("event.type", "event_type", "default_registration_max", "seats_max")] | ||
|
||
_field_renames_event_sale = [ | ||
("event.type", "event_type", "use_ticketing", "use_ticket"), | ||
("event.event.ticket", "event_event_ticket", "deadline", "end_sale_date"), | ||
("event.registration", "event_registration", "campaign_id", "utm_campaign_id"), | ||
("event.registration", "event_registration", "medium_id", "utm_medium_id"), | ||
("event.registration", "event_registration", "source_id", "utm_source_id"), | ||
] | ||
|
||
_xmlid_renames_event_sale = [ | ||
( | ||
"event_sale.access_event_event_ticket_user", | ||
"event.access_event_event_ticket_user", | ||
), | ||
( | ||
"event_sale.access_event_event_ticket_admin", | ||
"event.access_event_event_ticket_manager", | ||
), | ||
] | ||
|
||
|
||
def rename_event_event_seats(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE event_event | ||
ADD COLUMN seats_limited boolean""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE event_event | ||
SET seats_limited = CASE | ||
WHEN seats_availability = 'limited' THEN TRUE ELSE FALSE END""", | ||
) | ||
|
||
|
||
def fast_fill_kanban_state(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE event_event | ||
ADD COLUMN kanban_state varchar""", | ||
) | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
UPDATE event_event | ||
SET kanban_state = CASE | ||
WHEN state = 'done' THEN 'done' ELSE 'normal' END""", | ||
) | ||
|
||
|
||
def avoid_default_in_event_event_stage_id(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
ALTER TABLE event_event | ||
ADD COLUMN stage_id integer""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
openupgrade.rename_fields(env, _field_renames) | ||
if openupgrade.table_exists(env.cr, "event_event_ticket"): | ||
openupgrade.rename_fields(env, _field_renames_event_sale) | ||
openupgrade.rename_xmlids(env.cr, _xmlid_renames_event_sale) | ||
rename_event_event_seats(env) | ||
fast_fill_kanban_state(env) | ||
avoid_default_in_event_event_stage_id(env) |
193 changes: 193 additions & 0 deletions
193
openupgrade_scripts/scripts/event/14.0.1.3/upgrade_analysis_work.txt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
---Models in module 'event'--- | ||
obsolete model event.confirm [transient] | ||
model event.event.ticket (moved from event_sale) | ||
new model event.stage | ||
new model event.tag | ||
new model event.tag.category | ||
new model event.type.ticket | ||
# NOTHING TO DO | ||
|
||
---Fields in module 'event'--- | ||
event / event.event / auto_confirm (boolean) : now a function | ||
event / event.event / date_tz (selection) : now a function | ||
event / event.event / event_mail_ids (one2many) : now a function | ||
event / event.event / event_ticket_ids (one2many) : previously in module event_sale | ||
event / event.event / seats_max (integer) : now a function | ||
# NOTHING TO DO: Computed writable fields | ||
|
||
event / event.event / color (integer) : DEL | ||
# NOTHING TO DO: obsolete | ||
|
||
event / event.event / note (text) : NEW | ||
# NOTHING TO DO: new feature | ||
|
||
event / event.event / seats_availability (selection): DEL required, selection_keys: ['limited', 'unlimited'], req_default: function | ||
event / event.event / seats_limited (boolean) : NEW required, isfunction: function, stored | ||
# DONE: pre-migration: fast creation and filled boolean from char | ||
|
||
event / event.event / tag_ids (many2many) : NEW relation: event.tag, isfunction: function, stored | ||
# NOTHING TO DO: new feature | ||
|
||
event / event.event / kanban_state (selection) : NEW selection_keys: ['blocked', 'done', 'normal'], hasdefault | ||
event / event.event / kanban_state_label (char) : NEW isfunction: function, stored | ||
# DONE: pre-migration: fast filled | ||
|
||
event / event.event / stage_id (many2one) : NEW relation: event.stage, hasdefault | ||
event / event.event / state (selection) : DEL required, selection_keys: ['cancel', 'confirm', 'done', 'draft'], req_default: function | ||
# DONE: post-migration: map stages for each state | ||
|
||
event / event.event / is_online (boolean) : DEL | ||
event / event.type / is_online (boolean) : DEL | ||
# NOTHING TO DO: obsolete feature | ||
|
||
event / event.event / seats_min (integer) : DEL | ||
event / event.type / default_registration_min (integer): DEL | ||
# NOTHING TO DO: obsolete feature | ||
|
||
event / event.event / twitter_hashtag (char) : DEL | ||
event / event.type / default_hashtag (char) : DEL | ||
event / event.type / use_hashtag (boolean) : DEL | ||
# NOTHING TO DO: obsolete feature | ||
|
||
event / event.type / event_type_mail_ids (one2many): now a function | ||
event / event.type / event_type_ticket_ids (one2many): NEW relation: event.type.ticket, isfunction: function, stored | ||
event / event.type / tag_ids (many2many) : NEW relation: event.tag | ||
# NOTHING TO DO | ||
|
||
event / event.type / default_registration_max (integer): DEL | ||
event / event.type / seats_max (integer) : NEW isfunction: function, stored | ||
# DONE: pre-migration: renamed field | ||
|
||
event / event.type / use_ticket (boolean) : NEW | ||
# DONE: pre-migration: renamed from use_ticketing (of event_sale) | ||
|
||
event / event.event.ticket / __last_update (datetime) : previously in module event_sale | ||
event / event.event.ticket / _order : previously in module event_sale | ||
event / event.event.ticket / company_id (many2one) : previously in module event_sale | ||
event / event.event.ticket / display_name (char) : previously in module event_sale | ||
event / event.event.ticket / event_id (many2one) : previously in module event_sale | ||
event / event.event.ticket / event_type_id (many2one) : previously in module event_sale | ||
event / event.event.ticket / is_expired (boolean) : previously in module event_sale | ||
event / event.event.ticket / name (char) : previously in module event_sale | ||
event / event.event.ticket / registration_ids (one2many) : previously in module event_sale | ||
event / event.event.ticket / seats_available (integer) : previously in module event_sale | ||
event / event.event.ticket / seats_max (integer) : previously in module event_sale | ||
event / event.event.ticket / seats_reserved (integer) : previously in module event_sale | ||
event / event.event.ticket / seats_unconfirmed (integer) : previously in module event_sale | ||
event / event.event.ticket / seats_used (integer) : previously in module event_sale | ||
event / event.registration / event_ticket_id (many2one) : previously in module event_sale | ||
# NOTHING TO DO: Handled by ORM when event_sale was installed | ||
|
||
event / event.event.ticket / end_sale_date (date) : NEW | ||
# DONE: pre-migration: renamed from deadline (of event_sale) | ||
|
||
event / event.event.ticket / description (text) : NEW | ||
event / event.event.ticket / seats_limited (boolean) : NEW isfunction: function, stored | ||
event / event.event.ticket / start_sale_date (date) : NEW | ||
# NOTHING TO DO: new features | ||
|
||
event / event.registration / _order : _order is now 'id desc' ('name, create_date desc') | ||
event / event.registration / date_closed (datetime) : now a function | ||
event / event.registration / email (char) : now a function | ||
event / event.registration / mobile (char) : now a function | ||
event / event.registration / name (char) : now a function | ||
event / event.registration / phone (char) : now a function | ||
# NOTHING TO DO: Computed writable fields | ||
|
||
event / event.registration / origin (char) : DEL | ||
# NOTHING TO DO: obsolete feature | ||
|
||
event / event.registration / utm_campaign_id (many2one) : NEW relation: utm.campaign | ||
event / event.registration / utm_medium_id (many2one) : NEW relation: utm.medium | ||
event / event.registration / utm_source_id (many2one) : NEW relation: utm.source | ||
# DONE: pre-migration: renamed fields from campaign_id, medium_id and source_id (of event_sale) | ||
|
||
event / event.stage / description (text) : NEW | ||
event / event.stage / fold (boolean) : NEW hasdefault | ||
event / event.stage / legend_blocked (char) : NEW required, req_default: function, hasdefault | ||
event / event.stage / legend_done (char) : NEW required, req_default: function, hasdefault | ||
event / event.stage / legend_normal (char) : NEW required, req_default: function, hasdefault | ||
event / event.stage / name (char) : NEW required | ||
event / event.stage / pipe_end (boolean) : NEW hasdefault | ||
event / event.stage / sequence (integer) : NEW hasdefault | ||
event / event.tag / category_id (many2one) : NEW relation: event.tag.category, required | ||
event / event.tag / color (integer) : NEW hasdefault | ||
event / event.tag / name (char) : NEW required | ||
event / event.tag / sequence (integer) : NEW hasdefault | ||
event / event.tag.category / name (char) : NEW required | ||
event / event.tag.category / sequence (integer) : NEW hasdefault | ||
event / event.tag.category / tag_ids (one2many) : NEW relation: event.tag | ||
event / event.type.ticket / description (text) : NEW | ||
event / event.type.ticket / event_type_id (many2one) : NEW relation: event.type, required | ||
event / event.type.ticket / name (char) : NEW required, req_default: function, hasdefault | ||
event / event.type.ticket / seats_limited (boolean) : NEW isfunction: function, stored | ||
event / event.type.ticket / seats_max (integer) : NEW | ||
# NOTHING TO DO: new models | ||
|
||
---XML records in module 'event'--- | ||
NEW event.stage: event.event_stage_announced (noupdate) | ||
NEW event.stage: event.event_stage_booked (noupdate) | ||
NEW event.stage: event.event_stage_cancelled (noupdate) | ||
NEW event.stage: event.event_stage_done (noupdate) | ||
NEW event.stage: event.event_stage_new (noupdate) | ||
# NOTHING TO DO | ||
|
||
NEW event.type: event.event_type_data_conference (noupdate) | ||
NEW event.type: event.event_type_data_ticket (noupdate) | ||
# NOTHING TO DO | ||
|
||
DEL event.type: event.event_type_data_online (noupdate) | ||
DEL event.type: event.event_type_data_physical (noupdate) | ||
# DONE: post-migration: safely deleted | ||
|
||
NEW ir.actions.act_window: event.event_registration_action | ||
NEW ir.actions.act_window: event.event_registration_action_tree | ||
NEW ir.actions.act_window: event.event_stage_action | ||
NEW ir.actions.act_window: event.event_tag_category_action_tree | ||
DEL ir.actions.act_window: event.action_event_confirm | ||
NEW ir.model.access: event.access_event_category | ||
NEW ir.model.access: event.access_event_category_manager | ||
NEW ir.model.access: event.access_event_registration_all | ||
NEW ir.model.access: event.access_event_stage_manager | ||
NEW ir.model.access: event.access_event_stage_user | ||
NEW ir.model.access: event.access_event_tag | ||
NEW ir.model.access: event.access_event_tag_manager | ||
NEW ir.model.access: event.access_event_type_ticket | ||
NEW ir.model.access: event.access_event_type_ticket_manager | ||
DEL ir.model.access: event.access_event_registration_employee | ||
DEL ir.model.access: event.access_event_registration_portal | ||
# NOTHING TO DO | ||
|
||
NEW ir.model.access: event.access_event_event_ticket_manager | ||
NEW ir.model.access: event.access_event_event_ticket_user [renamed from event_sale module] | ||
# DONE: pre-migration: renamed xmlids from event_sale | ||
|
||
NEW ir.rule: event.ir_rule_event_event_ticket_company (noupdate) | ||
# NOTHING TO DO | ||
|
||
DEL ir.rule: event.event_registration_portal (noupdate) | ||
# DONE: post-migration: safely deleted | ||
|
||
NEW ir.ui.menu: event.event_stage_menu | ||
NEW ir.ui.menu: event.menu_event_category | ||
NEW ir.ui.view: event.assets_common | ||
NEW ir.ui.view: event.event_default_descripton | ||
NEW ir.ui.view: event.event_event_ticket_form_view | ||
NEW ir.ui.view: event.event_event_ticket_view_form_from_event | ||
NEW ir.ui.view: event.event_event_ticket_view_kanban_from_event | ||
NEW ir.ui.view: event.event_event_ticket_view_tree | ||
NEW ir.ui.view: event.event_event_ticket_view_tree_from_event | ||
NEW ir.ui.view: event.event_event_view_form_quick_create | ||
NEW ir.ui.view: event.event_event_view_graph | ||
NEW ir.ui.view: event.event_stage_view_form | ||
NEW ir.ui.view: event.event_stage_view_tree | ||
NEW ir.ui.view: event.event_tag_category_view_form | ||
NEW ir.ui.view: event.event_tag_category_view_tree | ||
NEW ir.ui.view: event.event_tag_view_form | ||
NEW ir.ui.view: event.event_tag_view_tree | ||
NEW ir.ui.view: event.event_type_ticket_view_form | ||
NEW ir.ui.view: event.event_type_ticket_view_form_from_type | ||
NEW ir.ui.view: event.event_type_ticket_view_tree | ||
NEW ir.ui.view: event.event_type_ticket_view_tree_from_type | ||
DEL ir.ui.view: event.view_event_confirm | ||
# NOTHING TO DO |