19.0 vanilla

This commit is contained in:
Ernad Husremovic 2026-03-09 09:31:00 +01:00
parent a1137a1456
commit e1d89e11e3
2789 changed files with 1093187 additions and 605897 deletions

View file

@ -8,24 +8,25 @@ 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)
employee_id = fields.Many2one('hr.employee', string='Employee', required=False)
user_id = fields.Many2one('res.users', string='User', compute='_compute_user_id',
store=True, readonly=False, 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,
'employee_id': self.user_id.employee_id.id,
'comment': self.comment,
}
return self.env['gamification.badge.user'].create(values)._send_badge()
@api.depends('employee_id')
def _compute_user_id(self):
for wizard in self:
wizard.user_id = wizard.employee_id.user_id

View file

@ -7,11 +7,9 @@
<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>
<!--remove in master-->
<xpath expr="//field[@name='user_id']" position="after">
<field name="employee_id" nolabel="1" domain="[('user_id', '!=', False),('user_id', '!=', uid)]" colspan="2"/>
<field name="employee_id" nolabel="1" invisible="1" domain="[('user_id', '!=', False),('user_id', '!=', uid)]" colspan="2"/>
</xpath>
</data>
</field>
@ -22,31 +20,42 @@
<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" />
<field name="employee_id" invisible="1" />
<field name="user_id" invisible="1" />
<group col="12">
<group colspan="9">
<div>
<div colspan="3" class="mb-3 mt-1">What are you thankful for?</div>
<field colspan="6" name="badge_id" nolabel="1" domain="[('rule_auth','!=','nobody')]"/>
</div>
</group>
<group colspan="3">
<field
name="badge_id"
nolabel="1"
class="oe_avatar m-0"
widget="image"
options="{'preview_image': 'image_1024'}"
/>
</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"/>
<button string="Grant a badge" type="object" name="action_grant_badge" class="btn-primary" data-hotkey="q"/>
<button string="Discard" special="cancel" data-hotkey="x" 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="name">Grant a badge</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>
<field name="context">{'default_employee_id': active_id, 'employee_id': active_id, 'dialog_size': 'medium'}</field>
</record>
</odoo>