From 389b502b63c4ebfe5386dc8bacd5e2e5b5bdc1cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 7 Nov 2012 18:15:21 +0100 Subject: [PATCH] [FIX] mail: posting from mailboxes now correctly handles recipients of replies message. Body is now converted into html. bzr revid: tde@openerp.com-20121107171521-whwcjefpjvt91ye6 --- addons/mail/mail_thread.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index ca598ce3a93..c483fca9537 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -710,12 +710,24 @@ class mail_thread(osv.AbstractModel): def message_post_api(self, cr, uid, thread_id, body='', subject=False, parent_id=False, attachment_ids=None, context=None): """ Wrapper on message_post, used only in Chatter (JS). The purpose is to handle attachments. - # TDE FIXME: body is plaintext: convert it into html + - body is plaintext: convert it into html + - handle reply to a previous message """ - new_message_id = self.message_post(cr, uid, thread_id=thread_id, body=body, subject=subject, type='comment', - subtype='mail.mt_comment', parent_id=parent_id, context=context) + # 1. handle body + body = tools.text2html(body) - # HACK FIXME: Chatter: attachments linked to the document (not done JS-side), load the message + # 2. handle message partner_ids + if parent_id: + parent_data = self.pool.get('mail.message').browse(cr, uid, parent_id, context=context) + partner_ids = [(4, partner.id) for partner in parent_data.partner_ids] + else: + partner_ids = [] + + # 3. post message + new_message_id = self.message_post(cr, uid, thread_id=thread_id, body=body, subject=subject, type='comment', + subtype='mail.mt_comment', parent_id=parent_id, context=context, partner_ids=partner_ids) + + # 4. HACK FIXME: Chatter: attachments linked to the document (not done JS-side), load the message if attachment_ids: ir_attachment = self.pool.get('ir.attachment') mail_message = self.pool.get('mail.message')