From 1db95b244c5c88c20f348b73e4e8df8ec67eb4d7 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 18 Mar 2013 13:46:20 +0100 Subject: [PATCH] [ADD] use badge user views with comment bzr revid: mat@openerp.com-20130318124620-gm17hn75lz9i4ohk --- addons/gamification/badge.py | 9 +++-- addons/gamification/badge_view.xml | 37 ++++++++++++++++++- .../templates/badge_received.mako | 10 ++--- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/addons/gamification/badge.py b/addons/gamification/badge.py index b77d5362f58..ab3bdb81c12 100644 --- a/addons/gamification/badge.py +++ b/addons/gamification/badge.py @@ -37,8 +37,12 @@ class gamification_badge_user(osv.Model): _columns = { 'user_id': fields.many2one('res.users', string="User", required=True), - 'badge_id': fields.many2one('gamification.badge', string='Badge'), + 'badge_id': fields.many2one('gamification.badge', string='Badge', required=True), 'comment': fields.text('Comment'), + + 'badge_name': fields.related('badge_id', 'name', type="char", string="Badge Name"), + 'create_date': fields.datetime('Created', readonly=True), + 'create_uid': fields.many2one('res.users', 'Creator', readonly=True), } @@ -196,14 +200,13 @@ result = pool.get('res.users').search(cr, uid, domain=[], context=context)""", res = None for badge_user in self.pool.get('gamification.badge.user').browse(cr, uid, badge_user_ids, context=context): - values = {'badge': badge} + values = {'badge_user': badge_user} if user_from: values['user_from'] = user_from else: values['user_from'] = False body_html = template_env.get_template('badge_received.mako').render(values) - context['badge_user'] = badge_user res = self.message_post(cr, uid, 0, body=body_html, partner_ids=[(4, badge_user.user_id.partner_id.id)], diff --git a/addons/gamification/badge_view.xml b/addons/gamification/badge_view.xml index 9ccfbf001e0..2c5d4084bcc 100644 --- a/addons/gamification/badge_view.xml +++ b/addons/gamification/badge_view.xml @@ -2,7 +2,7 @@ - + Badges gamification.badge @@ -28,6 +28,7 @@ +