[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)
|
- Create the missing goals (eg: modified the challenge to add lines)
|
||||||
- Update every running challenge
|
- Update every running challenge
|
||||||
"""
|
"""
|
||||||
|
if context is None:
|
||||||
|
context = {}
|
||||||
|
|
||||||
# start scheduled challenges
|
# start scheduled challenges
|
||||||
planned_challenge_ids = self.search(cr, uid, [
|
planned_challenge_ids = self.search(cr, uid, [
|
||||||
('state', '=', 'draft'),
|
('state', '=', 'draft'),
|
||||||
|
@ -281,6 +284,9 @@ class gamification_challenge(osv.Model):
|
||||||
if not ids:
|
if not ids:
|
||||||
ids = self.search(cr, uid, [('state', '=', 'inprogress')], context=context)
|
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)
|
return self._update_all(cr, uid, ids, context=context)
|
||||||
|
|
||||||
def _update_all(self, cr, uid, ids, context=None):
|
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."""
|
the target value being reached, the goal is set as failed."""
|
||||||
if context is None:
|
if context is None:
|
||||||
context = {}
|
context = {}
|
||||||
|
commit = context.get('commit_gamification', False)
|
||||||
|
|
||||||
goals_by_definition = {}
|
goals_by_definition = {}
|
||||||
all_goals = {}
|
all_goals = {}
|
||||||
|
@ -358,6 +359,8 @@ class gamification_goal(osv.Model):
|
||||||
value['closed'] = True
|
value['closed'] = True
|
||||||
if value:
|
if value:
|
||||||
self.write(cr, uid, [goal.id], value, context=context)
|
self.write(cr, uid, [goal.id], value, context=context)
|
||||||
|
if commit:
|
||||||
|
cr.commit()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def action_start(self, cr, uid, ids, context=None):
|
def action_start(self, cr, uid, ids, context=None):
|
||||||
|
|
Loading…
Reference in New Issue