diff --git a/docsource/modules140-150.rst b/docsource/modules140-150.rst index 7f556ce9d385..0a82996ee6f4 100644 --- a/docsource/modules140-150.rst +++ b/docsource/modules140-150.rst @@ -160,7 +160,7 @@ Module coverage 14.0 -> 15.0 +-------------------------------------------------+----------------------+-------------------------------------------------+ | google_account |Nothing to do |No DB layout changes. | +-------------------------------------------------+----------------------+-------------------------------------------------+ -| google_calendar | | | +| google_calendar | Done | | +-------------------------------------------------+----------------------+-------------------------------------------------+ | google_drive | | | +-------------------------------------------------+----------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/google_calendar/15.0.1.0/post-migration.py b/openupgrade_scripts/scripts/google_calendar/15.0.1.0/post-migration.py new file mode 100644 index 000000000000..2294652db288 --- /dev/null +++ b/openupgrade_scripts/scripts/google_calendar/15.0.1.0/post-migration.py @@ -0,0 +1,34 @@ +from openupgradelib import openupgrade + + +def _move_credentials_from_res_users_to_google_calendar_credentials(env): + openupgrade.logged_query( + env.cr, + """ + WITH google_calendar_credentials_tmp AS ( + INSERT INTO google_calendar_credentials AS cc ( + calendar_rtoken, calendar_token, calendar_token_validity, + calendar_sync_token, calendar_cal_id, synchronization_stopped, + create_uid, create_date, write_uid, write_date) + SELECT u.google_calendar_rtoken, u.google_calendar_token, + u.google_calendar_token_validity, u.google_calendar_sync_token, + u.google_calendar_cal_id, FALSE, max(u.write_uid), max(u.write_date), + max(u.write_uid), max(u.write_date) + FROM res_users u + WHERE u.google_calendar_token IS NOT NULL + GROUP BY u.google_calendar_rtoken, u.google_calendar_token, + u.google_calendar_token_validity, u.google_calendar_sync_token, + u.google_calendar_cal_id + RETURNING cc.id, cc.calendar_token + ) + UPDATE res_users u + SET google_cal_account_id = tmp.id + FROM google_calendar_credentials_tmp as tmp + WHERE tmp.calendar_token = u.google_calendar_token + """, + ) + + +@openupgrade.migrate() +def migrate(env, version): + _move_credentials_from_res_users_to_google_calendar_credentials(env) diff --git a/openupgrade_scripts/scripts/google_calendar/15.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/google_calendar/15.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..b53514241d1f --- /dev/null +++ b/openupgrade_scripts/scripts/google_calendar/15.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,32 @@ +---Models in module 'google_calendar'--- +new model google.calendar.credentials +---Fields in module 'google_calendar'--- +google_calendar / google.calendar.credentials / calendar_cal_id (char) : NEW +google_calendar / google.calendar.credentials / calendar_rtoken (char) : NEW +google_calendar / google.calendar.credentials / calendar_sync_token (char) : NEW +google_calendar / google.calendar.credentials / calendar_token (char) : NEW +google_calendar / google.calendar.credentials / calendar_token_validity (datetime): NEW +google_calendar / google.calendar.credentials / synchronization_stopped (boolean): NEW +google_calendar / google.calendar.credentials / user_ids (one2many) : NEW relation: res.users, required +google_calendar / res.users / google_cal_account_id (many2one): NEW relation: google.calendar.credentials +# NOTHING TO DO: new feature + +google_calendar / res.users / google_calendar_cal_id (char) : not stored anymore +google_calendar / res.users / google_calendar_cal_id (char) : now related +google_calendar / res.users / google_calendar_rtoken (char) : not stored anymore +google_calendar / res.users / google_calendar_rtoken (char) : now related +google_calendar / res.users / google_calendar_sync_token (char): not stored anymore +google_calendar / res.users / google_calendar_sync_token (char): now related +google_calendar / res.users / google_calendar_token (char) : not stored anymore +google_calendar / res.users / google_calendar_token (char) : now related +google_calendar / res.users / google_calendar_token_validity (datetime): not stored anymore +google_calendar / res.users / google_calendar_token_validity (datetime): now related +# DONE: move credentials from res_user table to google_calendar_credentials table + +---XML records in module 'google_calendar'--- +NEW ir.model.access: google_calendar.access_google_calendar_credentials +NEW ir.model.access: google_calendar.google_calendar_manager +DEL ir.ui.view: google_calendar.assets_backend +DEL ir.ui.view: google_calendar.qunit_mobile_suite +DEL ir.ui.view: google_calendar.qunit_suite +# NOTHING TO DO: noupdate="0" records