Changed vendor filter in product search to find "any vendor".

I.e. the current filter is ''not'' restricted to the preferred vendor only.
Probably should still add one (back) for preferred only as well; hence the
commented code.
This commit is contained in:
Lance Edgar 2013-09-10 06:35:17 -07:00
parent 88adfe5d85
commit 047c35ab75

View file

@ -61,15 +61,21 @@ class ProductsGrid(SearchableAlchemyGridView):
def join_map(self):
def join_vendor(q):
q = q.outerjoin(
ProductCost,
and_(
ProductCost.product_uuid == Product.uuid,
ProductCost.preference == 1,
))
q = q.outerjoin(Vendor)
return q
# def join_vendor(q):
# q = q.outerjoin(
# ProductCost,
# ProductCost.product_uuid == Product.uuid,
# and_(
# ProductCost.product_uuid == Product.uuid,
# ProductCost.preference == 1,
# ))
# q = q.outerjoin(Vendor)
# return q
def join_vendor_any(q):
return q.outerjoin(ProductCost,
ProductCost.product_uuid == Product.uuid)\
.outerjoin(Vendor)
return {
'brand':
@ -86,8 +92,10 @@ class ProductsGrid(SearchableAlchemyGridView):
'current_price':
lambda q: q.outerjoin(ProductPrice,
ProductPrice.uuid == Product.current_price_uuid),
'vendor':
join_vendor,
# 'vendor':
# join_vendor,
'vendor_any':
join_vendor_any,
'code':
lambda q: q.outerjoin(ProductCode),
}
@ -122,7 +130,8 @@ class ProductsGrid(SearchableAlchemyGridView):
brand=self.filter_ilike(Brand.name),
department=self.filter_ilike(Department.name),
subdepartment=self.filter_ilike(Subdepartment.name),
vendor=self.filter_ilike(Vendor.name),
# vendor=self.filter_ilike(Vendor.name),
vendor_any=self.filter_ilike(Vendor.name),
code=self.filter_ilike(ProductCode.code))
def filter_config(self):
@ -136,8 +145,9 @@ class ProductsGrid(SearchableAlchemyGridView):
filter_type_description='lk',
include_filter_department=True,
filter_type_department='lk',
include_filter_vendor=True,
filter_type_vendor='lk')
include_filter_vendor_any=True,
filter_label_vendor_any="Vendor (any)",
filter_type_vendor_any='lk')
def sort_map(self):
return self.make_sort_map(
@ -171,7 +181,7 @@ class ProductsGrid(SearchableAlchemyGridView):
g.description,
g.size,
g.subdepartment,
g.vendor,
g.vendor.label("Pref. Vendor"),
g.regular_price.label("Reg. Price"),
g.current_price.label("Cur. Price"),
],