From b783e25a1d306a97676db35481663c17d5c8fd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Tue, 8 Dec 2015 16:58:07 +0100 Subject: [PATCH] [FIX] mail: template signature duplicated When using a template adding the signature, do not re-add it when posting the message on a document. For example the Sale Order - Send by Email templates generated two signature in the email. This issue has been introduced when migrating mail to the new API. --- addons/mail/wizard/mail_compose_message.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index cebd729d301..6ea72c16ed5 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -195,15 +195,10 @@ class MailComposer(models.TransientModel): """ Process the wizard content and proceed with sending the related email(s), rendering any template patterns on the fly if needed. """ for wizard in self: - Mail = self.env['mail.mail'] # Duplicate attachments linked to the email.template. # Indeed, basic mail.compose.message wizard duplicates attachments in mass # mailing mode. But in 'single post' mode, attachments of an email template # also have to be duplicated to avoid changing their ownership. - if wizard.template_id: - # template user_signature is added when generating body_html - # mass mailing: use template auto_delete value -> note, for emails mass mailing only - Mail = Mail.with_context(mail_notify_user_signature=False, mail_auto_delete=wizard.template_id.auto_delete, mail_server_id=wizard.template_id.mail_server_id.id) if wizard.attachment_ids and wizard.composition_mode != 'mass_mail' and wizard.template_id: new_attachment_ids = [] for attachment in wizard.attachment_ids: @@ -215,7 +210,14 @@ class MailComposer(models.TransientModel): # Mass Mailing mass_mode = wizard.composition_mode in ('mass_mail', 'mass_post') + + Mail = self.env['mail.mail'] ActiveModel = self.env[wizard.model if wizard.model else 'mail.thread'] + if wizard.template_id: + # template user_signature is added when generating body_html + # mass mailing: use template auto_delete value -> note, for emails mass mailing only + Mail = Mail.with_context(mail_notify_user_signature=False, mail_auto_delete=wizard.template_id.auto_delete, mail_server_id=wizard.template_id.mail_server_id.id) + ActiveModel = ActiveModel.with_context(mail_notify_user_signature=False) if not hasattr(ActiveModel, 'message_post'): ActiveModel = self.env['mail.thread'].with_context(thread_model=wizard.model) if wizard.composition_mode == 'mass_post':