[IMP] send badge from employee profile
bzr revid: mat@openerp.com-20130318141457-amz13k27718i9cqi
This commit is contained in:
@@ -45,6 +45,8 @@ class gamification_badge_user(osv.Model):
|
||||
'create_uid': fields.many2one('res.users', 'Creator', readonly=True),
|
||||
}
|
||||
|
||||
_order = "create_date desc"
|
||||
|
||||
|
||||
class gamification_badge(osv.Model):
|
||||
"""Badge object that users can send and receive"""
|
||||
@@ -357,6 +359,7 @@ class grant_badge_wizard(osv.TransientModel):
|
||||
}
|
||||
|
||||
def action_grant_badge(self, cr, uid, ids, context=None):
|
||||
"""Wizard action for sending a badge to a chosen user"""
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
@@ -364,13 +367,19 @@ class grant_badge_wizard(osv.TransientModel):
|
||||
badge_user_obj = self.pool.get('gamification.badge.user')
|
||||
|
||||
for wiz in self.browse(cr, uid, ids, context=context):
|
||||
if uid == wiz.user_id.id:
|
||||
raise osv.except_osv(_('Warning!'), _('You can not send a badge to yourself'))
|
||||
|
||||
if badge_obj.can_grant_badge(cr, uid,
|
||||
user_from_id=uid,
|
||||
badge_id=wiz.badge_id.id,
|
||||
context=context):
|
||||
|
||||
badge_user = badge_user_obj.create(cr, uid,
|
||||
{'user_id': wiz.user_id.id, 'badge_id': wiz.badge_id.id, 'comment': wiz.comment}, context=context)
|
||||
values = {
|
||||
'user_id': wiz.user_id.id,
|
||||
'badge_id': wiz.badge_id.id,
|
||||
'comment': wiz.comment,
|
||||
}
|
||||
badge_user = badge_user_obj.create(cr, uid, values, context=context)
|
||||
|
||||
user_from = self.pool.get('res.users').browse(cr, uid, uid, context=context)
|
||||
|
||||
|
||||
@@ -177,9 +177,9 @@ jspW8F2wIbhtSRr0Vf4AD6Nod0TaN4kAAAAASUVORK5CYII=" alt="got-it" /></t>
|
||||
<a type="open"><t t-esc="record.badge_name.raw_value" /></a>
|
||||
</h4>
|
||||
<t t-if="record.comment.raw_value">
|
||||
<em><field name="comment"/></em>
|
||||
<p><em><field name="comment"/></em></p>
|
||||
</t>
|
||||
Sent by <a type="open"><field name="create_uid" /> the <t t-esc="record.create_date.raw_value.toString(Date.CultureInfo.formatPatterns.shortDate)" /></a>
|
||||
<p>Sent by <a type="open"><field name="create_uid" /></a> the <t t-esc="record.create_date.raw_value.toString(Date.CultureInfo.formatPatterns.shortDate)" /></p>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -75,6 +75,7 @@ class hr_grant_badge_wizard(osv.TransientModel):
|
||||
}
|
||||
|
||||
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 = {}
|
||||
|
||||
@@ -85,6 +86,9 @@ class hr_grant_badge_wizard(osv.TransientModel):
|
||||
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'))
|
||||
|
||||
if badge_obj.can_grant_badge(cr, uid,
|
||||
user_from_id=uid,
|
||||
badge_id=wiz.badge_id.id,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Wizard -->
|
||||
|
||||
<record id="gamification.view_badge_wizard_grant" model="ir.ui.view">
|
||||
<field name="name">Grant Badge Employee Form</field>
|
||||
<field name="model">gamification.badge.user.wizard</field>
|
||||
@@ -24,16 +26,49 @@
|
||||
<menuitem id="gamification_badge_menu_hr" parent="hr.menu_hr_main" action="gamification.badge_list_action" groups="gamification.group_goal_user" />
|
||||
|
||||
|
||||
<record id="gamification.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">
|
||||
Select the badge that the employee will receive
|
||||
<group>
|
||||
<field name="employee_id" invisible="1" />
|
||||
<field name="badge_id" />
|
||||
<field name="comment" />
|
||||
</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"/>
|
||||
|
||||
|
||||
|
||||
<!-- HR Employee -->
|
||||
|
||||
<record id="hr_hr_employee_view_form" model="ir.ui.view">
|
||||
<field name="name">hr.hr.employee.view.form</field>
|
||||
<field name="model">hr.employee</field>
|
||||
<field name="inherit_id" ref="hr.view_employee_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@string='Public Information']" position="before">
|
||||
<page string="Received Badges">
|
||||
<field name="badge_ids" widget="many2many_kanban" />
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="//div[@name='button_box']" position="inside">
|
||||
<button string="Send Reward" type="action" name="%(action_reward_wizard)d" />
|
||||
</xpath>
|
||||
<xpath expr="//page[@string='Public Information']" position="before">
|
||||
<page string="Received Badges">
|
||||
<field name="badge_ids" widget="many2many_kanban" />
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user