[ADD] gamification: add completeness progressbar
bzr revid: mat@openerp.com-20130215145415-39cx5v3pf8mn5ye7
This commit is contained in:
@@ -107,6 +107,7 @@ class gamification_goal_type(osv.Model):
|
||||
required=True),
|
||||
}
|
||||
|
||||
_order = 'sequence'
|
||||
_defaults = {
|
||||
'sequence': 0,
|
||||
'condition': 'plus',
|
||||
@@ -124,6 +125,16 @@ class gamification_goal(osv.Model):
|
||||
_description = 'Gamification goal instance'
|
||||
_inherit = 'mail.thread'
|
||||
|
||||
def _get_completeness(self, cr, uid, ids, field_name, arg, context=None):
|
||||
res = {}
|
||||
for goal in self.browse(cr, uid, ids, context):
|
||||
# more 100% ?
|
||||
if goal.target_goal > 0:
|
||||
res[goal.id] = 100.0 * goal.current / goal.target_goal
|
||||
else:
|
||||
res[goal.id] = 0.0
|
||||
return res
|
||||
|
||||
_columns = {
|
||||
'type_id' : fields.many2one('gamification.goal.type',
|
||||
string='Goal type',
|
||||
@@ -139,6 +150,9 @@ class gamification_goal(osv.Model):
|
||||
'current' : fields.float('Current',
|
||||
required=True,
|
||||
track_visibility = 'always'),
|
||||
'completeness': fields.function(_get_completeness,
|
||||
type='float',
|
||||
string='Occupation'),
|
||||
'state': fields.selection(GAMIFICATION_GOAL_STATE,
|
||||
string='State',
|
||||
required=True,
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<field name="target_goal"/>
|
||||
<field name="start_date"/>
|
||||
<field name="end_date"/>
|
||||
<field name="completeness" widget="progressbar"/>
|
||||
<field name="state" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user