fix: avoid error for trainwreck query when not a customer
when viewing a person's profile, who does not have a customer record, the trainwreck query can't really return anything since it normally should be matching on the customer ID
This commit is contained in:
parent
bcaf0d08bc
commit
980031f524
|
@ -564,15 +564,19 @@ class PersonView(MasterView):
|
|||
Method which must return the base query for the profile's POS
|
||||
Transactions grid data.
|
||||
"""
|
||||
app = self.get_rattail_app()
|
||||
customer = app.get_customer(person)
|
||||
customer = self.app.get_customer(person)
|
||||
|
||||
key_field = app.get_customer_key_field()
|
||||
customer_key = getattr(customer, key_field)
|
||||
if customer_key is not None:
|
||||
customer_key = str(customer_key)
|
||||
if customer:
|
||||
key_field = self.app.get_customer_key_field()
|
||||
customer_key = getattr(customer, key_field)
|
||||
if customer_key is not None:
|
||||
customer_key = str(customer_key)
|
||||
else:
|
||||
# nb. this should *not* match anything, so query returns
|
||||
# no results..
|
||||
customer_key = person.uuid
|
||||
|
||||
trainwreck = app.get_trainwreck_handler()
|
||||
trainwreck = self.app.get_trainwreck_handler()
|
||||
model = trainwreck.get_model()
|
||||
query = TrainwreckSession.query(model.Transaction)\
|
||||
.filter(model.Transaction.customer_id == customer_key)
|
||||
|
|
Loading…
Reference in a new issue