From 3b60ce38b7f73f7dd85579dc2f4a93602fe0d5e3 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 16 Dec 2013 14:27:48 +0100 Subject: [PATCH] [FIX] gamification: avoid traceback in goal computation if target == 0 (even if does not make much sense) bzr revid: mat@openerp.com-20131216132748-i4o71hmxyeyedznx --- addons/gamification/goal.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/gamification/goal.py b/addons/gamification/goal.py index 6657b76ce3a..fe07d24d43f 100644 --- a/addons/gamification/goal.py +++ b/addons/gamification/goal.py @@ -131,7 +131,10 @@ class gamification_goal(osv.Model): res = dict.fromkeys(ids, 0.0) for goal in self.browse(cr, uid, ids, context=context): if goal.type_condition == 'higher': - res[goal.id] = min(100, round(100.0 * goal.current / goal.target_goal, 2)) + if goal.current >= goal.target_goal: + res[goal.id] = 100.0 + else: + res[goal.id] = 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