Allow admins to inspect invoices (#5641)

This is helpful to debug invoice renderers or non-PDF invoices like
Peppol or other XML formats
This commit is contained in:
Raphael Michel
2025-11-19 14:42:18 +01:00
committed by GitHub
parent 9c80f3038a
commit db7518735a
4 changed files with 34 additions and 2 deletions

View File

@@ -131,13 +131,16 @@ from pretix.control.forms.orders import (
ReactivateOrderForm,
)
from pretix.control.forms.rrule import RRuleForm
from pretix.control.permissions import EventPermissionRequiredMixin
from pretix.control.permissions import (
AdministratorPermissionRequiredMixin, EventPermissionRequiredMixin,
)
from pretix.control.signals import order_search_forms
from pretix.control.views import PaginationMixin
from pretix.helpers import OF_SELF
from pretix.helpers.compat import CompatDeleteView
from pretix.helpers.format import SafeFormatter, format_map
from pretix.helpers.hierarkey import clean_filename
from pretix.helpers.json import CustomJSONEncoder
from pretix.helpers.safedownload import check_token
from pretix.presale.signals import question_form_fields
@@ -1752,6 +1755,25 @@ class OrderInvoiceReissue(OrderView):
return HttpResponseNotAllowed(['POST'])
class OrderInvoiceInspect(AdministratorPermissionRequiredMixin, OrderView):
def get(self, *args, **kwargs): # NOQA
inv = get_object_or_404(self.order.invoices, pk=kwargs.get('id'))
d = {"lines": []}
for f in inv._meta.fields:
v = getattr(inv, f.name)
d[f.name] = v
for il in inv.lines.all():
line = {}
for f in il._meta.fields:
v = getattr(il, f.name)
line[f.name] = v
d["lines"].append(line)
return JsonResponse(d, encoder=CustomJSONEncoder)
class OrderResendLink(OrderView):
permission = 'can_change_orders'