diff options
| author | Thibault Delavallée <tde@openerp.com> | 2014-02-27 16:38:35 +0100 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2014-02-27 16:38:35 +0100 |
| commit | a9a4767d17650320cba710ce99b6c737419df7c7 (patch) | |
| tree | ee478aaea603d5fe0df2636896a7b287d42ac208 /addons/website_mail/models | |
| parent | b1f88d634d603b74a62d051032e4003fc6f7a3b1 (diff) | |
[FIX] email_template :
- fixed composer using template that were rendering the body twice, once form the template and
once from the composer body. Only the latter one is used, so avoid generating the template body
that is not necessary
- fixed email_template generating values for a set of given fields, ignoring the field list
given into parameter
- fixed post processing of templates to transform local urls into absolute urls; now urls are
transformed after body generation, when sending email based on templates , or when generating
the content when using the composer.
bzr revid: tde@openerp.com-20140227153835-gmqnxrzed9fnbxhm
Diffstat (limited to 'addons/website_mail/models')
| -rw-r--r-- | addons/website_mail/models/__init__.py | 1 | ||||
| -rw-r--r-- | addons/website_mail/models/email_template.py | 16 | ||||
| -rw-r--r-- | addons/website_mail/models/mail_compose_message.py | 34 |
3 files changed, 42 insertions, 9 deletions
diff --git a/addons/website_mail/models/__init__.py b/addons/website_mail/models/__init__.py index e60de014149..3e374ccddd2 100644 --- a/addons/website_mail/models/__init__.py +++ b/addons/website_mail/models/__init__.py @@ -1,3 +1,4 @@ import mail_message import mail_thread import email_template +import mail_compose_message
\ No newline at end of file diff --git a/addons/website_mail/models/email_template.py b/addons/website_mail/models/email_template.py index aed01c179f7..105fcff4428 100644 --- a/addons/website_mail/models/email_template.py +++ b/addons/website_mail/models/email_template.py @@ -79,12 +79,10 @@ class EmailTemplate(osv.Model): html = html[5:-6] return html - def create(self, cr, uid, values, context=None): - if 'body_html' in values: - values['body_html'] = self._postprocess_html_replace_links(cr, uid, values['body_html'], context=context) - return super(EmailTemplate, self).create(cr, uid, values, context=context) - - def write(self, cr, uid, ids, values, context=None): - if 'body_html' in values: - values['body_html'] = self._postprocess_html_replace_links(cr, uid, values['body_html'], context=context) - return super(EmailTemplate, self).write(cr, uid, ids, values, context=context) + def generate_email_batch(self, cr, uid, template_id, res_ids, context=None, fields=None): + """ Add a post processing after rendering, aka replace local URLs to absolute URLs. """ + results = super(EmailTemplate, self).generate_email_batch(cr, uid, template_id, res_ids, context=context, fields=fields) + for res_id, value in results.iteritems(): + if 'body_html' in value: + results[res_id]['body_html'] = self._postprocess_html_replace_links(cr, uid, value['body_html'], context=context) + return results diff --git a/addons/website_mail/models/mail_compose_message.py b/addons/website_mail/models/mail_compose_message.py new file mode 100644 index 00000000000..bc8258bbb6f --- /dev/null +++ b/addons/website_mail/models/mail_compose_message.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2014-Today OpenERP SA (<http://www.openerp.com>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from openerp.osv import osv + + +class MailComposeMessage(osv.Model): + _inherit = 'mail.compose.message' + + def generate_email_for_composer_batch(self, cr, uid, template_id, res_ids, context=None, fields=None): + """ Add a post processing after rendering, aka replace local URLs to absolute URLs. """ + results = super(MailComposeMessage, self).generate_email_for_composer_batch(cr, uid, template_id, res_ids, context=context, fields=fields) + for res_id, value in results.iteritems(): + if 'body' in value: + results[res_id]['body'] = self.pool['email.template']._postprocess_html_replace_links(cr, uid, value['body'], context=context) + return results |
