Browse Source

Move variables outside for loop

pull/74/head
dufresnedavid 9 years ago
parent
commit
7d114d01a7
  1. 9
      mail_template_multi_report/models/email_template.py

9
mail_template_multi_report/models/email_template.py

@ -21,6 +21,7 @@ class EmailTemplate(models.Model):
template_id, res_ids, fields=fields)
template = self.browse(template_id)
report_ext = '.pdf'
for report_line in template.report_line_ids:
records = self.env[template.model_id.model].browse(res_ids)
@ -42,17 +43,13 @@ class EmailTemplate(models.Model):
report_service = report.report_name
result = self.env['report'].get_pdf(rec, report_service)
report_format = 'pdf'
result = base64.b64encode(result)
if not report_name:
report_name = 'report.' + report_service
ext = "." + report_format
if not report_name.endswith(ext):
report_name += ext
if not report_name.endswith(report_ext):
report_name += report_ext
results[rec.id].setdefault('attachments', [])
results[rec.id]['attachments'].append((report_name, result))

Loading…
Cancel
Save