diff --git a/addons/hr_goal/goal.py b/addons/hr_goal/goal.py index 1808f0a9ec8..cc4c525deae 100644 --- a/addons/hr_goal/goal.py +++ b/addons/hr_goal/goal.py @@ -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, diff --git a/addons/hr_goal/view/goal.xml b/addons/hr_goal/view/goal.xml index ab4ee3f8b3d..c711927044c 100644 --- a/addons/hr_goal/view/goal.xml +++ b/addons/hr_goal/view/goal.xml @@ -18,6 +18,7 @@ +