Skip to content

Commit

Permalink
[OU-IMP] calendar: fill calendar_recurrence table
Browse files Browse the repository at this point in the history
  • Loading branch information
MiquelRForgeFlow authored and pedrobaeza committed Jun 6, 2021
1 parent 4efd10e commit 1bedaa2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
36 changes: 36 additions & 0 deletions openupgrade_scripts/scripts/calendar/14.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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']')
Expand Down

0 comments on commit 1bedaa2

Please sign in to comment.