summaryrefslogtreecommitdiff
path: root/addons/mail/models
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-09-28 16:28:31 +0200
committerChristophe Simonis <chs@odoo.com>2016-09-28 16:28:31 +0200
commita7ba6cde9c7951fa54cf031deb3bebc8d511bf95 (patch)
tree89e2e1f62bc3973dde713099af357a33264256dd /addons/mail/models
parentd04a42022b2338d529d245080fa506f72cdc8daa (diff)
parent7134affc89c3ad04b365e64b49b911c8bc3f433e (diff)
[MERGE] forward port branch saas-12 up to 7134aff
Diffstat (limited to 'addons/mail/models')
-rw-r--r--addons/mail/models/mail_template.py2
-rw-r--r--addons/mail/models/mail_thread.py13
2 files changed, 10 insertions, 5 deletions
diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py
index 8508fa9f250..d87cad5fec7 100644
--- a/addons/mail/models/mail_template.py
+++ b/addons/mail/models/mail_template.py
@@ -488,7 +488,7 @@ class MailTemplate(models.Model):
)
# Add report in attachments: generate once for all template_res_ids
- if template.report_template and not 'report_template_in_attachment' in self.env.context:
+ if template.report_template:
for res_id in template_res_ids:
attachments = []
report_name = self.render_template(template.report_name, template.model, res_id)
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py
index 7363bf6510b..6af6a2206f4 100644
--- a/addons/mail/models/mail_thread.py
+++ b/addons/mail/models/mail_thread.py
@@ -1692,12 +1692,14 @@ class MailThread(models.AbstractModel):
m2m_attachment_ids += [(4, id) for id in attachment_ids]
# Handle attachments parameter, that is a dictionary of attachments
for attachment in attachments:
+ cid = False
if len(attachment) == 2:
name, content = attachment
elif len(attachment) == 3:
name, content, info = attachment
if info and info.get('cid'):
- cid_mapping[info['cid']] = name
+ cid = info['cid']
+ cid_mapping[cid] = name
else:
continue
if isinstance(content, unicode):
@@ -1705,7 +1707,7 @@ class MailThread(models.AbstractModel):
data_attach = {
'name': name,
'datas': base64.b64encode(str(content)),
- 'datas_fname': name,
+ 'datas_fname': cid or name,
'description': name,
'res_model': message_data['model'],
'res_id': message_data['res_id'],
@@ -1718,8 +1720,11 @@ class MailThread(models.AbstractModel):
postprocessed = False
for node in root.iter('img'):
if node.get('src', '').startswith('cid:'):
- fname = cid_mapping.get(node.get('src').split('cid:')[1], node.get('data-filename', ''))
- attachment = parameter_attachments.filtered(lambda attachment: attachment.name == fname)
+ cid = node.get('src').split('cid:')[1]
+ fname = cid_mapping.get(cid, node.get('data-filename', ''))
+ attachment = parameter_attachments.filtered(lambda attachment: attachment.datas_fname == cid)
+ if not attachment:
+ attachment = parameter_attachments.filtered(lambda attachment: attachment.datas_fname == fname)
if attachment:
node.set('src', '/web/image/%s' % attachment.ids[0])
postprocessed = True