From 72f6a8c646179d433de11c2f26e5f589b5ad8cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Jun 2013 14:37:24 +0200 Subject: [FIX] mail.compose.message: supports user_signature of template. Note that in case of multiple wizards (send on ids that is not a singleton list), user_signature on one template is valid for all wizard. bzr revid: tde@openerp.com-20130606123724-f7q3mwm81ek7mr5c --- addons/email_template/wizard/mail_compose_message.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'addons/email_template/wizard/mail_compose_message.py') diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 7f44828ce15..6fbc541341b 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -54,18 +54,22 @@ class mail_compose_message(osv.TransientModel): 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 context is None: + context = {} + wizard_context = dict(context) for wizard in self.browse(cr, uid, ids, context=context): + if wizard.template_id and not wizard.template_id.user_signature: + wizard_context['mail_notify_user_signature'] = False # template user_signature is added when generating body_html if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id: continue - template = self.pool.get('email.template').browse(cr, uid, wizard.template_id.id, context=context) new_attachment_ids = [] for attachment in wizard.attachment_ids: - if attachment in template.attachment_ids: + if attachment in wizard.template.attachment_ids: new_attachment_ids.append(self.pool.get('ir.attachment').copy(cr, uid, attachment.id, {'res_model': 'mail.compose.message', 'res_id': wizard.id}, context=context)) else: new_attachment_ids.append(attachment.id) self.write(cr, uid, wizard.id, {'attachment_ids': [(6, 0, new_attachment_ids)]}, context=context) - return super(mail_compose_message, self).send_mail(cr, uid, ids, context=context) + return super(mail_compose_message, self).send_mail(cr, uid, ids, context=wizard_context) def onchange_template_id(self, cr, uid, ids, template_id, composition_mode, model, res_id, context=None): """ - mass_mailing: we cannot render, so return the template values -- cgit v1.2.3 From 62a03693a39a59bf1833dbed0e4aff32ee5ca8c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 6 Jun 2013 15:08:51 +0200 Subject: [FIX] mail.compose.message in email_template: var typo bzr revid: tde@openerp.com-20130606130851-h5jswklvvz98enue --- addons/email_template/wizard/mail_compose_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/email_template/wizard/mail_compose_message.py') diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 6fbc541341b..746c2cc55f6 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -64,7 +64,7 @@ class mail_compose_message(osv.TransientModel): continue new_attachment_ids = [] for attachment in wizard.attachment_ids: - if attachment in wizard.template.attachment_ids: + if attachment in wizard.template_id.attachment_ids: new_attachment_ids.append(self.pool.get('ir.attachment').copy(cr, uid, attachment.id, {'res_model': 'mail.compose.message', 'res_id': wizard.id}, context=context)) else: new_attachment_ids.append(attachment.id) -- cgit v1.2.3 From f8480b69be0cf4fa9e748fee783c3d2dee8a72a0 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 16 Jul 2013 11:59:28 +0200 Subject: [FIX]email_template: generate_email_for_composer, clean context before find or create partner, to avoid default values for partner bzr revid: dle@openerp.com-20130716095928-z79ipwgjxw5ypg3y --- addons/email_template/wizard/mail_compose_message.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/email_template/wizard/mail_compose_message.py') diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 2e051338352..2f1e266848e 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -147,8 +147,9 @@ class mail_compose_message(osv.TransientModel): # transform email_to, email_cc into partner_ids partner_ids = set() mails = tools.email_split(values.pop('email_to', '') + ' ' + values.pop('email_cc', '')) + ctx = dict((k, v) for k, v in (context or {}).items() if not k.startswith('default_')) for mail in mails: - partner_id = self.pool.get('res.partner').find_or_create(cr, uid, mail, context=context) + partner_id = self.pool.get('res.partner').find_or_create(cr, uid, mail, context=ctx) partner_ids.add(partner_id) email_recipients = values.pop('email_recipients', '') if email_recipients: -- cgit v1.2.3 From f1f2b2ba06c6b62c886b7dea13118687e9b93b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Mon, 22 Jul 2013 15:17:25 +0200 Subject: [IMP] mail: mail.message now has mail_server_id from template_id. bzr revid: tde@openerp.com-20130722131725-i30xd4b03nui3hyw --- addons/email_template/wizard/mail_compose_message.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'addons/email_template/wizard/mail_compose_message.py') diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index 746c2cc55f6..92bf7c3aedf 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -22,6 +22,7 @@ from openerp import tools from openerp.osv import osv, fields + def _reopen(self, res_id, model): return {'type': 'ir.actions.act_window', 'view_mode': 'form', @@ -34,7 +35,8 @@ def _reopen(self, res_id, model): 'context': { 'default_model': model, }, - } + } + class mail_compose_message(osv.TransientModel): _inherit = 'mail.compose.message' @@ -58,7 +60,7 @@ class mail_compose_message(osv.TransientModel): context = {} wizard_context = dict(context) for wizard in self.browse(cr, uid, ids, context=context): - if wizard.template_id and not wizard.template_id.user_signature: + if wizard.template_id: wizard_context['mail_notify_user_signature'] = False # template user_signature is added when generating body_html if not wizard.attachment_ids or wizard.composition_mode == 'mass_mail' or not wizard.template_id: continue @@ -75,7 +77,7 @@ 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'] + 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)) elif template_id: @@ -95,7 +97,7 @@ class mail_compose_message(osv.TransientModel): } values['attachment_ids'].append(ir_attach_obj.create(cr, uid, data_attach, context=context)) else: - values = self.default_get(cr, uid, ['subject', 'body', 'email_from', 'email_to', 'email_cc', 'partner_to', 'reply_to', 'attachment_ids'], context=context) + values = self.default_get(cr, uid, ['subject', 'body', 'email_from', 'email_to', 'email_cc', 'partner_to', 'reply_to', 'attachment_ids', 'mail_server_id'], context=context) if values.get('body_html'): values['body'] = values.pop('body_html') @@ -150,7 +152,7 @@ class mail_compose_message(osv.TransientModel): mail.compose.message, transform email_cc and email_to into partner_ids """ template_values = self.pool.get('email.template').generate_email(cr, uid, template_id, res_id, context=context) # filter template values - fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'attachments'] + fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'attachments', 'mail_server_id'] values = dict((field, template_values[field]) for field in fields if template_values.get(field)) values['body'] = values.pop('body_html', '') -- cgit v1.2.3