summaryrefslogtreecommitdiff
path: root/addons/gamification/models/challenge.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-09-13 13:32:51 +0000
committerChristophe Simonis <chs@odoo.com>2019-09-13 13:32:51 +0000
commit5a273e74f0fff18df5ab6cb240c9e260be4bb7ff (patch)
tree4fbc7e142335d110fa0a984ff2c345a487e37ca4 /addons/gamification/models/challenge.py
parentdc5f83b63313018999b598210b972636986c5bea (diff)
parentfe59754c5201f9392b75d5d4cce8ca1400a7ef5d (diff)
[MERGE] forward port branch saas-12.4 up to fe59754c520
closes odoo/odoo#36721 Signed-off-by: Christophe Simonis <chs@odoo.com>
Diffstat (limited to 'addons/gamification/models/challenge.py')
-rw-r--r--addons/gamification/models/challenge.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py
index 08194e0d7ec..72103f89205 100644
--- a/addons/gamification/models/challenge.py
+++ b/addons/gamification/models/challenge.py
@@ -379,9 +379,9 @@ class Challenge(models.Model):
# the goal is initialised over the limit to make sure we will compute it at least once
if line.condition == 'higher':
- values['current'] = line.target_goal - 1
+ values['current'] = min(line.target_goal - 1, 0)
else:
- values['current'] = line.target_goal + 1
+ values['current'] = max(line.target_goal + 1, 0)
if challenge.remind_update_delay:
values['remind_update_delay'] = challenge.remind_update_delay
@@ -737,7 +737,7 @@ class Challenge(models.Model):
all_reached = False
if goal.definition_condition == 'higher':
# can be over 100
- total_completeness += 100.0 * goal.current / goal.target_goal
+ total_completeness += (100.0 * goal.current / goal.target_goal) if goal.target_goal else 0
elif goal.state == 'reached':
# for lower goals, can not get percentage so 0 or 100
total_completeness += 100