Skip to content

Commit

Permalink
[FIX] calendar: Fix recurrence population + others
Browse files Browse the repository at this point in the history
- recurrent_id is an integer.
- Missing recurrency = True for following recurrent events.
- Populate missing recurrent occurrences.
- Fix incorrect method name.
- Remove translations for the mail templates.
  • Loading branch information
pedrobaeza committed Jun 7, 2021
1 parent 1bedaa2 commit 05fbc7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
26 changes: 22 additions & 4 deletions openupgrade_scripts/scripts/calendar/14.0.1.0/post-migration.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# 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

Expand Down Expand Up @@ -38,7 +39,7 @@ def fill_calendar_recurrence_table(env):
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 = '')
AND (recurrent_id IS NULL OR recurrent_id = 0)
RETURNING id,base_event_id
)
UPDATE calendar_event ce
Expand All @@ -51,17 +52,34 @@ def fill_calendar_recurrence_table(env):
env.cr,
"""
UPDATE calendar_event ce
SET recurrence_id = ce2.recurrence_id
SET recurrence_id = ce2.recurrence_id, recurrency = True
FROM calendar_event ce2
WHERE ce.recurrency AND ce.recurrence_id IS NULL
AND ce.recurrent_id = ce2.id || ''
WHERE ce.recurrence_id IS NULL AND ce.recurrent_id = ce2.id
""",
)


@openupgrade.logging()
def create_recurrent_events(env):
"""In v14, now all occurrences of recurrent events are created as real records, not
virtual ones, so we need to regenerate them for all the existing ones.
"""
env["calendar.event"].search([("base_event_id", "!=", False)])._apply_recurrence()


@openupgrade.migrate()
def migrate(env, version):
update_follow_recurrence_field(env)
map_calendar_event_byday(env)
fill_calendar_recurrence_table(env)
create_recurrent_events(env)
openupgrade.load_data(env.cr, "calendar", "14.0.1.0/noupdate_changes.xml")
openupgrade.delete_record_translations(
env.cr,
"calendar",
[
"calendar_template_meeting_changedate",
"calendar_template_meeting_invitation",
"calendar_template_meeting_reminder",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from openupgradelib import openupgrade


def delete_empty_event_id_pratner_id_records(env):
def delete_empty_event_id_partner_id_records(env):
openupgrade.logged_query(
env.cr,
"""
Expand Down Expand Up @@ -34,6 +34,6 @@ def fill_empty_privacy_and_show_as_fields(env):

@openupgrade.migrate()
def migrate(env, version):
delete_empty_event_id_pratner_id_records(env)
delete_empty_event_id_partner_id_records(env)
fill_empty_privacy_and_show_as_fields(env)
openupgrade.copy_columns(env.cr, {"calendar_event": [("byday", None, None)]})

0 comments on commit 05fbc7a

Please sign in to comment.