From 1ab87ddd677d230f254dcfe8075df1a655e3efc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Fri, 21 Dec 2012 15:52:47 +0100 Subject: [PATCH] [CLEAN] Misc code cleaning. bzr revid: tde@openerp.com-20121221145247-qqd1a1morv99ooow --- addons/mail/mail_thread.py | 19 +++++++++---------- addons/mail/res_users.py | 6 ++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 6925128f689..943e5a011ea 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -886,9 +886,9 @@ class mail_thread(osv.AbstractModel): return mail_message.create(cr, uid, values, context=context) - def message_post_user_api(self, cr, uid, thread_id, body='', subject=False, - parent_id=False, attachment_ids=None, extra_emails=None, - context=None, content_subtype='plaintext', **kwargs): + def message_post_user_api(self, cr, uid, thread_id, body='', parent_id=False, + attachment_ids=None, extra_emails=None, content_subtype='plaintext', + context=None, **kwargs): """ Wrapper on message_post, used for user input : - mail gateway - quick reply in Chatter (refer to mail.js), not @@ -933,8 +933,8 @@ class mail_thread(osv.AbstractModel): # 1.B: handle body, message_type and message_subtype if content_subtype == 'plaintext': body = tools.plaintext2html(body) - message_type = kwargs.pop('type', 'comment') - message_subtype = kwargs.pop('subtype', 'mail.mt_comment') + msg_type = kwargs.pop('type', 'comment') + msg_subtype = kwargs.pop('subtype', 'mail.mt_comment') # 2. Pre-processing: attachments # HACK TDE FIXME: Chatter: attachments linked to the document (not done JS-side), load the message @@ -954,13 +954,12 @@ class mail_thread(osv.AbstractModel): ir_attachment.write(cr, SUPERUSER_ID, attachment_ids, {'res_model': model, 'res_id': thread_id}, context=context) else: attachment_ids = [] + attachment_ids = [(4, id) for id in attachment_ids] # 3. Post message - new_message_id = self.message_post(cr, uid, thread_id=thread_id, body=body, subject=subject, - type=message_type, subtype=message_subtype, parent_id=parent_id, - attachment_ids=[(4, id) for id in attachment_ids], partner_ids=partner_ids, - context=context, **kwargs) - return new_message_id + return self.message_post(cr, uid, thread_id=thread_id, body=body, + type=msg_type, subtype=msg_subtype, parent_id=parent_id, + attachment_ids=attachment_ids, partner_ids=partner_ids, context=context, **kwargs) #------------------------------------------------------ # Followers API diff --git a/addons/mail/res_users.py b/addons/mail/res_users.py index 6c7fe712652..4f87b9d51dc 100644 --- a/addons/mail/res_users.py +++ b/addons/mail/res_users.py @@ -127,16 +127,14 @@ class res_users(osv.Model): def message_post_user_api(self, cr, uid, thread_id, body='', context=None, **kwargs): """ Redirect the posting of message on res.users to the related partner. This is done because when giving the context of Chatter on the - various mailboxes, we do not have access to the current partner_id. - We therefore post on the user and redirect on its partner. """ + various mailboxes, we do not have access to the current partner_id. """ partner_id = self._message_post_get_pid(cr, uid, thread_id, context=context) return self.pool.get('res.partner').message_post_user_api(cr, uid, partner_id, **kwargs) def message_post(self, cr, uid, thread_id, context=None, **kwargs): """ Redirect the posting of message on res.users to the related partner. This is done because when giving the context of Chatter on the - various mailboxes, we do not have access to the current partner_id. - We therefore post on the user and redirect on its partner. """ + various mailboxes, we do not have access to the current partner_id. """ partner_id = self._message_post_get_pid(cr, uid, thread_id, context=context) return self.pool.get('res.partner').message_post(cr, uid, partner_id, context=context, **kwargs)