From 488126b92c42e2c59b9bed755caf5a7e6b59c4ad Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 5 Jun 2023 20:18:57 -0500 Subject: [PATCH] Add customer number filter for People grid --- tailbone/views/people.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tailbone/views/people.py b/tailbone/views/people.py index c0d0c86f..0a471f46 100644 --- a/tailbone/views/people.py +++ b/tailbone/views/people.py @@ -112,6 +112,7 @@ class PersonView(MasterView): def configure_grid(self, g): super(PersonView, self).configure_grid(g) + model = self.model g.joiners['email'] = lambda q: q.outerjoin(model.PersonEmailAddress, sa.and_( model.PersonEmailAddress.parent_uuid == model.Person.uuid, @@ -124,8 +125,17 @@ class PersonView(MasterView): g.set_filter('phone', model.PersonPhoneNumber.number, factory=grids.filters.AlchemyPhoneNumberFilter) - g.joiners['customer_id'] = lambda q: q.outerjoin(model.CustomerPerson).outerjoin(model.Customer) - g.filters['customer_id'] = g.make_filter('customer_id', model.Customer.id) + Customer_ID = orm.aliased(model.Customer) + CustomerPerson_ID = orm.aliased(model.CustomerPerson) + + Customer_Number = orm.aliased(model.Customer) + CustomerPerson_Number = orm.aliased(model.CustomerPerson) + + g.joiners['customer_id'] = lambda q: q.outerjoin(CustomerPerson_ID).outerjoin(Customer_ID) + g.filters['customer_id'] = g.make_filter('customer_id', Customer_ID.id) + + g.joiners['customer_number'] = lambda q: q.outerjoin(CustomerPerson_Number).outerjoin(Customer_Number) + g.filters['customer_number'] = g.make_filter('customer_number', Customer_Number.number) g.filters['first_name'].default_active = True g.filters['first_name'].default_verb = 'contains'