summaryrefslogtreecommitdiff
path: root/addons/gamification/models/res_users.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-07-05 16:14:48 +0200
committerChristophe Simonis <chs@odoo.com>2019-07-05 16:14:48 +0200
commit66bb578ac9f0cc260a5b7f859fc0bb4fcfab6e25 (patch)
tree57b147168f7118374f0f5b4ba46f4c9d75220df2 /addons/gamification/models/res_users.py
parent201c5b5878f13c34cb7a9edb3c3296fc9a1944fe (diff)
parentbe5e8fdab800ff1fd9e953ec64801f96bcc3dac5 (diff)
[MERGE] forward port branch saas-12.2 up to be5e8fdab80
Diffstat (limited to 'addons/gamification/models/res_users.py')
-rw-r--r--addons/gamification/models/res_users.py8
1 files changed, 8 insertions, 0 deletions
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