summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2016-09-27 19:36:54 +0200
committerOlivier Dony <odo@openerp.com>2016-09-27 19:39:30 +0200
commit40bce50ddbffa5ef663fe02c9b2025d0b2d6b6d3 (patch)
treea56860957011c0aee1d2a08d553da8a55b6abf38
parent1df161db6b9eb63c3012fde34da07bbdfb15108a (diff)
Revert "[FIX] mail: onchange_template_id"
This reverts commit dc02f773ce616e1eba564e574c654fe51d665d11. This commit caused a side-effect that is worse than the issue it tried to fix, which was purely cosmetic. Now in mass-mail mode the template is only rendered once and all recipients receive the same PDF, which completely defeats the goal of a dynamic report. We have static attachments for that. Original fix related to opw-657152 Reverts PR #10568
-rw-r--r--addons/mail/models/mail_template.py2
-rw-r--r--addons/mail/wizard/mail_compose_message.py23
2 files changed, 2 insertions, 23 deletions
diff --git a/addons/mail/models/mail_template.py b/addons/mail/models/mail_template.py
index c4346fd6c71..c84bc1bca2b 100644
--- a/addons/mail/models/mail_template.py
+++ b/addons/mail/models/mail_template.py
@@ -493,7 +493,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/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py
index 6296496662a..6898341bb7f 100644
--- a/addons/mail/wizard/mail_compose_message.py
+++ b/addons/mail/wizard/mail_compose_message.py
@@ -187,7 +187,7 @@ class MailComposer(models.TransientModel):
@api.multi
def send_mail_action(self):
# TDE/ ???
- return self.with_context(report_template_in_attachment=True).send_mail()
+ return self.send_mail()
@api.multi
def send_mail(self, auto_commit=False):
@@ -346,20 +346,6 @@ class MailComposer(models.TransientModel):
if template.user_signature and 'body_html' in values:
signature = self.env.user.signature
values['body_html'] = tools.append_content_to_html(values['body_html'], signature, plaintext=False)
- if template.report_template:
- attachment = self.env['ir.attachment']
- attach = self.generate_attachment_from_report(template_id, res_id)
- for attach_fname, attach_datas in attach[res_id].pop('attachments', []):
- data_attach = {
- 'name': attach_fname,
- 'datas': attach_datas,
- 'datas_fname': attach_fname,
- 'res_model': 'mail.compose.message',
- 'res_id': 0,
- 'type': 'binary',
- }
- values.setdefault('attachment_ids', list()).append(attachment.create(data_attach).id)
-
elif template_id:
values = self.generate_email_for_composer(template_id, [res_id])[res_id]
# transform attachments into attachment_ids; not attached to the document because this will
@@ -391,13 +377,6 @@ class MailComposer(models.TransientModel):
return {'value': values}
@api.multi
- def generate_attachment_from_report(self, template_id, res_id):
- fields = ['attachment_ids']
- result = self.env['mail.template'].with_context(tpl_partners_only=True).browse(template_id).generate_email([res_id], fields=fields)
- return result
-
-
- @api.multi
def save_as_template(self):
""" hit save as template button: current form value will be a new
template attached to the current document. """