From 01e2851a76deecb9b5e1be7d45b062ab582ff0e1 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 14 Apr 2020 09:47:34 +0200 Subject: [PATCH] Invoice model: Do not crash on invalid states --- src/pretix/base/models/invoices.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pretix/base/models/invoices.py b/src/pretix/base/models/invoices.py index ac5679caa8..dced6a2d81 100644 --- a/src/pretix/base/models/invoices.py +++ b/src/pretix/base/models/invoices.py @@ -157,9 +157,12 @@ class Invoice(models.Model): state_name = self.invoice_to_state if str(self.invoice_to_country) in COUNTRIES_WITH_STATE_IN_ADDRESS: if COUNTRIES_WITH_STATE_IN_ADDRESS[str(self.invoice_to_country)][1] == 'long': - state_name = pycountry.subdivisions.get( - code='{}-{}'.format(self.invoice_to_country, self.invoice_to_state) - ).name + try: + state_name = pycountry.subdivisions.get( + code='{}-{}'.format(self.invoice_to_country, self.invoice_to_state) + ).name + except: + pass parts = [ self.invoice_to_company,