From 12fdf46a5b6a73d5141f0fc6bbce754dbf84cce8 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 18 Jul 2017 19:00:08 +0200 Subject: [PATCH] [FIX] mass_mailing: avoid creating mass mailing for messages posts In case a default value is set for the field `mass_mailing_name` of the mail composer, the automatic messages sent via message_post_with_* are considered as a mass mailing. It may also create an AccessError if the current user is not a mass mailing user. In the case of the "assign user" email (for auto-subscribed users), the url wasn't shorten, which resulted in invalid links (opw-752941) (fixed by 3228694bddff75a9c04504f09b6da56c5f5a5647) --- addons/mass_mailing/models/mail_thread.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/mass_mailing/models/mail_thread.py b/addons/mass_mailing/models/mail_thread.py index 066dd285c79..da886569962 100644 --- a/addons/mass_mailing/models/mail_thread.py +++ b/addons/mass_mailing/models/mail_thread.py @@ -39,3 +39,13 @@ class MailThread(models.AbstractModel): message_ids = [x.strip() for x in decode_smtp_header(message['References']).split()] self.env['mail.mail.statistics'].set_replied(mail_message_ids=message_ids) return super(MailThread, self).message_route_process(message, message_dict, routes) + + @api.multi + def message_post_with_template(self, template_id, **kwargs): + # avoid having message send through `message_post*` methods being implicitly considered as + # mass-mailing + no_massmail = self.with_context( + default_mass_mailing_name=False, + default_mass_mailing_id=False, + ) + return super(MailThread, no_massmail).message_post_with_template(template_id, **kwargs)