Initial commit: Vertical Industry packages

This commit is contained in:
Ernad Husremovic 2025-08-29 15:20:52 +02:00
commit d5567a0017
766 changed files with 733028 additions and 0 deletions

View file

@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import update_goal
from . import grant_badge

View file

@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models, _, exceptions
class grant_badge_wizard(models.TransientModel):
""" Wizard allowing to grant a badge to a user"""
_name = 'gamification.badge.user.wizard'
_description = 'Gamification User Badge Wizard'
user_id = fields.Many2one("res.users", string='User', required=True)
badge_id = fields.Many2one("gamification.badge", string='Badge', required=True)
comment = fields.Text('Comment')
def action_grant_badge(self):
"""Wizard action for sending a badge to a chosen user"""
BadgeUser = self.env['gamification.badge.user']
uid = self.env.uid
for wiz in self:
if uid == wiz.user_id.id:
raise exceptions.UserError(_('You can not grant a badge to yourself.'))
#create the badge
BadgeUser.create({
'user_id': wiz.user_id.id,
'sender_id': uid,
'badge_id': wiz.badge_id.id,
'comment': wiz.comment,
})._send_badge()
return True

View file

@ -0,0 +1,31 @@
<odoo>
<record id="view_badge_wizard_grant" model="ir.ui.view">
<field name="name">Grant Badge User Form</field>
<field name="model">gamification.badge.user.wizard</field>
<field name="arch" type="xml">
<form string="Grant Badge To">
Who would you like to reward?
<field name="badge_id" invisible="1"/>
<group>
<field name="user_id" nolabel="1" colspan="2"/>
<field name="comment" nolabel="1" placeholder="Describe what they did and why it matters (will be public)" colspan="2"/>
</group>
<footer>
<button string="Grant Badge" 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_grant_wizard" model="ir.actions.act_window">
<field name="name">Grant Badge</field>
<field name="res_model">gamification.badge.user.wizard</field>
<field name="view_id" ref="gamification.view_badge_wizard_grant"/>
<field name="target">new</field>
<field name="context">{
'default_badge_id': active_id,
'badge_id': active_id
}</field>
</record>
</odoo>

View file

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models, fields
class goal_manual_wizard(models.TransientModel):
"""Wizard to update a manual goal"""
_name = 'gamification.goal.wizard'
_description = 'Gamification Goal Wizard'
goal_id = fields.Many2one("gamification.goal", string='Goal', required=True)
current = fields.Float('Current')
def action_update_current(self):
"""Wizard action for updating the current value"""
for wiz in self:
wiz.goal_id.write({
'current': wiz.current,
'goal_id': wiz.goal_id.id,
'to_update': False,
})
wiz.goal_id.update_goal()
return False

View file

@ -0,0 +1,19 @@
<odoo>
<record id="view_goal_wizard_update_current" model="ir.ui.view">
<field name="name">Update the current value of the Goal</field>
<field name="model">gamification.goal.wizard</field>
<field name="arch" type="xml">
<form string="Grant Badge To">
Set the current value you have reached for this goal
<group>
<field name="goal_id" invisible="1"/>
<field name="current" />
</group>
<footer>
<button string="Update" type="object" name="action_update_current" class="btn-primary" data-hotkey="q"/>
<button string="Cancel" special="cancel" data-hotkey="z" class="btn-secondary"/>
</footer>
</form>
</field>
</record>
</odoo>