From 12a3bacf8ca65b4060d2108c1b9abe751f18ca9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 25 Oct 2012 09:51:10 +0200 Subject: [PATCH] [FIX] message_read: giving ids is now just a way to avoid using the domain; everything else is the same. bzr revid: tde@openerp.com-20121025075110-3re19dkvyxix8q76 --- addons/mail/mail_message.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index a649c04ad29..c6895c3acc1 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -352,7 +352,7 @@ class mail_message(osv.Model): except (orm.except_orm, osv.except_osv): return False - def message_read(self, cr, uid, ids=False, domain=None, message_unload_ids=None, thread_level=0, context=None, parent_id=False, limit=None): + def message_read(self, cr, uid, ids=None, domain=None, message_unload_ids=None, thread_level=0, context=None, parent_id=False, limit=None): """ Read messages from mail.message, and get back a list of structured messages to be displayed as discussion threads. If IDs is set, fetch these records. Otherwise use the domain to fetch messages. @@ -385,16 +385,10 @@ class mail_message(osv.Model): read_messages = {} message_list = [] - # specific IDs given: fetch those ids and return directly the message list - if ids: - for message in self.read(cr, uid, ids, self._message_read_fields, context=context): - message_list.append(self._message_get_dict(cr, uid, message, context=context)) - message_list = sorted(message_list, key=lambda k: k['id']) - return message_list - # TDE FIXME: check access rights on search are implemented for mail.message - # fetch messages according to the domain, add their parents if uid has access to - ids = self.search(cr, uid, domain, context=context, limit=limit) + # no specific IDS given: fetch messages according to the domain, add their parents if uid has access to + if ids is None: + ids = self.search(cr, uid, domain, context=context, limit=limit) for message in self.read(cr, uid, ids, self._message_read_fields, context=context): # if not in tree and not in message_loaded list if not read_messages.get(message.get('id')) and message.get('id') not in message_unload_ids: