[IMP] gamification: add start goal button for draft goals

bzr revid: mat@openerp.com-20130227111220-ipgvl5djlndcnxpw
This commit is contained in:
Martin Trigaux 2013-02-27 12:12:20 +01:00
parent 504b6c4ca7
commit e57a761dc7
2 changed files with 6 additions and 2 deletions

View File

@ -208,7 +208,7 @@ class gamification_goal(osv.Model):
for goal in self.browse(cr, uid, ids, context=context or {}):
if goal.state not in ('inprogress','inprogress_update','reached'):
# skip if goal failed or canceled
# skip if goal draft, failed or canceled
continue
if goal.state == 'reached' and goal.end_date and fields.date.today() > goal.end_date:
# only a goal reached but not passed the end date will still be
@ -263,6 +263,9 @@ class gamification_goal(osv.Model):
self.write(cr, uid, [goal.id], towrite, context=context)
return True
def action_start(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'inprogress'}, context=context)
return self.update(cr, uid, ids, context=context)
def action_reach(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'reached'}, context=context)

View File

@ -40,7 +40,8 @@
<field name="arch" type="xml">
<form string="Goal" version="7.0">
<header>
<button string="Refresh state" type="object" name="update" class="oe_highlight"/>
<button string="Start goal" type="object" name="action_start" states="draft" class="oe_highlight"/>
<button string="Refresh state" type="object" name="update" states="inprogress,inprogress_update,failed,reached" class="oe_highlight"/>
<button string="Goal Reached" type="object" name="action_reach" states="inprogress,inprogress_update" />
<button string="Goal Failed" type="object" name="action_fail" states="inprogress,inprogress_update"/>
<button string="Reset Completion" type="object" name="action_cancel" states="failed,reached"/>