summaryrefslogtreecommitdiff
path: root/addons/gamification
diff options
context:
space:
mode:
authorMartin Trigaux <mat@odoo.com>2019-07-15 07:07:48 +0000
committerMartin Trigaux <mat@odoo.com>2019-07-15 08:12:26 +0000
commitfd15ca19183a765e1307c4d197bf0dda30b73ab7 (patch)
tree896042073ebc752e8bcf535f21696320c69bbe13 /addons/gamification
parent6b8a0beda65dce688ecd0ee34828097b67a13dab (diff)
parent1f5a4649a67908ecb6acfec37673c8149de0471f (diff)
[MERGE] Forward port of saas-12.4 to master up to 1f5a4649a67908
closes odoo/odoo#34850 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/gamification')
-rw-r--r--addons/gamification/data/gamification_karma_rank_data.xml19
-rw-r--r--addons/gamification/data/gamification_karma_rank_demo.xml4
-rw-r--r--addons/gamification/models/res_users.py8
3 files changed, 20 insertions, 11 deletions
diff --git a/addons/gamification/data/gamification_karma_rank_data.xml b/addons/gamification/data/gamification_karma_rank_data.xml
index f86b827cceb..5eba07b1a3d 100644
--- a/addons/gamification/data/gamification_karma_rank_data.xml
+++ b/addons/gamification/data/gamification_karma_rank_data.xml
@@ -14,8 +14,8 @@
<field name="description" type="html"><p>You just began the adventure! Welcome!</p></field>
<field name="description_motivational" type="html">
<div class="media align-items-center">
- <div class="media-body">Reach the next rank to show the rest of the world you exist!</div>
- <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_student_badge.svg"/>
+ <div class="media-body">Earn your first points and join the adventure !</div>
+ <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_newbie_badge.svg"/>
</div>
</field>
<field name="karma_min">1</field>
@@ -27,8 +27,8 @@
<field name="description" type="html"><p>You're a young padawan now. May the force be with you!</p></field>
<field name="description_motivational" type="html">
<div class="media align-items-center">
- <div class="media-body">Reach the next rank to improve your status.</div>
- <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_bachelor_badge.svg"/>
+ <div class="media-body">Reach the next rank to show the rest of the world you exist.</div>
+ <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_student_badge.svg"/>
</div>
</field>
<field name="karma_min">100</field>
@@ -40,8 +40,8 @@
<field name="description" type="html"><p>You love learning things. Curiosity is a good way to progress.</p></field>
<field name="description_motivational" type="html">
<div class="media align-items-center">
- <div class="media-body">Reach the next rank and become a Master!</div>
- <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_master_badge.svg"/>
+ <div class="media-body">Reach the next rank to improve your status!</div>
+ <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_bachelor_badge.svg"/>
</div>
</field>
<field name="karma_min">500</field>
@@ -53,8 +53,8 @@
<field name="description" type="html"><p>You know what you are talking about. People learn from you.</p></field>
<field name="description_motivational" type="html">
<div class="media align-items-center">
- <div class="media-body">Reach the next rank and become a powerful user!</div>
- <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_doctor_badge.svg"/>
+ <div class="media-body">Reach the next rank and become a Master!</div>
+ <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_master_badge.svg"/>
</div>
</field>
<field name="karma_min">2000</field>
@@ -66,7 +66,8 @@
<field name="description" type="html"><p>You have reached the last rank. Congratulations!</p></field>
<field name="description_motivational" type="html">
<div class="media align-items-center">
- <div class="media-body">You have reached the last rank. Congratulations!</div>
+ <div class="media-body">Reach the next rank and become a powerful user!</div>
+ <img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_doctor_badge.svg"/>
</div>
</field>
<field name="karma_min">10000</field>
diff --git a/addons/gamification/data/gamification_karma_rank_demo.xml b/addons/gamification/data/gamification_karma_rank_demo.xml
index 6250ee227f6..839e8750047 100644
--- a/addons/gamification/data/gamification_karma_rank_demo.xml
+++ b/addons/gamification/data/gamification_karma_rank_demo.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<odoo><data noupdate="0">
+<odoo><data noupdate="1">
<!-- Set demo karma for test tour as demo user-->
<record id="base.user_demo" model="res.users">
<field name="karma">20</field>
@@ -39,7 +39,7 @@
<record id="rank_doctor" model="gamification.karma.rank">
<field name="description_motivational" type="html">
<div class="media align-items-center">
- <div class="media-body">You have reached the last rank. Congratulations!</div>
+ <div class="media-body">Reach the next rank and gain a very nice unicorn !</div>
<img class="ml-3 img img-fluid" style="max-height: 72px;" src="/gamification/static/img/rank_misc_unicorn.png"/>
</div>
</field>
diff --git a/addons/gamification/models/res_users.py b/addons/gamification/models/res_users.py
index daa9d4bc1e1..a0ca65ced45 100644
--- a/addons/gamification/models/res_users.py
+++ b/addons/gamification/models/res_users.py
@@ -96,6 +96,14 @@ class Users(models.Model):
if old_rank != user.rank_id:
user._rank_changed()
+ def _get_next_rank(self):
+ """ For fresh users with 0 karma that don't have a rank_id and next_rank_id yet
+ this method returns the first karma rank (by karma ascending). This acts as a
+ default value in related views.
+
+ TDE FIXME in post-12.4: make next_rank_id a non-stored computed field correctly computed """
+ return self.next_rank_id or (not self.rank_id and self.env['gamification.karma.rank'].search([], order="karma_min ASC", limit=1))
+
def get_gamification_redirection_data(self):
"""
Hook for other modules to add redirect button(s) in new rank reached mail