Add a dropdown of choices to the Department filter for Products grid
This commit is contained in:
parent
a52b5ec380
commit
65ac7e0c15
|
@ -202,6 +202,7 @@ class ProductView(MasterView):
|
|||
|
||||
def configure_grid(self, g):
|
||||
super(ProductView, self).configure_grid(g)
|
||||
app = self.get_rattail_app()
|
||||
|
||||
def join_vendor(q):
|
||||
return q.outerjoin(self.ProductVendorCost,
|
||||
|
@ -230,8 +231,18 @@ class ProductView(MasterView):
|
|||
ProductCostCodeAny.product_uuid == model.Product.uuid)
|
||||
|
||||
g.joiners['brand'] = lambda q: q.outerjoin(model.Brand)
|
||||
g.joiners['department'] = lambda q: q.outerjoin(model.Department,
|
||||
model.Department.uuid == model.Product.department_uuid)
|
||||
|
||||
# department
|
||||
g.set_joiner('department', lambda q: q.outerjoin(model.Department))
|
||||
g.set_sorter('department', model.Department.name)
|
||||
department_choices = app.cache_model(self.Session(), model.Department,
|
||||
order_by=model.Department.name,
|
||||
normalizer=lambda d: d.name)
|
||||
g.set_filter('department', model.Department.uuid,
|
||||
value_enum=department_choices,
|
||||
verbs=['equal', 'not_equal', 'is_null', 'is_not_null', 'is_any'],
|
||||
default_active=True, default_verb='equal')
|
||||
|
||||
g.joiners['subdepartment'] = lambda q: q.outerjoin(model.Subdepartment,
|
||||
model.Subdepartment.uuid == model.Product.subdepartment_uuid)
|
||||
g.joiners['code'] = lambda q: q.outerjoin(model.ProductCode)
|
||||
|
@ -241,7 +252,6 @@ class ProductView(MasterView):
|
|||
g.joiners['vendor_code_any'] = join_vendor_code_any
|
||||
|
||||
g.sorters['brand'] = g.make_sorter(model.Brand.name)
|
||||
g.sorters['department'] = g.make_sorter(model.Department.name)
|
||||
g.sorters['subdepartment'] = g.make_sorter(model.Subdepartment.name)
|
||||
g.sorters['vendor'] = g.make_sorter(model.Vendor.name)
|
||||
|
||||
|
@ -274,8 +284,6 @@ class ProductView(MasterView):
|
|||
g.filters['description'].default_verb = 'contains'
|
||||
g.filters['brand'] = g.make_filter('brand', model.Brand.name,
|
||||
default_active=True, default_verb='contains')
|
||||
g.filters['department'] = g.make_filter('department', model.Department.name,
|
||||
default_active=True, default_verb='contains')
|
||||
g.filters['subdepartment'] = g.make_filter('subdepartment', model.Subdepartment.name)
|
||||
g.filters['code'] = g.make_filter('code', model.ProductCode.code)
|
||||
g.filters['vendor'] = g.make_filter('vendor', model.Vendor.name)
|
||||
|
|
Loading…
Reference in a new issue