From 3bb23bb77e44bc2940914ac252bec44640054923 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 2 Feb 2021 15:47:25 +0100 Subject: [PATCH] Invoice exporter: Add order ID to filename --- src/pretix/base/exporters/invoices.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pretix/base/exporters/invoices.py b/src/pretix/base/exporters/invoices.py index 1b23e1164b..50bd2e0baf 100644 --- a/src/pretix/base/exporters/invoices.py +++ b/src/pretix/base/exporters/invoices.py @@ -66,7 +66,7 @@ class InvoiceExporterMixin: ) def invoices_queryset(self, form_data: dict): - qs = Invoice.objects.filter(event__in=self.events) + qs = Invoice.objects.filter(event__in=self.events).select_related('order') if form_data.get('payment_provider'): qs = qs.annotate( @@ -112,13 +112,13 @@ class InvoiceExporter(InvoiceExporterMixin, BaseExporter): invoice_pdf_task.apply(args=(i.pk,)) i.refresh_from_db() i.file.open('rb') - zipf.writestr('{}.pdf'.format(i.number), i.file.read()) + zipf.writestr('{}-{}.pdf'.format(i.number, i.order.code), i.file.read()) i.file.close() except FileNotFoundError: invoice_pdf_task.apply(args=(i.pk,)) i.refresh_from_db() i.file.open('rb') - zipf.writestr('{}.pdf'.format(i.number), i.file.read()) + zipf.writestr('{}-{}.pdf'.format(i.number, i.order.code), i.file.read()) i.file.close() counter += 1 if total and counter % max(10, total // 100) == 0: