From b10f030b253b1a50a5541ce8b0672e87d2cdbe41 Mon Sep 17 00:00:00 2001 From: mreficent Date: Fri, 9 Jul 2021 18:14:39 +0200 Subject: [PATCH] [MIG] gamification --- docsource/modules130-140.rst | 2 +- .../14.0.1.0/noupdate_changes.xml | 6 ++-- .../gamification/14.0.1.0/post-migration.py | 27 ++++++++++++++ .../gamification/14.0.1.0/pre-migration.py | 18 ++++++++++ .../14.0.1.0/upgrade_analysis_work.txt | 35 +++++++++++++++++++ 5 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 openupgrade_scripts/scripts/gamification/14.0.1.0/post-migration.py create mode 100644 openupgrade_scripts/scripts/gamification/14.0.1.0/pre-migration.py create mode 100644 openupgrade_scripts/scripts/gamification/14.0.1.0/upgrade_analysis_work.txt diff --git a/docsource/modules130-140.rst b/docsource/modules130-140.rst index 2ce8f697c106..e8add904e7f6 100644 --- a/docsource/modules130-140.rst +++ b/docsource/modules130-140.rst @@ -136,7 +136,7 @@ Module coverage 13.0 -> 14.0 +--------------------------------------------+-------------------------------------------------+ |fleet | | +--------------------------------------------+-------------------------------------------------+ -|gamification | | +|gamification | Done | +--------------------------------------------+-------------------------------------------------+ |gamification_sale_crm | | +--------------------------------------------+-------------------------------------------------+ diff --git a/openupgrade_scripts/scripts/gamification/14.0.1.0/noupdate_changes.xml b/openupgrade_scripts/scripts/gamification/14.0.1.0/noupdate_changes.xml index c919a9d190cf..eda8596bee40 100644 --- a/openupgrade_scripts/scripts/gamification/14.0.1.0/noupdate_changes.xml +++ b/openupgrade_scripts/scripts/gamification/14.0.1.0/noupdate_changes.xml @@ -1,10 +1,10 @@ - other + - other + @@ -153,7 +153,7 @@ - + diff --git a/openupgrade_scripts/scripts/gamification/14.0.1.0/post-migration.py b/openupgrade_scripts/scripts/gamification/14.0.1.0/post-migration.py new file mode 100644 index 000000000000..c0ac0c96580f --- /dev/null +++ b/openupgrade_scripts/scripts/gamification/14.0.1.0/post-migration.py @@ -0,0 +1,27 @@ +# Copyright 2021 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +def create_karma_trackings(env): + openupgrade.logged_query( + env.cr, + """ + INSERT INTO gamification_karma_tracking (user_id, old_value, new_value, + tracking_date, create_uid, write_uid, create_date, write_date) + SELECT id, 0, karma, create_date::date, create_uid, write_uid, + create_date, write_date + FROM res_users + WHERE karma IS NOT NULL AND karma != 0""", + ) + + +@openupgrade.migrate() +def migrate(env, version): + create_karma_trackings(env) + openupgrade.load_data(env.cr, "gamification", "14.0.1.0/noupdate_changes.xml") + openupgrade.delete_record_translations( + env.cr, + "gamification", + ["email_template_badge_received", "email_template_goal_reminder"], + ) diff --git a/openupgrade_scripts/scripts/gamification/14.0.1.0/pre-migration.py b/openupgrade_scripts/scripts/gamification/14.0.1.0/pre-migration.py new file mode 100644 index 000000000000..fe114c6ca29d --- /dev/null +++ b/openupgrade_scripts/scripts/gamification/14.0.1.0/pre-migration.py @@ -0,0 +1,18 @@ +# Copyright 2021 ForgeFlow S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +from openupgradelib import openupgrade + + +@openupgrade.migrate() +def migrate(env, version): + openupgrade.rename_fields( + env, + [ + ( + "gamification.challenge", + "gamification_challenge", + "category", + "challenge_category", + ) + ], + ) diff --git a/openupgrade_scripts/scripts/gamification/14.0.1.0/upgrade_analysis_work.txt b/openupgrade_scripts/scripts/gamification/14.0.1.0/upgrade_analysis_work.txt new file mode 100644 index 000000000000..f612693cdf21 --- /dev/null +++ b/openupgrade_scripts/scripts/gamification/14.0.1.0/upgrade_analysis_work.txt @@ -0,0 +1,35 @@ +---Models in module 'gamification'--- +new model gamification.karma.tracking +# DONE: post-migration: populated + +---Fields in module 'gamification'--- +gamification / gamification.challenge / category (selection) : DEL required, selection_keys: ['hr', 'other'], req_default: function +gamification / gamification.challenge / challenge_category (selection): NEW required, selection_keys: ['hr', 'other'], req_default: function, hasdefault +# DONE: pre-migration: renamed field + +gamification / gamification.karma.rank / karma_min (integer) : now required, req_default: function +# NOTHING TO DO: has default + +gamification / gamification.karma.tracking / consolidated (boolean) : NEW +gamification / gamification.karma.tracking / new_value (integer) : NEW required +gamification / gamification.karma.tracking / old_value (integer) : NEW required +gamification / gamification.karma.tracking / tracking_date (date) : NEW hasdefault +gamification / gamification.karma.tracking / user_id (many2one) : NEW relation: res.users, required +gamification / res.users / karma_tracking_ids (one2many) : NEW relation: gamification.karma.tracking +# DONE: post-migration: created records for each user with karma + +---XML records in module 'gamification'--- +DEL gamification.goal.definition: gamification.definition_nbr_following (noupdate) +NEW ir.actions.act_window: gamification.action_current_rank_users +NEW ir.actions.act_window: gamification.gamification_karma_tracking_action +NEW ir.cron: gamification.ir_cron_consolidate_last_month (noupdate) +NEW ir.model.access: gamification.access_gamification_badge_user_wizard +NEW ir.model.access: gamification.access_gamification_goal_wizard +NEW ir.model.access: gamification.gamification_karma_tracking_access_all +NEW ir.model.access: gamification.gamification_karma_tracking_access_user_manager +NEW ir.ui.menu: gamification.gamification_karma_tracking_menu +NEW ir.ui.view: gamification.gamification_karma_tracking_view_form +NEW ir.ui.view: gamification.gamification_karma_tracking_view_search +NEW ir.ui.view: gamification.gamification_karma_tracking_view_tree +NEW ir.ui.view: gamification.res_users_view_form +# NOTHING TO DO