Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][MIG] gamification #2807

Merged
merged 1 commit into from
Jul 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docsource/modules130-140.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Module coverage 13.0 -> 14.0
+--------------------------------------------+-------------------------------------------------+
|fleet | |
+--------------------------------------------+-------------------------------------------------+
|gamification | |
|gamification | Done |
+--------------------------------------------+-------------------------------------------------+
|gamification_sale_crm | |
+--------------------------------------------+-------------------------------------------------+
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version='1.0' encoding='utf-8'?>
<odoo>
<record id="challenge_base_configure" model="gamification.challenge">
<field name="challenge_category">other</field>
<!-- <field name="challenge_category">other</field>-->
</record>
<record id="challenge_base_discover" model="gamification.challenge">
<field name="challenge_category">other</field>
<!-- <field name="challenge_category">other</field>-->
</record>
<record id="definition_base_company_data" model="gamification.goal.definition">
<field name="action_id" ref="base.action_res_company_form"/>
Expand Down Expand Up @@ -153,7 +153,7 @@
</field>
</record>
<record id="goal_global_multicompany" model="ir.rule">
<field name="global"/>
<!-- <field name="global"/>-->
</record>
<record id="line_base_admin1" model="gamification.challenge.line">
<field name="challenge_id" ref="challenge_base_configure"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# 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"],
)
18 changes: 18 additions & 0 deletions openupgrade_scripts/scripts/gamification/14.0.1.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2021 ForgeFlow S.L. <https://www.forgeflow.com>
# 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",
)
],
)
Original file line number Diff line number Diff line change
@@ -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