Turn on quickie person search for CustomerShopper views
also set default sort for that grid
This commit is contained in:
parent
214f3d9b1e
commit
69bda79baf
|
@ -746,10 +746,28 @@ class CustomerShopperView(MasterView):
|
||||||
'active',
|
'active',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def should_expose_quickie_search(self):
|
||||||
|
if self.expose_quickie_search:
|
||||||
|
return True
|
||||||
|
app = self.get_rattail_app()
|
||||||
|
return app.get_people_handler().should_expose_quickie_search()
|
||||||
|
|
||||||
|
def get_quickie_perm(self):
|
||||||
|
return 'people.quickie'
|
||||||
|
|
||||||
|
def get_quickie_url(self):
|
||||||
|
return self.request.route_url('people.quickie')
|
||||||
|
|
||||||
|
def get_quickie_placeholder(self):
|
||||||
|
app = self.get_rattail_app()
|
||||||
|
return app.get_people_handler().get_quickie_search_placeholder()
|
||||||
|
|
||||||
def query(self, session):
|
def query(self, session):
|
||||||
query = super().query(session)
|
query = super().query(session)
|
||||||
model = self.model
|
model = self.model
|
||||||
return query.join(model.Customer)
|
return query.join(model.Customer)\
|
||||||
|
.join(model.Person,
|
||||||
|
model.Person.uuid == model.CustomerShopper.person_uuid)
|
||||||
|
|
||||||
def configure_grid(self, g):
|
def configure_grid(self, g):
|
||||||
super().configure_grid(g)
|
super().configure_grid(g)
|
||||||
|
@ -763,6 +781,7 @@ class CustomerShopperView(MasterView):
|
||||||
g.set_renderer('customer_key',
|
g.set_renderer('customer_key',
|
||||||
lambda shopper, field: getattr(shopper.customer, key))
|
lambda shopper, field: getattr(shopper.customer, key))
|
||||||
g.set_sorter('customer_key', getattr(model.Customer, key))
|
g.set_sorter('customer_key', getattr(model.Customer, key))
|
||||||
|
g.set_sort_defaults('customer_key')
|
||||||
g.set_filter('customer_key', getattr(model.Customer, key),
|
g.set_filter('customer_key', getattr(model.Customer, key),
|
||||||
label=f"Customer {label}",
|
label=f"Customer {label}",
|
||||||
default_active=True,
|
default_active=True,
|
||||||
|
@ -771,7 +790,12 @@ class CustomerShopperView(MasterView):
|
||||||
# customer (name)
|
# customer (name)
|
||||||
g.set_sorter('customer', model.Customer.name)
|
g.set_sorter('customer', model.Customer.name)
|
||||||
g.set_filter('customer', model.Customer.name,
|
g.set_filter('customer', model.Customer.name,
|
||||||
label="Customer Name")
|
label="Customer Account Name")
|
||||||
|
|
||||||
|
# person (name)
|
||||||
|
g.set_sorter('person', model.Person.display_name)
|
||||||
|
g.set_filter('person', model.Person.display_name,
|
||||||
|
label="Person Name")
|
||||||
|
|
||||||
def configure_form(self, f):
|
def configure_form(self, f):
|
||||||
super().configure_form(f)
|
super().configure_form(f)
|
||||||
|
|
Loading…
Reference in a new issue