summaryrefslogtreecommitdiff
path: root/addons/email_template
diff options
context:
space:
mode:
authorChristophe Simonis <chs@openerp.com>2014-04-24 15:45:33 +0200
committerChristophe Simonis <chs@openerp.com>2014-04-24 15:45:33 +0200
commit7a7d7febf8d51cdc693e77678fc9eaee3864b3b2 (patch)
treed2bb635b1441f04267727e39a4bfbd219a4b7b6b /addons/email_template
parent96b9d8b9d59dc7b240a096e6c6775c7a45ac88c4 (diff)
parent52cfc16c2e2f33395a53b255825a8153ec80ce40 (diff)
[MERGE] forward port of branch saas-3 up to revid 9429 chs@openerp.com-20140424123538-rxk9got9k2on1ki1
bzr revid: chs@openerp.com-20140424131824-4ksluvhnegp7kplb bzr revid: chs@openerp.com-20140424134533-lhhcd32n3s0m9cqk
Diffstat (limited to 'addons/email_template')
-rw-r--r--addons/email_template/email_template.py5
-rw-r--r--addons/email_template/tests/test_mail.py4
-rw-r--r--addons/email_template/wizard/mail_compose_message.py13
3 files changed, 15 insertions, 7 deletions
diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py
index dd9ed49d3ef..7321d9dca08 100644
--- a/addons/email_template/email_template.py
+++ b/addons/email_template/email_template.py
@@ -431,7 +431,7 @@ class email_template(osv.osv):
is taken from template definition)
:returns: a dict containing all relevant fields for creating a new
mail.mail entry, with one extra key ``attachments``, in the
- format expected by :py:meth:`mail_thread.message_post`.
+ format [(report_name, data)] where data is base64 encoded.
"""
if context is None:
context = {}
@@ -492,7 +492,8 @@ class email_template(osv.osv):
result, format = self.pool['report'].get_pdf(cr, uid, [res_id], report_service, context=ctx), 'pdf'
else:
result, format = openerp.report.render_report(cr, uid, [res_id], report_service, {'model': template.model}, ctx)
-
+
+ # TODO in trunk, change return format to binary to match message_post expected format
result = base64.b64encode(result)
if not report_name:
report_name = 'report.' + report_service
diff --git a/addons/email_template/tests/test_mail.py b/addons/email_template/tests/test_mail.py
index 8bc6d62017c..beda74d0853 100644
--- a/addons/email_template/tests/test_mail.py
+++ b/addons/email_template/tests/test_mail.py
@@ -62,7 +62,7 @@ class test_message_compose(TestMail):
'name': 'Pigs Template',
'subject': '${object.name}',
'body_html': '${object.description}',
- 'user_signature': True,
+ 'user_signature': False,
'attachment_ids': [(0, 0, _attachments[0]), (0, 0, _attachments[1])],
'email_to': 'b@b.b, c@c.c',
'email_cc': 'd@d.d'
@@ -157,7 +157,7 @@ class test_message_compose(TestMail):
message_pids = [partner.id for partner in compose.partner_ids]
partner_ids = [p_a_id]
self.assertEqual(compose.subject, '${object.name}', 'mail.compose.message subject incorrect')
- self.assertEqual(compose.body, '<p>${object.description}</p>', 'mail.compose.message body incorrect')
+ self.assertEqual(compose.body, '<p>${object.description}</p>', 'mail.compose.message body incorrect') # todo: check signature
self.assertEqual(set(message_pids), set(partner_ids), 'mail.compose.message partner_ids incorrect')
# 2. Post the comment, get created message
diff --git a/addons/email_template/wizard/mail_compose_message.py b/addons/email_template/wizard/mail_compose_message.py
index 676f11b23e3..7d148c87e3c 100644
--- a/addons/email_template/wizard/mail_compose_message.py
+++ b/addons/email_template/wizard/mail_compose_message.py
@@ -87,9 +87,16 @@ 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', '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', 'reply_to', 'mail_server_id']
+ 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))
+ 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