From 0595541414e6cc5d7099a11b37c5df078f8cbd29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BB=8Bnh=20=C4=90=E1=BB=A9c=20=C4=90=E1=BB=99?= <59251518+haumenphai@users.noreply.github.com> Date: Tue, 28 May 2024 15:04:13 +0700 Subject: [PATCH] [MIG] microsoft_calendar: nothing to do (#645) * [MIG] microsoft_calendar: nothing to do * [IMP] microsoft_calendar: create new record microsoft.calendar.credentials in post-migration * Update openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/post-migration.py * Update openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/post-migration.py --------- Co-authored-by: Roy Le Co-authored-by: Roy Le <43790414+royle-viindoo@users.noreply.github.com> --- docsource/modules160-170.rst | 2 +- .../17.0.1.0/post-migration.py | 30 +++++++++++++++++++ .../17.0.1.0/upgrade_analysis_work.txt | 25 ++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules160-170.rst b/docsource/modules160-170.rst index 269964223600..9dc8ddb5c8f6 100644 --- a/docsource/modules160-170.rst +++ b/docsource/modules160-170.rst @@ -560,7 +560,7 @@ Module coverage 16.0 -> 17.0 +---------------------------------------------------+----------------------+-------------------------------------------------+ | microsoft_account |Nothing to do |No DB layout changes. | +---------------------------------------------------+----------------------+-------------------------------------------------+ -| microsoft_calendar | | | +| microsoft_calendar |Done | | +---------------------------------------------------+----------------------+-------------------------------------------------+ | microsoft_outlook |Nothing to do | | +---------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/post-migration.py b/openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/post-migration.py new file mode 100644 index 000000000000..0c94b68c0702 --- /dev/null +++ b/openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/post-migration.py @@ -0,0 +1,30 @@ +# Copyright 2024 Viindoo Technology Joint Stock Company (Viindoo) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from openupgradelib import openupgrade + + +def _fill_res_users_microsoft_calendar_account_id(env): + env.cr.execute( + """ + SELECT id, microsoft_calendar_sync_token, microsoft_synchronization_stopped + FROM res_users + WHERE microsoft_calendar_sync_token IS NOT NULL + """ + ) + vals_list = [] + for row in env.cr.fetchall(): + vals_list.append( + { + "calendar_sync_token": row[1], + "synchronization_stopped": row[2], + "user_ids": [(6, 0, [row[0]])], + } + ) + if vals_list: + env["microsoft.calendar.credentials"].create(vals_list) + + +@openupgrade.migrate() +def migrate(env, version): + _fill_res_users_microsoft_calendar_account_id(env) diff --git a/openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..b8b89cc9374f --- /dev/null +++ b/openupgrade_scripts/scripts/microsoft_calendar/17.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,25 @@ +---Models in module 'microsoft_calendar'--- +new model microsoft.calendar.credentials +# NOTHING TO DO + +---Fields in module 'microsoft_calendar'--- +microsoft_calendar / microsoft.calendar.credentials / calendar_sync_token (char) : NEW +microsoft_calendar / microsoft.calendar.credentials / last_sync_date (datetime) : NEW +microsoft_calendar / microsoft.calendar.credentials / synchronization_stopped (boolean): NEW +microsoft_calendar / microsoft.calendar.credentials / user_ids (one2many) : NEW relation: res.users, required +# NOTHING TO DO: new feature + +microsoft_calendar / res.users / microsoft_calendar_account_id (many2one): NEW relation: microsoft.calendar.credentials +microsoft_calendar / res.users / microsoft_calendar_sync_token (char): not stored anymore +microsoft_calendar / res.users / microsoft_calendar_sync_token (char): now related +microsoft_calendar / res.users / microsoft_synchronization_stopped (boolean): not stored anymore +microsoft_calendar / res.users / microsoft_synchronization_stopped (boolean): now related +# DONE: create new record microsoft.calendar.credentials in post-migration + +---XML records in module 'microsoft_calendar'--- +NEW ir.model.access: microsoft_calendar.access_microsoft_calendar_credentials +NEW ir.model.access: microsoft_calendar.microsoft_calendar_manager +NEW ir.rule: microsoft_calendar.microsoft_calendar_not_own_token_rule (noupdate) +NEW ir.rule: microsoft_calendar.microsoft_calendar_own_token_rule (noupdate) +NEW ir.rule: microsoft_calendar.microsoft_calendar_token_system_access (noupdate) +# NOTHING TO DO