From 4e8878b996822f52aa55cdb491d990961389e4c0 Mon Sep 17 00:00:00 2001 From: mreficent Date: Wed, 1 Apr 2020 16:54:25 +0200 Subject: [PATCH 1/2] [MIG] calendar --- .../migrations/13.0.1.0/noupdate_changes.xml | 14 +++++++------- .../13.0.1.0/openupgrade_analysis_work.txt | 16 ++++++++++++++++ .../migrations/13.0.1.0/post-migration.py | 10 ++++++++++ .../migrations/13.0.1.0/pre-migration.py | 13 +++++++++++++ odoo/openupgrade/doc/source/modules120-130.rst | 2 +- 5 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 addons/calendar/migrations/13.0.1.0/openupgrade_analysis_work.txt create mode 100644 addons/calendar/migrations/13.0.1.0/post-migration.py create mode 100644 addons/calendar/migrations/13.0.1.0/pre-migration.py diff --git a/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml b/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml index cff73376dbfe..e0bc7c1bbaff 100644 --- a/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml +++ b/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml @@ -2,37 +2,37 @@ Email - 3 Hours - + email Email - 6 Hours - + email Notification - 15 Minutes - + notification Notification - 30 Minutes - + notification Notification - 1 Hours - + notification Notification - 2 Hours - + notification Notification - 1 Days - + notification diff --git a/addons/calendar/migrations/13.0.1.0/openupgrade_analysis_work.txt b/addons/calendar/migrations/13.0.1.0/openupgrade_analysis_work.txt new file mode 100644 index 000000000000..6a05d6f88ad1 --- /dev/null +++ b/addons/calendar/migrations/13.0.1.0/openupgrade_analysis_work.txt @@ -0,0 +1,16 @@ +---Models in module 'calendar'--- +---Fields in module 'calendar'--- +calendar / calendar.alarm / alarm_type (selection) : NEW required, selection_keys: ['email', 'notification'], req_default: function, hasdefault +calendar / calendar.alarm / type (selection) : DEL required, selection_keys: ['email', 'notification'], req_default: function +# DONE: pre-migration: renamed fields + +calendar / calendar.event / event_tz (selection) : NEW selection_keys: function, hasdefault +# NOTHING TO DO: New field that has default, will be automatically filled + +calendar / mail.activity.type / category (False) : selection_keys is now '['default', 'meeting', 'upload_file']' ('['default', 'meeting']') +# NOTHING TO DO: new features + +---XML records in module 'calendar'--- +DEL ir.ui.view: calendar.mail_activity_type_view_form +DEL ir.ui.view: calendar.view_calendar_event_form_popup +# NOTHING TO DO diff --git a/addons/calendar/migrations/13.0.1.0/post-migration.py b/addons/calendar/migrations/13.0.1.0/post-migration.py new file mode 100644 index 000000000000..7f97fc084bee --- /dev/null +++ b/addons/calendar/migrations/13.0.1.0/post-migration.py @@ -0,0 +1,10 @@ +# Copyright 2020 ForgeFlow +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.load_data( + env.cr, 'calendar', 'migrations/13.0.1.0/noupdate_changes.xml') diff --git a/addons/calendar/migrations/13.0.1.0/pre-migration.py b/addons/calendar/migrations/13.0.1.0/pre-migration.py new file mode 100644 index 000000000000..628c3aced7fb --- /dev/null +++ b/addons/calendar/migrations/13.0.1.0/pre-migration.py @@ -0,0 +1,13 @@ +# Copyright 2020 ForgeFlow +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + +_field_renames = [ + ('calendar.alarm ', 'calendar_alarm ', 'type', 'alarm_type'), +] + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_fields(env, _field_renames) diff --git a/odoo/openupgrade/doc/source/modules120-130.rst b/odoo/openupgrade/doc/source/modules120-130.rst index 0db6d3e43d47..72fc87c9c0fe 100644 --- a/odoo/openupgrade/doc/source/modules120-130.rst +++ b/odoo/openupgrade/doc/source/modules120-130.rst @@ -97,7 +97,7 @@ missing in the new release are marked with |del|. +----------------------------------------------+-------------------------------------------------+ |bus | Nothing to do | +----------------------------------------------+-------------------------------------------------+ -|calendar | | +|calendar | Done | +----------------------------------------------+-------------------------------------------------+ |calendar_sms | | +----------------------------------------------+-------------------------------------------------+ From 3110d99975e01598b5316cdfa1d8a0e028d956e5 Mon Sep 17 00:00:00 2001 From: "Pedro M. Baeza" Date: Sat, 11 Apr 2020 13:37:19 +0200 Subject: [PATCH 2/2] [FIX] calendar: Several fixes * Don't overwrite renamed field `alarm_type` in noupdate changes. * Make sure `event_tz` field is empty for preserving previous behavior. --- .../migrations/13.0.1.0/noupdate_changes.xml | 28 +++++++++---------- .../migrations/13.0.1.0/post-migration.py | 10 +++++++ 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml b/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml index e0bc7c1bbaff..cb32f0ad59b2 100644 --- a/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml +++ b/addons/calendar/migrations/13.0.1.0/noupdate_changes.xml @@ -2,38 +2,38 @@ Email - 3 Hours - - email + Email - 6 Hours - - email + Notification - 15 Minutes - - notification + Notification - 30 Minutes - - notification + Notification - 1 Hours - - notification + Notification - 2 Hours - - notification + Notification - 1 Days - - notification + ${(object.event_id.user_id.email_formatted or user.email_formatted or '') | safe} diff --git a/addons/calendar/migrations/13.0.1.0/post-migration.py b/addons/calendar/migrations/13.0.1.0/post-migration.py index 7f97fc084bee..db6045191d86 100644 --- a/addons/calendar/migrations/13.0.1.0/post-migration.py +++ b/addons/calendar/migrations/13.0.1.0/post-migration.py @@ -1,10 +1,20 @@ # Copyright 2020 ForgeFlow +# Copyright 2020 Tecnativa - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade +def _empty_calendar_event_tz(env): + """Make sure event tz is empty for equal behavior as in v12.""" + openupgrade.logged_query( + env.cr, + "UPDATE calendar_event set event_tz = NULL WHERE event_tz IS NOT NULL", + ) + + @openupgrade.migrate() def migrate(env, version): + _empty_calendar_event_tz(env) openupgrade.load_data( env.cr, 'calendar', 'migrations/13.0.1.0/noupdate_changes.xml')