mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-30 12:36:45 +00:00
Improved error messages when report templates (or snippets) are missing!
This commit is contained in:
parent
efc749c695
commit
6aec40b9ba
@ -225,13 +225,15 @@ class ReportPrintMixin:
|
|||||||
outputs.append(report.render_as_string(request))
|
outputs.append(report.render_as_string(request))
|
||||||
else:
|
else:
|
||||||
outputs.append(report.render(request))
|
outputs.append(report.render(request))
|
||||||
except TemplateDoesNotExist:
|
except TemplateDoesNotExist as e:
|
||||||
|
|
||||||
filename = report.template
|
template = str(e)
|
||||||
|
if not template:
|
||||||
|
template = report.template
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
'error': _(f"Template file '{filename}' is missing or does not exist"),
|
'error': _(f"Template file '{template}' is missing or does not exist"),
|
||||||
},
|
},
|
||||||
status=400,
|
status=400,
|
||||||
)
|
)
|
||||||
@ -269,13 +271,16 @@ class ReportPrintMixin:
|
|||||||
else:
|
else:
|
||||||
pdf = outputs[0].get_document().write_pdf()
|
pdf = outputs[0].get_document().write_pdf()
|
||||||
|
|
||||||
except TemplateDoesNotExist:
|
except TemplateDoesNotExist as e:
|
||||||
|
|
||||||
filename = report.template
|
template = str(e)
|
||||||
|
|
||||||
|
if not template:
|
||||||
|
template = report.template
|
||||||
|
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
'error': _(f"Template file '{filename}' is missing or does not exist"),
|
'error': _(f"Template file '{template}' is missing or does not exist"),
|
||||||
},
|
},
|
||||||
status=400,
|
status=400,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user