Add customer number filter for People grid

This commit is contained in:
Lance Edgar 2023-06-05 20:18:57 -05:00
parent 4318f03bd6
commit 488126b92c

View file

@ -112,6 +112,7 @@ class PersonView(MasterView):
def configure_grid(self, g): def configure_grid(self, g):
super(PersonView, self).configure_grid(g) super(PersonView, self).configure_grid(g)
model = self.model
g.joiners['email'] = lambda q: q.outerjoin(model.PersonEmailAddress, sa.and_( g.joiners['email'] = lambda q: q.outerjoin(model.PersonEmailAddress, sa.and_(
model.PersonEmailAddress.parent_uuid == model.Person.uuid, model.PersonEmailAddress.parent_uuid == model.Person.uuid,
@ -124,8 +125,17 @@ class PersonView(MasterView):
g.set_filter('phone', model.PersonPhoneNumber.number, g.set_filter('phone', model.PersonPhoneNumber.number,
factory=grids.filters.AlchemyPhoneNumberFilter) factory=grids.filters.AlchemyPhoneNumberFilter)
g.joiners['customer_id'] = lambda q: q.outerjoin(model.CustomerPerson).outerjoin(model.Customer) Customer_ID = orm.aliased(model.Customer)
g.filters['customer_id'] = g.make_filter('customer_id', model.Customer.id) 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_active = True
g.filters['first_name'].default_verb = 'contains' g.filters['first_name'].default_verb = 'contains'