[REF] gamification: compute_code is now similar to ir.actions, cleanup code

bzr revid: mat@openerp.com-20131224130023-e4gc91ell38zdtfj
This commit is contained in:
Martin Trigaux
2013-12-24 14:00:23 +01:00
parent 6f5815f44d
commit aefd64e8cf
6 changed files with 57 additions and 56 deletions
+1 -1
View File
@@ -61,7 +61,7 @@
<field name="name">Mail Group Following</field>
<field name="description">Follow mail groups to receive news</field>
<field name="computation_mode">python</field>
<field name="compute_code">self.number_following(cr, uid, 'mail.group')</field>
<field name="compute_code">result = pool.get('mail.followers').search(cr, uid, [('res_model', '=', 'mail.group'), ('partner_id', '=', object.user_id.partner_id.id)], count=True, context=context)</field>
<field name="action_id" eval="ref('mail.action_view_groups')" />
</record>
@@ -30,12 +30,3 @@ class gamification_goal_definition_data(osv.Model):
of a user's goal. The return definition must be a float or integer.
"""
_inherit = 'gamification.goal.definition'
def number_following(self, cr, uid, xml_id="mail.thread", context=None):
"""Return the number of 'xml_id' objects the user is following
The model specified in 'xml_id' must inherit from mail.thread
"""
ref_obj = self.pool.get(xml_id)
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return ref_obj.search(cr, uid, [('message_follower_ids', '=', user.partner_id.id)], count=True, context=context)