[IMP] res.users in mail.thread: cleaned code and improved message_load_ids (checks body html and text for @login)
bzr revid: tde@openerp.com-20120405210412-c41g5hnk4g8ke6op
This commit is contained in:
parent
09d751796b
commit
230ae5cbdf
|
@ -52,17 +52,21 @@ class res_users(osv.osv):
|
|||
# create a welcome message to broadcast
|
||||
company_name = user.company_id.name if user.company_id else 'the company'
|
||||
message = _('%s has joined %s! You may leave him/her a message to celebrate a new arrival in the company ! You can help him/her doing its first steps on OpenERP.') % (user.name, company_name)
|
||||
self.message_append_note(cr, uid, [user.id], 'Welcome notification', message, context=context)
|
||||
self.message_broadcast(cr, uid, [user.id], 'Welcome notification', message, 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):
|
||||
""" Override of message_load_ids
|
||||
User discussion page :
|
||||
- messages posted on res.users, res_id = user.id
|
||||
- messages directly sent to user with @user_login
|
||||
"""
|
||||
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,
|
||||
for user in self.browse(cr, uid, ids, context=context):
|
||||
msg_ids += msg_obj.search(cr, uid, ['|', '|', ('body_text', 'like', '@%s' % (user.login)), ('body_html', 'like', '@%s' % (user.login)), '&', ('res_id', '=', user.id), ('model', '=', self._name)] + domain,
|
||||
limit=limit, offset=offset, context=context)
|
||||
if (ascent): msg_ids = self._message_add_ancestor_ids(cr, uid, ids, msg_ids, root_ids, context=context)
|
||||
return msg_ids
|
||||
|
|
Loading…
Reference in New Issue