diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 7e03bca9caa..fdcc1e73ec5 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -368,8 +368,10 @@ class mail_message(osv.Model): :param list domain: optional domain for searching ids if ids not set :param list message_unload_ids: optional ids we do not want to fetch, because i.e. they are already displayed somewhere - :param int parent_id: if parent_id reached when adding ancestors, - stop going further in the ancestor search + :param int parent_id: context of parent_id + - if parent_id reached when adding ancestors, stop going further + in the ancestor search + - if set in flat mode, ancestor_id is set to parent_id :param int limit: number of messages to fetch, before adding the ancestors and expandables :return list: list of message structure for the Chatter widget @@ -400,13 +402,16 @@ class mail_message(osv.Model): message_list.append(self._message_get_dict(cr, uid, message, context=context)) # get the older ancestor the user can read, update its ancestor field + if not thread_level: + message_list[-1]['ancestor_id'] = parent_id + continue parent = self._get_parent(cr, uid, message, context=context) while parent and parent.get('id') != parent_id: message_list[-1]['ancestor_id'] = parent.get('id') message = parent parent = self._get_parent(cr, uid, message, context=context) # if in thread: add its ancestor to the list of messages - if thread_level and not read_messages.get(message.get('id')) and message.get('id') not in message_unload_ids: + if not read_messages.get(message.get('id')) and message.get('id') not in message_unload_ids: read_messages[message.get('id')] = message message_list.append(self._message_get_dict(cr, uid, message, context=context))