[FIX] gamification: allow having False or 0 values as result of a computation.
bzr revid: tde@openerp.com-20140411141510-c11djv7qlf9qgek2
This commit is contained in:
parent
f8664c8d97
commit
e4d4c00312
|
@ -249,16 +249,15 @@ class gamification_goal(osv.Model):
|
||||||
'object': goal,
|
'object': goal,
|
||||||
'pool': self.pool,
|
'pool': self.pool,
|
||||||
'cr': cr,
|
'cr': cr,
|
||||||
'context': dict(context), # copy context to prevent side-effects of eval
|
'context': dict(context), # copy context to prevent side-effects of eval
|
||||||
'uid': uid,
|
'uid': uid,
|
||||||
'result': False,
|
|
||||||
'date': date, 'datetime': datetime, 'timedelta': timedelta, 'time': time
|
'date': date, 'datetime': datetime, 'timedelta': timedelta, 'time': time
|
||||||
}
|
}
|
||||||
code = goal.definition_id.compute_code.strip()
|
code = goal.definition_id.compute_code.strip()
|
||||||
safe_eval(code, cxt, mode="exec", nocopy=True)
|
safe_eval(code, cxt, mode="exec", nocopy=True)
|
||||||
# the result of the evaluated codeis put in the 'result' local variable, propagated to the context
|
# the result of the evaluated codeis put in the 'result' local variable, propagated to the context
|
||||||
result = cxt.get('result', False)
|
result = cxt.get('result')
|
||||||
if result and type(result) in (float, int, long):
|
if result is not None and type(result) in (float, int, long):
|
||||||
if result != goal.current:
|
if result != goal.current:
|
||||||
towrite['current'] = result
|
towrite['current'] = result
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue