diff --git a/openupgrade_scripts/scripts/calendar/14.0.1.0/post-migration.py b/openupgrade_scripts/scripts/calendar/14.0.1.0/post-migration.py index e456799280b3..0b95e3c14e08 100644 --- a/openupgrade_scripts/scripts/calendar/14.0.1.0/post-migration.py +++ b/openupgrade_scripts/scripts/calendar/14.0.1.0/post-migration.py @@ -24,8 +24,44 @@ def map_calendar_event_byday(env): ) +def fill_calendar_recurrence_table(env): + openupgrade.logged_query( + env.cr, + """ + WITH recur AS ( + INSERT INTO calendar_recurrence (base_event_id, + event_tz,rrule,rrule_type,end_type,interval,count, + mo,tu,we,th,fr,sa,su,month_by,day,weekday,byday,until, + create_uid,create_date,write_uid,write_date) + SELECT id,event_tz,rrule,rrule_type,end_type,interval,count, + mo,tu,we,th,fr,sa,su,month_by,day,week_list,byday,final_date, + create_uid,create_date,write_uid,write_date) + FROM calendar_event + WHERE recurrency AND recurrence_id IS NULL + AND (recurrent_id IS NULL OR recurrent_id = '') + RETURNING id,base_event_id + ) + UPDATE calendar_event ce + SET recurrence_id = recur.id + FROM recur + WHERE recur.base_event_id = ce.id + """, + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE calendar_event ce + SET recurrence_id = ce2.recurrence_id + FROM calendar_event ce2 + WHERE ce.recurrency AND ce.recurrence_id IS NULL + AND ce.recurrent_id = ce2.id || '' + """, + ) + + @openupgrade.migrate() def migrate(env, version): update_follow_recurrence_field(env) map_calendar_event_byday(env) + fill_calendar_recurrence_table(env) openupgrade.load_data(env.cr, "calendar", "14.0.1.0/noupdate_changes.xml") diff --git a/openupgrade_scripts/scripts/calendar/14.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/calendar/14.0.1.0/upgrade_analysis_work.txt index 566c3e7253f9..13a1aa308877 100644 --- a/openupgrade_scripts/scripts/calendar/14.0.1.0/upgrade_analysis_work.txt +++ b/openupgrade_scripts/scripts/calendar/14.0.1.0/upgrade_analysis_work.txt @@ -68,11 +68,16 @@ calendar / calendar.recurrence / su (boolean) : NEW calendar / calendar.recurrence / th (boolean) : NEW calendar / calendar.recurrence / tu (boolean) : NEW calendar / calendar.recurrence / until (date) : NEW +calendar / calendar.event / final_date (date) : DEL calendar / calendar.recurrence / we (boolean) : NEW calendar / calendar.recurrence / weekday (selection) : NEW selection_keys: ['FR', 'MO', 'SA', 'SU', 'TH', 'TU', 'WE'] +calendar / calendar.event / week_list (selection) : DEL selection_keys: ['FR', 'MO', 'SA', 'SU', 'TH', 'TU', 'WE'] calendar / calendar.event / recurrence_id (many2one) : NEW relation: calendar.recurrence calendar / calendar.recurrence / base_event_id (many2one) : NEW relation: calendar.event -# TO DO: Move this fields from event to recurrence and set relation from event to recurrence (recurrence_id) +# DONE: Moved these fields from event to recurrence and set relation from event to recurrence (recurrence_id) + +calendar / calendar.event / recurrent_id (integer) : DEL +# DONE: post-migration: used recurrent_id to map to others recurrences calendar / calendar.event / follow_recurrence (boolean) : NEW hasdefault # DONE: post-migration: Set true all recurrent events (default=False) @@ -82,13 +87,10 @@ calendar / calendar.event / show_as (selection) : now re # DONE: pre-migration: Checking fields not empty and filling them with default ('public' and 'busy') if they are, in fact, empty calendar / calendar.event / display_start (char) : DEL -calendar / calendar.event / final_date (date) : DEL -calendar / calendar.event / recurrent_id (integer) : DEL calendar / calendar.event / recurrent_id_date (datetime) : DEL calendar / calendar.event / start_datetime (datetime) : DEL calendar / calendar.event / state (selection) : DEL selection_keys: ['draft', 'open'] calendar / calendar.event / stop_datetime (datetime) : DEL -calendar / calendar.event / week_list (selection) : DEL selection_keys: ['FR', 'MO', 'SA', 'SU', 'TH', 'TU', 'WE'] # NOTHING TO DO calendar / calendar.event / end_type (selection) : selection_keys is now '['count', 'end_date', 'forever']' ('['count', 'end_date']')