From 112b39c4de6193dc787d062dedc0d83cc00c05c4 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 20 Dec 2024 20:09:30 -0800 Subject: [PATCH] Lol this works --- src/paperless_einvoice/parsers.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/paperless_einvoice/parsers.py b/src/paperless_einvoice/parsers.py index b3c6fe57c..e46e941c6 100644 --- a/src/paperless_einvoice/parsers.py +++ b/src/paperless_einvoice/parsers.py @@ -8,7 +8,8 @@ from gotenberg_client.options import MarginUnitType from gotenberg_client.options import PageMarginsType from gotenberg_client.options import PageSize from gotenberg_client.options import PdfAFormat -from jinja2 import Template +from jinja2 import FileSystemLoader +from jinja2.environment import Environment from documents.parsers import ParseError from paperless.models import OutputTypeChoices @@ -32,7 +33,11 @@ class EInvoiceDocumentParser(TikaDocumentParser): context = { "id": invoice.trade.agreement.seller.name, } - template = Template("templates/invoice.j2.html") + templateLoader = FileSystemLoader( + searchpath=Path(__file__).parent / "templates", + ) + templateEnv = Environment(loader=templateLoader) + template = templateEnv.get_template("invoice.j2.html") html_file = Path(self.tempdir) / "invoice_as_html.html" html_file.write_text( template.render(context),