mirror of
https://github.com/bringout/oca-ocb-hr.git
synced 2026-04-25 17:52:08 +02:00
Initial commit: Hr packages
This commit is contained in:
commit
62531cd146
2820 changed files with 1432848 additions and 0 deletions
|
|
@ -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
|
||||
|
|
@ -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()
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_badge_wizard_grant_employee" model="ir.ui.view">
|
||||
<field name="name">gamification.badge.user.wizard.form.inherit</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>
|
||||
<field name="user_id" position="attributes">
|
||||
<attribute name="invisible">True</attribute>
|
||||
</field>
|
||||
<xpath expr="//field[@name='user_id']" position="after">
|
||||
<field name="employee_id" nolabel="1" domain="[('user_id', '!=', False),('user_id', '!=', uid)]" colspan="2"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_badge_wizard_reward" model="ir.ui.view">
|
||||
<field name="name">gamification.badge.user.wizard.form</field>
|
||||
<field name="model">gamification.badge.user.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reward Employee with">
|
||||
What are you thankful for?
|
||||
<group>
|
||||
<group>
|
||||
<field name="employee_id" invisible="1" />
|
||||
<field name="user_id" invisible="1" />
|
||||
<field name="badge_id" nolabel="1" colspan="4" />
|
||||
</group>
|
||||
</group>
|
||||
<field name="comment" nolabel="1" placeholder="Describe what they did and why it matters (will be public)" />
|
||||
<footer>
|
||||
<button string="Reward Employee" type="object" name="action_grant_badge" class="btn-primary" data-hotkey="q"/>
|
||||
<button string="Cancel" special="cancel" data-hotkey="z" class="btn-secondary"/>
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_reward_wizard" model="ir.actions.act_window">
|
||||
<field name="name">Reward Employee</field>
|
||||
<field name="res_model">gamification.badge.user.wizard</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="view_id" ref="view_badge_wizard_reward"/>
|
||||
<field name="target">new</field>
|
||||
<field name="domain">[]</field>
|
||||
<field name="context">{'default_employee_id': active_id, 'employee_id': active_id}</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Loading…
Add table
Add a link
Reference in a new issue