summaryrefslogtreecommitdiff
path: root/addons/hr_gamification/wizard
diff options
context:
space:
mode:
authorThibault Delavallée <tde@openerp.com>2014-01-06 14:57:00 +0100
committerThibault Delavallée <tde@openerp.com>2014-01-06 14:57:00 +0100
commit49c0b7a82003a889edc19cb189d0d6d0ebda2c5f (patch)
treed24c9d3fe3baad3ba06f11d4bf334e2504fb6092 /addons/hr_gamification/wizard
parentc4c268c902a134efdf0f097053c9b28d6b14417c (diff)
parentced63415b7319e12fb9d31a3e370850278f697c1 (diff)
[MERGE] Sync with trunk
bzr revid: tde@openerp.com-20140106135700-rt0g44w5xmpbtxiu
Diffstat (limited to 'addons/hr_gamification/wizard')
-rw-r--r--addons/hr_gamification/wizard/__init__.py22
-rw-r--r--addons/hr_gamification/wizard/grant_badge.py60
-rw-r--r--addons/hr_gamification/wizard/grant_badge.xml46
3 files changed, 128 insertions, 0 deletions
diff --git a/addons/hr_gamification/wizard/__init__.py b/addons/hr_gamification/wizard/__init__.py
new file mode 100644
index 00000000000..bb521f011bb
--- /dev/null
+++ b/addons/hr_gamification/wizard/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013 OpenERP SA (<http://openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import grant_badge \ No newline at end of file
diff --git a/addons/hr_gamification/wizard/grant_badge.py b/addons/hr_gamification/wizard/grant_badge.py
new file mode 100644
index 00000000000..b8a51044d4c
--- /dev/null
+++ b/addons/hr_gamification/wizard/grant_badge.py
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2013 OpenERP SA (<http://www.openerp.com>)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from openerp.osv import fields, osv
+from openerp.tools.translate import _
+
+class hr_grant_badge_wizard(osv.TransientModel):
+ _name = 'gamification.badge.user.wizard'
+ _inherit = ['gamification.badge.user.wizard']
+
+ _columns = {
+ 'employee_id': fields.many2one("hr.employee", string='Employee', required=True),
+ 'user_id': fields.related("employee_id", "user_id",
+ type="many2one", relation="res.users",
+ store=True, string='User')
+ }
+
+ def action_grant_badge(self, cr, uid, ids, context=None):
+ """Wizard action for sending a badge to a chosen employee"""
+ if context is None:
+ context = {}
+
+ badge_user_obj = self.pool.get('gamification.badge.user')
+
+ for wiz in self.browse(cr, uid, ids, context=context):
+ if not wiz.user_id:
+ raise osv.except_osv(_('Warning!'), _('You can send badges only to employees linked to a user.'))
+
+ if uid == wiz.user_id.id:
+ raise osv.except_osv(_('Warning!'), _('You can not send a badge to yourself'))
+
+ values = {
+ 'user_id': wiz.user_id.id,
+ 'sender_id': uid,
+ 'badge_id': wiz.badge_id.id,
+ 'employee_id': wiz.employee_id.id,
+ 'comment': wiz.comment,
+ }
+
+ badge_user = badge_user_obj.create(cr, uid, values, context=context)
+ result = badge_user_obj._send_badge(cr, uid, [badge_user], context=context)
+ return result \ No newline at end of file
diff --git a/addons/hr_gamification/wizard/grant_badge.xml b/addons/hr_gamification/wizard/grant_badge.xml
new file mode 100644
index 00000000000..6dcf2d2e7c4
--- /dev/null
+++ b/addons/hr_gamification/wizard/grant_badge.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openerp>
+ <data>
+
+ <record id="view_badge_wizard_grant_employee" model="ir.ui.view">
+ <field name="name">Grant Badge Employee Form</field>
+ <field name="model">gamification.badge.user.wizard</field>
+ <field name="inherit_id" ref="gamification.view_badge_wizard_grant" />
+ <field name="arch" type="xml">
+ <data>
+ <xpath expr="//field[@name='user_id']" position="replace">
+ <field name="employee_id" nolabel="1" domain="[('user_id', '!=', False),('user_id', '!=', uid)]" />
+ </xpath>
+ </data>
+ </field>
+ </record>
+
+ <record id="view_badge_wizard_reward" model="ir.ui.view">
+ <field name="name">Reward Employee Badge Form</field>
+ <field name="model">gamification.badge.user.wizard</field>
+ <field name="arch" type="xml">
+ <form string="Reward Employee with" version="7.0">
+ What are you thank for?
+ <group>
+ <field name="employee_id" invisible="1" />
+ <field name="badge_id" nolabel="1" colspan="4" />
+ <field name="comment" nolabel="1" placeholder="Describe what they did and why it matters (will be public)" />
+ </group>
+ <footer>
+ <button string="Reward Employee" type="object" name="action_grant_badge" class="oe_highlight" /> or
+ <button string="Cancel" special="cancel" class="oe_link"/>
+ </footer>
+ </form>
+ </field>
+ </record>
+
+ <act_window domain="[]" id="action_reward_wizard"
+ name="Reward Employee"
+ target="new"
+ res_model="gamification.badge.user.wizard"
+ context="{'default_employee_id': active_id, 'employee_id': active_id}"
+ view_type="form" view_mode="form"
+ view_id="view_badge_wizard_reward"/>
+
+ </data>
+</openerp>