From 05fbc7a0d7918d73b17c0f0f8f811dd64e9d02ce Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Mon, 7 Jun 2021 09:14:02 +0200 Subject: [PATCH] [FIX] calendar: Fix recurrence population + others - 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. --- .../calendar/14.0.1.0/post-migration.py | 26 ++++++++++++++++--- .../calendar/14.0.1.0/pre-migration.py | 4 +-- 2 files changed, 24 insertions(+), 6 deletions(-) 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 0b95e3c14e08..d43a35f1f0a5 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 @@ -1,4 +1,5 @@ # Copyright 2021 ForgeFlow S.L. +# Copyright 2021 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade @@ -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 @@ -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", + ], + ) diff --git a/openupgrade_scripts/scripts/calendar/14.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/calendar/14.0.1.0/pre-migration.py index 7f6264cda2c0..37b9a6dff3ed 100644 --- a/openupgrade_scripts/scripts/calendar/14.0.1.0/pre-migration.py +++ b/openupgrade_scripts/scripts/calendar/14.0.1.0/pre-migration.py @@ -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, """ @@ -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)]})