summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/models/mail_thread.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2017-07-18 19:00:08 +0200
committerChristophe Simonis <chs@odoo.com>2017-07-18 19:00:08 +0200
commit12fdf46a5b6a73d5141f0fc6bbce754dbf84cce8 (patch)
treee4911ef96264650fd1bc8ab235b67443c055b7c3 /addons/mass_mailing/models/mail_thread.py
parentb237c3e25e7547f7e04e0b0d3e9d6ce6a9e926cc (diff)
[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)
Diffstat (limited to 'addons/mass_mailing/models/mail_thread.py')
-rw-r--r--addons/mass_mailing/models/mail_thread.py10
1 files changed, 10 insertions, 0 deletions
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)