From fc1348dd3d73c2a5fbcc043f75b00272fedd6b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 3 Jan 2018 15:56:42 +0100 Subject: [PATCH] [REM] mail: remove unnecessary methods from mail.thread * one dead method; * one unnecessary method to inline; * one unnecessary wrapper; --- addons/mail/controllers/main.py | 3 +-- addons/mail/models/mail_thread.py | 25 +++------------------- addons/mail/wizard/mail_compose_message.py | 6 ++++-- 3 files changed, 8 insertions(+), 26 deletions(-) diff --git a/addons/mail/controllers/main.py b/addons/mail/controllers/main.py index f2568685da0..a3e9a10ced9 100644 --- a/addons/mail/controllers/main.py +++ b/addons/mail/controllers/main.py @@ -22,8 +22,7 @@ class MailController(http.Controller): @classmethod def _redirect_to_messaging(cls): - messaging_action = request.env['mail.thread']._get_inbox_action_xml_id() - url = '/web#%s' % url_encode({'action': messaging_action}) + url = '/web#%s' % url_encode({'action': 'mail.mail_channel_action_client_chat'}) return werkzeug.utils.redirect(url) @classmethod diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 317efc6d09d..1131f1fe570 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -554,13 +554,6 @@ class MailThread(models.AbstractModel): DocModel.check_access_rights(check_operation) DocModel.browse(res_ids).check_access_rule(check_operation) - @api.model - def _get_inbox_action_xml_id(self): - """ When redirecting towards the Inbox, choose which action xml_id has - to be fetched. This method is meant to be inherited, at least in portal - because portal users have a different Inbox action than classic users. """ - return 'mail.mail_channel_action_client_chat' - @api.model def _generate_notification_token(self, base_link, params): secret = self.env['ir.config_parameter'].sudo().get_param('database.secret') @@ -808,15 +801,6 @@ class MailThread(models.AbstractModel): # Mail gateway # ------------------------------------------------------ - @api.model - def message_capable_models(self): - """ Used by the plugin addon, based for plugin_outlook and others. """ - ret_dict = {} - for model_name, model in self.env.items(): - if hasattr(model, "message_process") and hasattr(model, "message_post"): - ret_dict[model_name] = model._description - return ret_dict - def _message_find_partners(self, message, header_fields=['From']): """ Find partners related to some header fields of the message. @@ -1705,18 +1689,15 @@ class MailThread(models.AbstractModel): ]).write({'author_id': partner_info['partner_id']}) return result - def _message_preprocess_attachments(self, attachments, attachment_ids, attach_model, attach_res_id): + def _message_post_process_attachments(self, attachments, attachment_ids, message_data): """ Preprocess attachments for mail_thread.message_post() or mail_mail.create(). :param list attachments: list of attachment tuples in the form ``(name,content)``, where content is NOT base64 encoded :param list attachment_ids: a list of attachment ids, not in tomany command form - :param str attach_model: the model of the attachments parent record - :param integer attach_res_id: the id of the attachments parent record + :param dict message_data: model: the model of the attachments parent record, + res_id: the id of the attachments parent record """ - return self._message_post_process_attachments(attachments, attachment_ids, {'model': attach_model, 'res_id': attach_res_id}) - - def _message_post_process_attachments(self, attachments, attachment_ids, message_data): IrAttachment = self.env['ir.attachment'] m2m_attachment_ids = [] cid_mapping = {} diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 0d91879224e..db46e76d5c8 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -325,9 +325,11 @@ class MailComposer(models.TransientModel): for attach_id in mail_values.pop('attachment_ids'): new_attach_id = self.env['ir.attachment'].browse(attach_id).copy({'res_model': self._name, 'res_id': self.id}) attachment_ids.append(new_attach_id.id) - mail_values['attachment_ids'] = self.env['mail.thread']._message_preprocess_attachments( + mail_values['attachment_ids'] = self.env['mail.thread']._message_post_process_attachments( mail_values.pop('attachments', []), - attachment_ids, 'mail.message', 0) + attachment_ids, + {'model': 'mail.message', 'res_id': 0} + ) results[res_id] = mail_values return results