diff options
| author | Martin Trigaux <mat@openerp.com> | 2013-07-03 12:25:07 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@openerp.com> | 2013-07-03 12:25:07 +0200 |
| commit | 6c9f08cfbb005ca8252290301752edb4e0b7cd75 (patch) | |
| tree | 701aae0fa6d7f8f570c43bbf7454b044d8269733 /addons/gamification | |
| parent | 2718403134a72fe95bd2b717f07b0a2c213cd6bf (diff) | |
[fix] gamification: correctly evaluate completness
bzr revid: mat@openerp.com-20130703102507-i85owm4ptmnulplc
Diffstat (limited to 'addons/gamification')
| -rw-r--r-- | addons/gamification/badge.py | 4 | ||||
| -rw-r--r-- | 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): |
