[IMP] res.users: message_load_ids overriden, to fetch ids of messages: 1/ res_model = res.users, res_id = id 2/ body_text contains @login

bzr revid: tde@openerp.com-20120326143538-7f88qpdx7a3w7b60
This commit is contained in:
Thibault Delavallée 2012-03-26 16:35:38 +02:00
parent 75b1ab7ac7
commit 3ea533f12d
1 changed files with 11 additions and 12 deletions

View File

@ -49,15 +49,14 @@ class res_users(osv.osv):
self.message_subscribe(cr, uid, [user_id], [user_id], context=context)
return user_id
#def message_load_ids(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None):
#if context is None:
#context = {}
#msg_obj = self.pool.get('mail.message')
#msg_ids = msg_obj.search(cr, uid, ['&', ('res_id', 'in', ids), ('model', '=', self._name)] + domain,
#limit=limit, offset=offset, context=context)
#if (ascent): msg_ids = self._message_get_parent_ids(cr, uid, ids, msg_ids, root_ids, context=context)
#return msg_ids
#def message_load(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None):
#msg_ids = self.message_load_ids(cr, uid, ids, limit, offset, domain, ascent, root_ids, context=context)
#return self.pool.get('mail.message').read(cr, uid, msg_ids, context=context)
def message_load_ids(self, cr, uid, ids, limit=100, offset=0, domain=[], ascent=False, root_ids=[False], context=None):
if context is None:
context = {}
user_data = self.read(cr, uid, ids, ['id', 'login'], context=context)
msg_obj = self.pool.get('mail.message')
msg_ids = []
for x_id in range(0, len(ids)):
msg_ids += msg_obj.search(cr, uid, ['|', ('body_text', 'like', '@%s' % (user_data[x_id]['login'])), '&', ('res_id', '=', ids[x_id]), ('model', '=', self._name)] + domain,
limit=limit, offset=offset, context=context)
if (ascent): msg_ids = self._message_get_parent_ids(cr, uid, ids, msg_ids, root_ids, context=context)
return msg_ids