From 7e24143b352161dbd3fd3bfbc36a8ee23737e16c Mon Sep 17 00:00:00 2001 From: rar-odoo Date: Thu, 17 Aug 2017 16:30:48 +0200 Subject: [PATCH] [FIX] gamification: challenge winner (#18901) In the curent behaviour, the users of the challenge are ordered regardless of the goal definition (higher wins or lower wins). This impacts the report email with the podium of users and always puts higher on top. This fix changes the ordering depending on the goal definition type. --- addons/gamification/models/challenge.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index 8a1b02d65fe..22d5564df34 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -503,8 +503,12 @@ class Challenge(models.Model): line_data['own_goal_id'] = False, line_data['goals'] = [] - - goals = Goals.search(domain, order="completeness desc, current desc") + if line.condition=='higher': + goals = Goals.search(domain, order="completeness desc, current desc") + else: + goals = Goals.search(domain, order="completeness desc, current asc") + import ipdb + ipdb.set_trace() for ranking, goal in enumerate(goals): if user and goal.user_id == user: line_data['own_goal_id'] = goal.id