From 3751379f1e9a4c215fb6eb898b4ccc67659b9ace Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 10 May 2022 21:51:50 +0700 Subject: initial commit 2 --- addons/hr_gamification/wizard/__init__.py | 4 ++ .../wizard/gamification_badge_user_wizard.py | 31 ++++++++++++++ .../gamification_badge_user_wizard_views.xml | 50 ++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 addons/hr_gamification/wizard/__init__.py create mode 100644 addons/hr_gamification/wizard/gamification_badge_user_wizard.py create mode 100644 addons/hr_gamification/wizard/gamification_badge_user_wizard_views.xml (limited to 'addons/hr_gamification/wizard') diff --git a/addons/hr_gamification/wizard/__init__.py b/addons/hr_gamification/wizard/__init__.py new file mode 100644 index 00000000..04b74f6b --- /dev/null +++ b/addons/hr_gamification/wizard/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import gamification_badge_user_wizard diff --git a/addons/hr_gamification/wizard/gamification_badge_user_wizard.py b/addons/hr_gamification/wizard/gamification_badge_user_wizard.py new file mode 100644 index 00000000..6bb1370b --- /dev/null +++ b/addons/hr_gamification/wizard/gamification_badge_user_wizard.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models, _ +from odoo.exceptions import UserError, AccessError + + +class GamificationBadgeUserWizard(models.TransientModel): + _inherit = 'gamification.badge.user.wizard' + + employee_id = fields.Many2one('hr.employee', string='Employee', required=True) + user_id = fields.Many2one('res.users', string='User', related='employee_id.user_id', + store=False, readonly=True, compute_sudo=True) + + def action_grant_badge(self): + """Wizard action for sending a badge to a chosen employee""" + if not self.user_id: + raise UserError(_('You can send badges only to employees linked to a user.')) + + if self.env.uid == self.user_id.id: + raise UserError(_('You can not send a badge to yourself.')) + + values = { + 'user_id': self.user_id.id, + 'sender_id': self.env.uid, + 'badge_id': self.badge_id.id, + 'employee_id': self.employee_id.id, + 'comment': self.comment, + } + + return self.env['gamification.badge.user'].create(values)._send_badge() diff --git a/addons/hr_gamification/wizard/gamification_badge_user_wizard_views.xml b/addons/hr_gamification/wizard/gamification_badge_user_wizard_views.xml new file mode 100644 index 00000000..364fc609 --- /dev/null +++ b/addons/hr_gamification/wizard/gamification_badge_user_wizard_views.xml @@ -0,0 +1,50 @@ + + + + + gamification.badge.user.wizard.form.inherit + gamification.badge.user.wizard + + + + + True + + + + + + + + + + gamification.badge.user.wizard.form + gamification.badge.user.wizard + +
+ What are you thankful for? + + + + + + +
+
+
+
+
+ + + Reward Employee + gamification.badge.user.wizard + form + + new + [] + {'default_employee_id': active_id, 'employee_id': active_id} + + +
-- cgit v1.2.3