[IMP] gamification: at least one user and planline is required
bzr revid: mat@openerp.com-20130218155933-p1nqmmppdts1wuik
This commit is contained in:
parent
1d3f9e41f4
commit
7d3ec21157
|
@ -234,6 +234,25 @@ class gamification_goal_plan(osv.Model):
|
||||||
'report_message_frequency' : 'onchange',
|
'report_message_frequency' : 'onchange',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _check_nonzero_planline(self, cr, uid, ids, context=None):
|
||||||
|
"checks that there is at least one planline set"
|
||||||
|
for plan in self.browse(cr, uid, ids, context):
|
||||||
|
if len(plan.planline_ids) < 1:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def _check_nonzero_users(self, cr, uid, ids, context=None):
|
||||||
|
"checks that there is at least one user set"
|
||||||
|
for plan in self.browse(cr, uid, ids, context):
|
||||||
|
if len(plan.user_ids) < 1:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
_constraints = [
|
||||||
|
(_check_nonzero_planline, "At least one planline is required to create a goal plan", ['planline_ids']),
|
||||||
|
(_check_nonzero_users, "At least one user is required to create a goal plan", ['user_ids']),
|
||||||
|
]
|
||||||
|
|
||||||
def action_start(self, cr, uid, ids, context=None):
|
def action_start(self, cr, uid, ids, context=None):
|
||||||
return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context)
|
return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue