[IMP] gamification: commit for each goal definition in cron
bzr revid: mat@openerp.com-20140506113831-iut3aqbwfwbnertv
This commit is contained in:
parent
697dcae728
commit
a233e26f71
|
@ -264,6 +264,9 @@ class gamification_challenge(osv.Model):
|
|||
- Create the missing goals (eg: modified the challenge to add lines)
|
||||
- Update every running challenge
|
||||
"""
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
# start scheduled challenges
|
||||
planned_challenge_ids = self.search(cr, uid, [
|
||||
('state', '=', 'draft'),
|
||||
|
@ -281,6 +284,9 @@ class gamification_challenge(osv.Model):
|
|||
if not ids:
|
||||
ids = self.search(cr, uid, [('state', '=', 'inprogress')], context=context)
|
||||
|
||||
# in cron mode, will do intermediate commits
|
||||
# TODO in trunk: replace by parameter
|
||||
context.update({'commit_gamification': True})
|
||||
return self._update_all(cr, uid, ids, context=context)
|
||||
|
||||
def _update_all(self, cr, uid, ids, context=None):
|
||||
|
|
|
@ -239,6 +239,7 @@ class gamification_goal(osv.Model):
|
|||
the target value being reached, the goal is set as failed."""
|
||||
if context is None:
|
||||
context = {}
|
||||
commit = context.get('commit_gamification', False)
|
||||
|
||||
goals_by_definition = {}
|
||||
all_goals = {}
|
||||
|
@ -358,6 +359,8 @@ class gamification_goal(osv.Model):
|
|||
value['closed'] = True
|
||||
if value:
|
||||
self.write(cr, uid, [goal.id], value, context=context)
|
||||
if commit:
|
||||
cr.commit()
|
||||
return True
|
||||
|
||||
def action_start(self, cr, uid, ids, context=None):
|
||||
|
|
Loading…
Reference in New Issue