Cleanup grid filters for vendor catalog batches

This commit is contained in:
Lance Edgar 2022-03-08 16:35:11 -06:00
parent a9e64e931e
commit 0a42ec77b2

View file

@ -148,10 +148,33 @@ class VendorCatalogView(FileBatchMasterView):
def configure_grid(self, g): def configure_grid(self, g):
super(VendorCatalogView, self).configure_grid(g) super(VendorCatalogView, self).configure_grid(g)
g.joiners['vendor'] = lambda q: q.join(model.Vendor) model = self.model
g.filters['vendor'] = g.make_filter('vendor', model.Vendor.name,
default_active=True, default_verb='contains') # nb. this batch has vendor_id and vendor_name fields, but in
g.sorters['vendor'] = g.make_sorter(model.Vendor.name) # practice they aren't used much and normally just the vendor
# proper is set. so we remove simple filters and add the
# custom one for (referenced) vendor name
g.remove_filter('vendor_id')
g.remove_filter('vendor_name')
g.set_joiner('vendor', lambda q: q.join(model.Vendor))
g.set_filter('vendor', model.Vendor.name,
default_active=True,
default_verb='contains')
# and this is the same thing we are showing as grid column
g.set_sorter('vendor', model.Vendor.name)
# preferred filters
g.set_filters_sequence([
'id',
'vendor',
'description',
'executed',
'created',
'filename',
'future',
'effective',
'notes',
])
g.set_link('vendor') g.set_link('vendor')
g.set_link('filename') g.set_link('filename')