diff options
| author | Thibault Delavallée <tde@odoo.com> | 2019-06-18 14:08:02 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2019-06-28 13:45:33 +0000 |
| commit | cd039b64d46b01a293ad496bd07ba28fd8e53d95 (patch) | |
| tree | 218bbfa871e1d1abb3621b04d5febeac88e4e1dc /addons/gamification/models | |
| parent | d5f8e39923de39c3a5b7daa39ea29f71178fe56f (diff) | |
[FIX] gamification, website_{profile, slides}: correctly display next rank
This fix correctly displayed motivational of next rank to achieve depending
on current karma. Indeed description_motivational field is not the
motivational to reach next rank but to reach the current rank, taken from
previous rank point of view. That way a given rank is configured by modifying
only 1 data.
When not having any karma points (newly created user) the next rank is computed
as being the first available rank. Motivational phrases and badges are updated
accordingly. This commit partially reverts 489c8623e2c4869ce1ed8be3d186e36cc1c47456.
Result
* new user with no karma: next rank is the first rank;
* user with karma and next rank: as currently;
* user being at final rank: next rank is just current rank with a 100%
circle;
Linked to task 2005840
Related to PR #34220
Diffstat (limited to 'addons/gamification/models')
| -rw-r--r-- | addons/gamification/models/res_users.py | 8 |
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 |
