From d5c4f14a1a5baf6edd794d1fcba57b258f525935 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Fri, 12 Apr 2013 15:36:06 +0200 Subject: [PATCH] [IMP] badge to employee actions bzr revid: mat@openerp.com-20130412133606-60kb4s026vfsrija --- addons/gamification/badge_view.xml | 14 +++++++++----- addons/hr_gamification/__openerp__.py | 1 + addons/hr_gamification/badge.py | 18 ++++++++++++++++++ addons/hr_gamification/badge_view.xml | 11 ++++++++++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/addons/gamification/badge_view.xml b/addons/gamification/badge_view.xml index 3d89bc752c2..9f3c113f53f 100644 --- a/addons/gamification/badge_view.xml +++ b/addons/gamification/badge_view.xml @@ -67,10 +67,12 @@
-
+
+
-

+

@@ -171,9 +173,11 @@
- - - + + + + +
diff --git a/addons/hr_gamification/__openerp__.py b/addons/hr_gamification/__openerp__.py index 7453d1e2d51..c28a43fd32a 100644 --- a/addons/hr_gamification/__openerp__.py +++ b/addons/hr_gamification/__openerp__.py @@ -30,4 +30,5 @@ This allow the user to send badges to employees instead of simple users. Badge received are displayed on the user profile.""", 'data': ['badge_view.xml'], 'auto_install': True, + 'js': ['static/src/js/badges.js'], } diff --git a/addons/hr_gamification/badge.py b/addons/hr_gamification/badge.py index 28734699307..e4ccac1cb75 100644 --- a/addons/hr_gamification/badge.py +++ b/addons/hr_gamification/badge.py @@ -61,6 +61,24 @@ class gamification_badge(osv.Model): badge_user.employee_id.id, context=context, **kwargs) return super(gamification_badge, self).message_post(cr, uid, thread_id, context=context, **kwargs) + def get_granted_employees(self, cr, uid, badge_ids, context=None): + if context is None: + context = {} + + employee_ids = [] + badge_user_ids = self.pool.get('gamification.badge.user').search(cr, uid, [('badge_id', 'in', badge_ids), ('employee_id', '!=', False)], context=context) + for badge_user in self.pool.get('gamification.badge.user').browse(cr, uid, badge_user_ids, context): + employee_ids.append(badge_user.employee_id.id) + # remove duplicates + employee_ids = list(set(employee_ids)) + return { + 'type': 'ir.actions.act_window', + 'name': 'Granted Employees', + 'view_mode': 'kanban,tree,form', + 'view_type': 'form', + 'res_model': 'hr.employee', + 'domain': [('id', 'in', employee_ids)] + } class hr_grant_badge_wizard(osv.TransientModel): _name = 'gamification.badge.user.wizard' diff --git a/addons/hr_gamification/badge_view.xml b/addons/hr_gamification/badge_view.xml index 1f47bd74d6f..f8e9e550883 100644 --- a/addons/hr_gamification/badge_view.xml +++ b/addons/hr_gamification/badge_view.xml @@ -53,7 +53,16 @@ view_type="form" view_mode="form" view_id="gamification.view_badge_wizard_reward"/> - + + Badge Form + gamification.badge + + + +