diff options
| author | Thibault Delavallée <tde@openerp.com> | 2014-03-04 12:29:57 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2014-03-04 12:29:57 +0100 |
| commit | db2bdee34349f5ceef06cbdde247c66fd001c18a (patch) | |
| tree | bdc7f454c50030c407ead8ef066fb89939218ee5 /addons/email_template/wizard/mail_compose_message.py | |
| parent | e78a3b18cc6c049a712d594ab70287c486447f0a (diff) | |
| parent | d417da6c1a64c6c51aa2c734e31e1360ad4f434e (diff) | |
MERGE] [FIX] email_template: fix relative -> absolute url conversion
Local URLs are converted into absolute URLs, notably because when using the
email designer, images are added using local URLs. Previously to this fix
the template was analyzed to find local URLs and make them absolute.
However this causes 2 issues :
- mako-based URLs are broken because a scheme is added before the mako that
generated the image src
- when changing the base url, the templates are not updated
The URLs are now converted dynamically when generating the content of the
html. This is done by passing a new parameter that enable the post processing
of the generated content.
Also fixed double body generation when using templates; fields parameter
was not propagated correctly.
bzr revid: tde@openerp.com-20140304112957-l9b10gyjqphs5fgc
Diffstat (limited to 'addons/email_template/wizard/mail_compose_message.py')
| -rw-r--r-- | addons/email_template/wizard/mail_compose_message.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py index beede1122dc..71f99471afa 100644 --- a/addons/email_template/wizard/mail_compose_message.py +++ b/addons/email_template/wizard/mail_compose_message.py @@ -162,16 +162,18 @@ class mail_compose_message(osv.TransientModel): partner_ids += self.pool['res.partner'].exists(cr, SUPERUSER_ID, tpl_partner_ids, context=context) return partner_ids - def generate_email_for_composer_batch(self, cr, uid, template_id, res_ids, context=None): + def generate_email_for_composer_batch(self, cr, uid, template_id, res_ids, context=None, fields=None): """ Call email_template.generate_email(), get fields relevant for mail.compose.message, transform email_cc and email_to into partner_ids """ # filter template values - fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'attachments', 'mail_server_id'] + if fields is None: + fields = ['subject', 'body_html', 'email_from', 'email_to', 'partner_to', 'email_cc', 'reply_to', 'attachment_ids', 'mail_server_id'] + returned_fields = fields + ['attachments'] values = dict.fromkeys(res_ids, False) - template_values = self.pool.get('email.template').generate_email_batch(cr, uid, template_id, res_ids, context=context) + template_values = self.pool.get('email.template').generate_email_batch(cr, uid, template_id, res_ids, fields=fields, context=context) for res_id in res_ids: - res_id_values = dict((field, template_values[res_id][field]) for field in fields if template_values[res_id].get(field)) + res_id_values = dict((field, template_values[res_id][field]) for field in returned_fields if template_values[res_id].get(field)) res_id_values['body'] = res_id_values.pop('body_html', '') # transform email_to, email_cc into partner_ids @@ -189,7 +191,10 @@ class mail_compose_message(osv.TransientModel): """ Override to handle templates. """ # generate template-based values if wizard.template_id: - template_values = self.generate_email_for_composer_batch(cr, uid, wizard.template_id.id, res_ids, context=context) + template_values = self.generate_email_for_composer_batch( + cr, uid, wizard.template_id.id, res_ids, + fields=['email_to', 'partner_to', 'email_cc', 'attachment_ids', 'mail_server_id'], + context=context) else: template_values = dict.fromkeys(res_ids, dict()) # generate composer values @@ -206,8 +211,8 @@ class mail_compose_message(osv.TransientModel): template_values[res_id].update(composer_values[res_id]) return template_values - def render_template_batch(self, cr, uid, template, model, res_ids, context=None): - return self.pool.get('email.template').render_template_batch(cr, uid, template, model, res_ids, context=context) + def render_template_batch(self, cr, uid, template, model, res_ids, context=None, post_process=False): + return self.pool.get('email.template').render_template_batch(cr, uid, template, model, res_ids, context=context, post_process=post_process) # Compatibility methods def generate_email_for_composer(self, cr, uid, template_id, res_id, context=None): |
