diff options
| author | David Beguin <dbe@odoo.com> | 2019-05-17 14:18:44 +0000 |
|---|---|---|
| committer | David Beguin <dbe@odoo.com> | 2019-05-21 11:22:08 +0000 |
| commit | 472c95e4af3c457eeea8f8560baa3fbf248cacbc (patch) | |
| tree | b8637d41ba68d7df622e91962f6a39d1f14b7cb8 /addons/gamification/models/res_users.py | |
| parent | dc694e9fb585ccbe9875e62f1312136020ceb5f2 (diff) | |
[FIX] website_profile, gamification : compute rank for website_published users only
If a non website_published user was 2nd in karma position, the all users page was
displaying in the top 3 a user with position 4 (in rank) as "normal users" cannot see
non published users.
The field karma_position is now deprecated and will be removed in master.
Task ID : 2000687
PR #33475
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Diffstat (limited to 'addons/gamification/models/res_users.py')
| -rw-r--r-- | addons/gamification/models/res_users.py | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/addons/gamification/models/res_users.py b/addons/gamification/models/res_users.py index 6a188f2003a..daa9d4bc1e1 100644 --- a/addons/gamification/models/res_users.py +++ b/addons/gamification/models/res_users.py @@ -3,6 +3,9 @@ from odoo import api, fields, models +import logging + +_logger = logging.getLogger(__name__) class Users(models.Model): _inherit = 'res.users' @@ -18,26 +21,9 @@ class Users(models.Model): @api.depends('karma') def _compute_karma_position(self): - where_query = self._where_calc([]) - self._apply_ir_rules(where_query, 'read') - from_clause, where_clause, where_clause_params = where_query.get_sql() - - query = """ - SELECT sub.id, sub.karma_position - FROM ( - SELECT id, row_number() OVER (ORDER BY res_users.karma DESC) AS karma_position - FROM {from_clause} - WHERE {where_clause} - ) sub - WHERE sub.id IN %s - """.format(from_clause=from_clause, where_clause=where_clause) - - self.env.cr.execute(query, where_clause_params + [tuple(self.ids)]) - - position_map = {item['id']: item['karma_position'] for item in self.env.cr.dictfetchall()} - + _logger.warning("The field karma_position from res.users is deprecated. Don't use it anymore.") for user in self: - user.karma_position = position_map.get(user.id, 0) + user.karma_position = 0 @api.multi @api.depends('badge_ids') |
