[IMP] gamification: change of state when using buttons

bzr revid: mat@openerp.com-20130215160204-0jt6yw01lytjgyto
This commit is contained in:
Martin Trigaux 2013-02-15 17:02:04 +01:00
parent 73b558e3c3
commit 33be2c1b8a
3 changed files with 28 additions and 8 deletions

View File

@ -164,6 +164,16 @@ class gamification_goal(osv.Model):
'state': 'inprogress',
}
def action_reach(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'reached'}, context=context)
def action_fail(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'failed'}, context=context)
def action_cancel(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context)
class gamification_goal_plan(osv.Model):
"""Ga;ification goal plan
@ -206,18 +216,28 @@ class gamification_goal_plan(osv.Model):
string="Frequency",
required=True),
'report_message_group_id' : fields.many2one('mail.group',
string='Group',
string='Report to',
help='Group that will receive the report in addition to the user'),
'report_header' : fields.text('Report header'),
}
_defaults = {
'period': 'once',
'state': 'inprogress',
'state': 'draft',
'report_mode' : 'progressbar',
'report_message_frequency' : 'onchange',
}
def action_start(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'inprogress'}, context=context)
def action_close(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'done'}, context=context)
def action_cancel(self, cr, uid, ids, context=None):
return self.write(cr, uid, ids, {'state': 'draft'}, context=context)
class gamification_goal_planline(osv.Model):
"""Gamification goal planline

View File

@ -30,9 +30,9 @@
<field name="arch" type="xml">
<form string="Goal" version="7.0">
<header>
<button string="Mark as reached" type="workflow" name="signal_reached" states="inprogress"/>
<button string="Mark as failed" type="workflow" name="signal_failed" states="inprogress"/>
<!-- <button string="Cancel completion" type="workflow" name="signal_cancel" states="failed,reached"/> -->
<button string="Mark as reached" type="object" name="action_reach" states="inprogress"/>
<button string="Mark as failed" type="object" name="action_fail" states="inprogress"/>
<button string="Cancel completion" type="object" name="action_cancel" states="failed,reached"/>
<field name="state" widget="statusbar"/>
</header>
<sheet>

View File

@ -26,9 +26,9 @@
<field name="arch" type="xml">
<form string="Goal types" version="7.0">
<header>
<button string="Start plan" type="workflow" name="signal_start" states="draft"/>
<button string="Close plan" type="workflow" name="signal_close" states="inprogress"/>
<button string="Cancel plan" type="workflow" name="signal_cancel" states="inprogress"/>
<button string="Start plan" type="object" name="action_start" states="draft"/>
<button string="Close plan" type="object" name="action_close" states="inprogress"/>
<button string="Cancel plan" type="object" name="action_cancel" states="inprogress"/>
<field name="state" widget="statusbar"/>
</header>
<sheet>