diff --git a/addons/gamification/badge.py b/addons/gamification/badge.py
index ab3bdb81c12..a209eaf822d 100644
--- a/addons/gamification/badge.py
+++ b/addons/gamification/badge.py
@@ -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)
diff --git a/addons/gamification/badge_view.xml b/addons/gamification/badge_view.xml
index 002424168ce..0a7e32769d4 100644
--- a/addons/gamification/badge_view.xml
+++ b/addons/gamification/badge_view.xml
@@ -177,9 +177,9 @@ jspW8F2wIbhtSRr0Vf4AD6Nod0TaN4kAAAAASUVORK5CYII=" alt="got-it" />