[ADD] use badge user views with comment
bzr revid: mat@openerp.com-20130318124620-gm17hn75lz9i4ohk
This commit is contained in:
parent
7744fadcb9
commit
1db95b244c
|
@ -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)],
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Goal views -->
|
||||
<!-- Badge views -->
|
||||
<record id="badge_list_action" model="ir.actions.act_window">
|
||||
<field name="name">Badges</field>
|
||||
<field name="res_model">gamification.badge</field>
|
||||
|
@ -28,6 +28,7 @@
|
|||
<group>
|
||||
<field name="user_id" />
|
||||
<field name="badge_id" invisible="1"/>
|
||||
<field name="comment" />
|
||||
</group>
|
||||
<footer>
|
||||
<button string="Grant Badge" type="object" name="action_grant_badge" class="oe_highlight" /> or
|
||||
|
@ -152,5 +153,39 @@ jspW8F2wIbhtSRr0Vf4AD6Nod0TaN4kAAAAASUVORK5CYII=" alt="got-it" /></t>
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<!-- Badge user viewss -->
|
||||
|
||||
<record id="badge_user_kanban_view" model="ir.ui.view" >
|
||||
<field name="name">Badge User Kanban View</field>
|
||||
<field name="model">gamification.badge.user</field>
|
||||
<field name="arch" type="xml">
|
||||
<kanban version="7.0" class="oe_background_grey">
|
||||
<field name="badge_name"/>
|
||||
<field name="badge_id"/>
|
||||
<field name="user_id"/>
|
||||
<field name="comment"/>
|
||||
<field name="create_date"/>
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div tclass="oe_kanban_card oe_kanban_global_click oe_kanban_goal oe_kanban_color_white">
|
||||
<div class="oe_kanban_content">
|
||||
<div class="oe_kanban_left">
|
||||
<a type="open"><img t-att-src="kanban_image('gamification.badge', 'image', record.badge_id.raw_value)" t-att-title="record.badge_name.value" width="24" height="24" /></a>
|
||||
</div>
|
||||
<h4>
|
||||
<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>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
</kanban>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
<style type="text_css">${css}</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>Congratulation, you have received the badge <strong>${badge.name}</strong> !
|
||||
<p>Congratulation, you have received the badge <strong>${badge_user.badge_id.name}</strong> !
|
||||
% if user_from
|
||||
This badge was granted by <strong>${user_from.name}</strong>.
|
||||
% endif
|
||||
</p>
|
||||
|
||||
% if badge.image
|
||||
<p><img src="cid:badge-img.png" alt="Badge ${badge.name}" /></p>
|
||||
% if badge_user.badge_id.image
|
||||
<p><img src="cid:badge-img.png" alt="Badge ${badge_user.badge_id.name}" /></p>
|
||||
% endif
|
||||
% if badge.comment
|
||||
<p><em>${badge.comment}</em></p>
|
||||
% if badge_user.comment
|
||||
<p><em>${badge_user.comment}</em></p>
|
||||
% endif
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue