Skip to content
Snippets Groups Projects
Commit d637fe40 authored by Laurent Mignon's avatar Laurent Mignon Committed by Nans Lefebvre
Browse files

[IMP] mail: restore support for all report_types in mail attachments


Commit 48018411 introduced a new ir.action.report type: qweb-text.
Commit 3425752e introduced an explicit check on the type, for html or pdf.
This removed the ability to support arbitrary reports through the call to the
generic render method, which dispatches to the correct one for a report_type.
We add support for the text format following the same logic.

The explicit error will be raised if the rendering fails,
e.g. in the case where the render method is not defined.

Thanks to @gdgellatly for reporting.
opw 1966208
closes #28513
closes #30013
closes #32532

closes odoo/odoo#32773

Signed-off-by: default avatarNans Lefebvre (len) <len@odoo.com>
parent 2830b93a
Branches
Tags
No related merge requests found
......@@ -477,9 +477,13 @@ class MailTemplate(models.Model):
report = template.report_template
report_service = report.report_name
if report.report_type not in ['qweb-html', 'qweb-pdf']:
raise UserError(_('Unsupported report type %s found.') % report.report_type)
result, format = report.render_qweb_pdf([res_id])
if report.report_type in ['qweb-html', 'qweb-pdf']:
result, format = report.render_qweb_pdf([res_id])
else:
res = report.render([res_id])
if not res:
raise UserError(_('Unsupported report type %s found.') % report.report_type)
result, format = res
# TODO in trunk, change return format to binary to match message_post expected format
result = base64.b64encode(result)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment