Add separate product grid filters for Category Code, Category Name

this also fixes a join bug in some edge cases
This commit is contained in:
Lance Edgar 2022-08-08 14:39:26 -05:00
parent 903afc111e
commit a999b996fb

View file

@ -225,6 +225,7 @@ class ProductView(MasterView):
def configure_grid(self, g):
super(ProductView, self).configure_grid(g)
app = self.get_rattail_app()
model = self.model
use_buefy = self.get_use_buefy()
def join_vendor(q):
@ -335,8 +336,16 @@ class ProductView(MasterView):
g.set_label('vendor_code_any', "Vendor Code (any)")
# category
g.set_joiner('category', lambda q: q.outerjoin(model.Category))
g.set_filter('category', model.Category.name)
CategoryByCode = orm.aliased(model.Category)
CategoryByName = orm.aliased(model.Category)
g.set_joiner('category_code',
lambda q: q.outerjoin(CategoryByCode,
CategoryByCode.uuid == model.Product.category_uuid))
g.set_filter('category_code', CategoryByCode.code)
g.set_joiner('category_name',
lambda q: q.outerjoin(CategoryByName,
CategoryByName.uuid == model.Product.category_uuid))
g.set_filter('category_name', CategoryByName.name)
# family
g.set_joiner('family', lambda q: q.outerjoin(model.Family))