From 21bb79d47e1e00df0b625453bc6817ad0d5a85f9 Mon Sep 17 00:00:00 2001 From: "Yogesh Parekh (OpenERP)" Date: Wed, 26 Mar 2014 17:55:49 +0530 Subject: [PATCH] [IMP]: Convert buttons into stat button in gamification module bzr revid: ypa@tinyerp.com-20140326122549-imqefk86wbxdxmpm --- addons/gamification/models/challenge.py | 11 +++++++++++ addons/gamification/views/challenge.xml | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/addons/gamification/models/challenge.py b/addons/gamification/models/challenge.py index 06d0c44baac..11b5f787bdd 100644 --- a/addons/gamification/models/challenge.py +++ b/addons/gamification/models/challenge.py @@ -114,6 +114,15 @@ class gamification_challenge(osv.Model): return self.pool.get('ir.model.data').get_object_reference(cr, uid, 'gamification', 'simple_report_template')[1] except ValueError: return False + + def _count_goals(self, cr, uid, ids, field_name, arg, context=None): + res = {} + try: + for goals in self.browse(cr, uid, ids, context=context): + res[goals.id] = len(goals.goals_ids) + except: + pass + return res _order = 'end_date, start_date, name, id' _columns = { @@ -191,6 +200,8 @@ class gamification_challenge(osv.Model): 'category': fields.selection(lambda s, *a, **k: s._get_categories(*a, **k), string="Appears in", help="Define the visibility of the challenge through menus", required=True), + 'goals_ids': fields.one2many('gamification.goal', 'challenge_id', 'Related Goals'), + 'goals_count': fields.function(_count_goals, type='integer', string='Related Goals') } _defaults = { diff --git a/addons/gamification/views/challenge.xml b/addons/gamification/views/challenge.xml index 075afcaccfa..ef2151c5a77 100644 --- a/addons/gamification/views/challenge.xml +++ b/addons/gamification/views/challenge.xml @@ -53,7 +53,13 @@
-