'Post-processing on values given by message_read. This method will
handle partners in batch to avoid doing numerous queries.
:param list messages: list of message, as get_dict result
:param dict message_tree: {[msg.id]: msg browse record as super user}'

@api.model
def _message_read_dict_postprocess(self, messages, message_tree):

    partners = self.env['res.partner'].sudo()
    attachments = self.env['ir.attachment']
    trackings = self.env['mail.tracking.value']
    for (key, message) in message_tree.iteritems():
        if message.author_id:
            partners |= message.author_id
        if (message.subtype_id and message.partner_ids):
            partners |= message.partner_ids
        elif ((not message.subtype_id) and message.partner_ids):
            partners |= message.partner_ids
        if message.needaction_partner_ids:
            partners |= message.needaction_partner_ids
        if message.attachment_ids:
            attachments |= message.attachment_ids
        if message.tracking_value_ids:
            trackings |= message.tracking_value_ids
    partners_names = partners.name_get()
    partner_tree = dict(((partner[0], partner) for partner in partners_names))
    attachments_data = attachments.sudo().read(['id', 'datas_fname', 'name', 'mimetype'])
    attachments_tree = dict(((attachment['id'], {'id': attachment['id'], 'filename': attachment['datas_fname'], 'name': attachment['name'], 'mimetype': attachment['mimetype']}) for attachment in attachments_data))
    tracking_tree = dict(((tracking.id, {'id': tracking.id, 'changed_field': tracking.field_desc, 'old_value': tracking.get_old_display_value()[0], 'new_value': tracking.get_new_display_value()[0], 'field_type': tracking.field_type}) for tracking in trackings))
    for message_dict in messages:
        message_id = message_dict.get('id')
        message = message_tree[message_id]
        if message.author_id:
            author = partner_tree[message.author_id.id]
        else:
            author = (0, message.email_from)
        partner_ids = []
        if message.subtype_id:
            partner_ids = [partner_tree[partner.id] for partner in message.partner_ids if (partner.id in partner_tree)]
        else:
            partner_ids = [partner_tree[partner.id] for partner in message.partner_ids if (partner.id in partner_tree)]
        customer_email_data = []
        for notification in message.notification_ids.filtered((lambda notif: (notif.res_partner_id.partner_share and notif.res_partner_id.active))):
            customer_email_data.append((partner_tree[notification.res_partner_id.id][0], partner_tree[notification.res_partner_id.id][1], notification.email_status))
        attachment_ids = []
        for attachment in message.attachment_ids:
            if (attachment.id in attachments_tree):
                attachment_ids.append(attachments_tree[attachment.id])
        tracking_value_ids = []
        for tracking_value in message.tracking_value_ids:
            if (tracking_value.id in tracking_tree):
                tracking_value_ids.append(tracking_tree[tracking_value.id])
        message_dict.update({'author_id': author, 'partner_ids': partner_ids, 'customer_email_status': ((all(((d[2] == 'sent') for d in customer_email_data)) and 'sent') or (any(((d[2] == 'exception') for d in customer_email_data)) and 'exception') or (any(((d[2] == 'bounce') for d in customer_email_data)) and 'bounce') or 'ready'), 'customer_email_data': customer_email_data, 'attachment_ids': attachment_ids, 'tracking_value_ids': tracking_value_ids})
    return True
