Fix exception if first order does not have billing address

This commit is contained in:
Nico Schottelius 2020-05-10 14:22:09 +02:00
parent 65440ab2ef
commit dc7a465a8c
1 changed files with 4 additions and 1 deletions

View File

@ -327,7 +327,10 @@ class Bill(models.Model):
orders = Order.objects.filter(bill=self)
# The genrate_for method makes sure all the orders of a bill share the
# same billing address. TODO: It would be nice to enforce that somehow...
return orders[0].billing_address
if orders:
return orders[0].billing_address
else:
return None
# TODO: split this huuuge method!
@staticmethod