Fix bug when making context for mailing address

sometimes those belong to a non-person, e.g. customer
This commit is contained in:
Lance Edgar 2021-10-10 20:24:26 -04:00
parent ffb33d00c8
commit 3e796e9164

View file

@ -515,8 +515,7 @@ class PersonView(MasterView):
return context
def get_context_address(self, address):
person = address.person
return {
context = {
'uuid': address.uuid,
'street': address.street,
'street2': address.street2,
@ -524,9 +523,15 @@ class PersonView(MasterView):
'state': address.state,
'zipcode': address.zipcode,
'display': six.text_type(address),
'invalid': self.handler.address_is_invalid(person, address),
}
model = self.model
if isinstance(address, model.PersonMailingAddress):
person = address.person
context['invalid'] = self.handler.address_is_invalid(person, address)
return context
def get_context_customers(self, person):
data = []
for cp in person._customers: