[IMP] gamification: messages posted on user when receiving a badge
authorThibault Delavallée <tde@openerp.com>
Fri, 11 Apr 2014 17:57:30 +0000 (19:57 +0200)
committerThibault Delavallée <tde@openerp.com>
Fri, 11 Apr 2014 17:57:30 +0000 (19:57 +0200)
now have a subtype, to ease their search.

bzr revid: tde@openerp.com-20140411175730-hq06b7qezurzymj6

addons/gamification/data/badge.xml
addons/gamification/models/badge.py

index 5a390be..33d02bf 100644 (file)
@@ -23,7 +23,6 @@
             <field name="active" eval="False" />
         </record>
 
-
         <record id="badge_idea" model="gamification.badge">
             <field name="name">Brilliant</field>
             <field name="description">With your brilliant ideas, you are an inspiration to others.</field>
             <field name="rule_max_number">2</field>
             <field name="image" type="base64" file="gamification/static/img/badge_idea-image.png"/>
         </record>
+
+        <!-- subtype for badge allocation -->
+        <record id="mt_badge_granted" model="mail.message.subtype">
+            <field name="name">Badge Granted</field>
+            <field name="res_model">res.users</field>
+            <field name="default" eval="True"/>
+            <field name="hidden" eval="True"/>
+            <field name="description">Badge Granted</field>
+        </record>
+
     </data>
 
 
index 4ecc116..d8a3ef1 100644 (file)
@@ -63,7 +63,12 @@ class gamification_badge_user(osv.Model):
         template_id = self.pool['ir.model.data'].get_object(cr, uid, 'gamification', 'email_template_badge_received', context)
         for badge_user in self.browse(cr, uid, ids, context=context):
             body_html = temp_obj.render_template(cr, uid, template_id.body_html, 'gamification.badge.user', badge_user.id, context=context)
-            res = user_obj.message_post(cr, uid, badge_user.user_id.id, body=body_html, partner_ids=[badge_user.user_id.partner_id.id], context=context)
+            res = user_obj.message_post(
+                cr, uid, badge_user.user_id.id,
+                body=body_html,
+                subtype='gamification.mt_badge_granted',
+                partner_ids=[badge_user.user_id.partner_id.id],
+                context=context)
         return res
 
     def create(self, cr, uid, vals, context=None):