FIX bug #56 crash in report_custom_filename

pull/57/head
Alexis de Lattre 2016-06-01 15:31:58 +02:00
parent 77a627b727
commit b471978642
1 changed files with 8 additions and 1 deletions

View File

@ -39,7 +39,14 @@ class Reports(main.Reports):
for report in report_xml.browse(report_ids):
if not report.download_filename:
continue
objects = http.request.session.model(context['active_model'])\
# When you are on the form view of a customer and you
# click on the "Sales" button, context['active_model']
# is still res.partner (probably a bug...) but
# context['active_ids'] has the ID of the sale order
# cf https://github.com/OCA/reporting-engine/issues/56
# That's why we use report.model instead of context['active_model']
# together with context['active_ids']
objects = http.request.session.model(report.model)\
.browse(context['active_ids'])
generated_filename = email_template.mako_template_env\
.from_string(report.download_filename)\