Fix the Department filter for Products grid, for jquery themes

ugh jquery
This commit is contained in:
Lance Edgar 2021-11-03 16:47:55 -05:00
parent 209b4b4de3
commit 9fef4c2601

View file

@ -204,6 +204,7 @@ class ProductView(MasterView):
def configure_grid(self, g): def configure_grid(self, g):
super(ProductView, self).configure_grid(g) super(ProductView, self).configure_grid(g)
app = self.get_rattail_app() app = self.get_rattail_app()
use_buefy = self.get_use_buefy()
def join_vendor(q): def join_vendor(q):
return q.outerjoin(self.ProductVendorCost, return q.outerjoin(self.ProductVendorCost,
@ -239,6 +240,12 @@ class ProductView(MasterView):
department_choices = app.cache_model(self.Session(), model.Department, department_choices = app.cache_model(self.Session(), model.Department,
order_by=model.Department.name, order_by=model.Department.name,
normalizer=lambda d: d.name) normalizer=lambda d: d.name)
department_choices = OrderedDict([('', "(any)")]
+ sorted(six.iteritems(department_choices),
key=lambda itm: itm[1]))
if not use_buefy:
department_choices = [tags.Option(name, uuid)
for uuid, name in six.iteritems(department_choices)]
g.set_filter('department', model.Department.uuid, g.set_filter('department', model.Department.uuid,
value_enum=department_choices, value_enum=department_choices,
verbs=['equal', 'not_equal', 'is_null', 'is_not_null', 'is_any'], verbs=['equal', 'not_equal', 'is_null', 'is_not_null', 'is_any'],