From 549da11e4055922f94fd420b1d6db0ae76a17592 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thibault=20Delavall=C3=A9e?= Date: Wed, 23 Apr 2014 17:29:26 +0200 Subject: [PATCH] [FIX] email_template: when usign the composer in mass mailing mode with a template, display the user's signature if asked by the template. The use will then be able to modify the generated content and to remove / update it if necessary; Otherwise the signature is not added in mass mailing mode, because the content of the email is based on the wizard's body, not the template one. Some rewriting in the onchange: now using a browse instead of a read. bzr revid: tde@openerp.com-20140423152926-sno0gk8lup9l442p --- addons/email_template/wizard/mail_compose_message.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 71f9947..f2dbfc1 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -92,9 +92,17 @@ class mail_compose_message(osv.TransientModel): """ - mass_mailing: we cannot render, so return the template values - normal mode: return rendered values """ if template_id and composition_mode == 'mass_mail': - fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'mail_server_id'] - template_values = self.pool.get('email.template').read(cr, uid, template_id, fields, context) - values = dict((field, template_values[field]) for field in fields if template_values.get(field)) + fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to'] + template = self.pool['email.template'].browse(cr, uid, template_id, context=context) + values = dict((field, getattr(template, field)) for field in fields if getattr(template, field)) + print values, template.user_signature + if template.attachment_ids: + values['attachment_ids'] = [att.id for att in template.attachment_ids] + if template.mail_server_id: + values['mail_server_id'] = template.mail_server_id.id + if template.user_signature and 'body_html' in values: + signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature + values['body_html'] = tools.append_content_to_html(values['body_html'], signature) elif template_id: values = self.generate_email_for_composer_batch(cr, uid, template_id, [res_id], context=context)[res_id] # transform attachments into attachment_ids; not attached to the document because this will -- 1.7.10.4