From 6c9f08cfbb005ca8252290301752edb4e0b7cd75 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Wed, 3 Jul 2013 12:25:07 +0200 Subject: [PATCH] [fix] gamification: correctly evaluate completness bzr revid: mat@openerp.com-20130703102507-i85owm4ptmnulplc --- addons/gamification/badge.py | 4 ++-- addons/gamification/goal.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/gamification/badge.py b/addons/gamification/badge.py index 51c4a033803..b562c6f7a7d 100644 --- a/addons/gamification/badge.py +++ b/addons/gamification/badge.py @@ -98,10 +98,10 @@ class gamification_badge(osv.Model): result = dict.fromkeys(ids, False) for badge in self.browse(cr, uid, ids, context=context): if self._can_grant_badge(cr, uid, uid, badge.id, context) != 1: - #if the user cannot grant this badge at all, result is 0 + # if the user cannot grant this badge at all, result is 0 result[badge.id] = 0 elif not badge.rule_max: - #if there is no limitation, -1 is returned which mean 'infinite' + # if there is no limitation, -1 is returned which means 'infinite' result[badge.id] = -1 else: result[badge.id] = badge.rule_max_number - badge.stat_my_monthly_sending diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 833d8de9c2f..6657b76ce3a 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -130,11 +130,13 @@ class gamification_goal(osv.Model): """Return the percentage of completeness of the goal, between 0 and 100""" res = dict.fromkeys(ids, 0.0) for goal in self.browse(cr, uid, ids, context=context): - if goal.type_condition == 'higher' and goal.current > 0: + if goal.type_condition == 'higher': res[goal.id] = min(100, round(100.0 * goal.current / goal.target_goal, 2)) elif goal.current < goal.target_goal: # a goal 'lower than' has only two values possible: 0 or 100% res[goal.id] = 100.0 + else: + res[goal.id] = 0.0 return res def on_change_type_id(self, cr, uid, ids, type_id=False, context=None):