[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.
This commit is contained in:
rar-odoo
2017-08-17 16:30:48 +02:00
committed by GitHub
parent cd0ba4234b
commit 7e24143b35
+6 -2
View File
@@ -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