From 230ae5cbdf27f415850a88a7aa8633c546ccc29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 5 Apr 2012 23:04:12 +0200 Subject: [PATCH] [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 --- addons/mail/res_users.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 4ceaebdd8fd..6c85e625e46 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -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