Skip to content

Commit

Permalink
[MIG] microsoft_calendar: nothing to do (#645)
Browse files Browse the repository at this point in the history
* [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 <[email protected]>
Co-authored-by: Roy Le <[email protected]>
  • Loading branch information
3 people authored May 28, 2024
1 parent d92f061 commit 0595541
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docsource/modules160-170.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
+---------------------------------------------------+----------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0595541

Please sign in to comment.