From 4e72ac303fbbce33b3bb75bfcdc57323db932d80 Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 23 Mar 2023 10:59:58 +1100 Subject: [PATCH] Catch TemplateDoesNotExist error (#4518) --- InvenTree/report/api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/InvenTree/report/api.py b/InvenTree/report/api.py index 68474bdf31..8fb7182e3a 100644 --- a/InvenTree/report/api.py +++ b/InvenTree/report/api.py @@ -295,8 +295,11 @@ class StockItemTestReportPrint(StockItemTestReportMixin, ReportPrintMixin, Retri if common.models.InvenTreeSetting.get_setting('REPORT_ATTACH_TEST_REPORT', cache=False): # Construct a PDF file object - pdf = report.get_document().write_pdf() - pdf_content = ContentFile(pdf, "test_report.pdf") + try: + pdf = report.get_document().write_pdf() + pdf_content = ContentFile(pdf, "test_report.pdf") + except TemplateDoesNotExist: + return StockItemAttachment.objects.create( attachment=pdf_content,