+
Security rules to define who is allowed to manually grant badges. Not enforced for administrator.
diff --git a/addons/gamification/wizard/grant_badge.py b/addons/gamification/wizard/grant_badge.py
index e100b2dce29..1b80c490ef3 100644
--- a/addons/gamification/wizard/grant_badge.py
+++ b/addons/gamification/wizard/grant_badge.py
@@ -46,10 +46,11 @@ class grant_badge_wizard(osv.TransientModel):
#create the badge
values = {
'user_id': wiz.user_id.id,
+ 'user_from_id': uid,
'badge_id': wiz.badge_id.id,
'comment': wiz.comment,
}
badge_user = badge_user_obj.create(cr, uid, values, context=context)
- result = badge_obj._send_badge(cr, uid, badge_user, user_from=uid, context=context)
+ result = badge_obj._send_badge(cr, uid, badge_user, context=context)
return result
diff --git a/addons/hr_gamification/models/gamification.py b/addons/hr_gamification/models/gamification.py
index 27c1834bc39..f07ed9c95c4 100644
--- a/addons/hr_gamification/models/gamification.py
+++ b/addons/hr_gamification/models/gamification.py
@@ -49,17 +49,6 @@ class gamification_badge(osv.Model):
_name = 'gamification.badge'
_inherit = ['gamification.badge']
- def message_post(self, cr, uid, thread_id, context=None, **kwargs):
- """Overwrite the message_post method to send the badge to the employee"""
- # badge_user included in the send_badge method and 'badge_id' in the wizard view
- if 'badge_user' in context and 'badge_id' in context:
- # badge = self.browse(cr, uid, context['badge_id'], context=context)
- badge_user = context['badge_user']
- if badge_user.employee_id:
- return self.pool.get('hr.employee').message_post(cr, SUPERUSER_ID,
- badge_user.employee_id.id, context=context, **kwargs)
- return super(gamification_badge, self).message_post(cr, uid, thread_id, context=context, **kwargs)
-
def get_granted_employees(self, cr, uid, badge_ids, context=None):
if context is None:
context = {}
diff --git a/addons/hr_gamification/wizard/grant_badge.py b/addons/hr_gamification/wizard/grant_badge.py
index 967324b7b87..22e72e84e27 100644
--- a/addons/hr_gamification/wizard/grant_badge.py
+++ b/addons/hr_gamification/wizard/grant_badge.py
@@ -49,11 +49,12 @@ class hr_grant_badge_wizard(osv.TransientModel):
values = {
'user_id': wiz.user_id.id,
+ 'user_from_id': uid,
'badge_id': wiz.badge_id.id,
'employee_id': wiz.employee_id.id,
'comment': wiz.comment,
}
badge_user = badge_user_obj.create(cr, uid, values, context=context)
- result = badge_user_obj._send_badge(cr, uid, [badge_user], user_from=uid, context=context)
+ result = badge_user_obj._send_badge(cr, uid, [badge_user], context=context)
return result
\ No newline at end of file