Catch TemplateDoesNotExist error (#4518)

This commit is contained in:
Oliver 2023-03-23 10:59:58 +11:00 committed by GitHub
parent 73aa56c6f3
commit 4e72ac303f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,