fix: Consider Table Multiselect fields in Query engine

- Since table multiselect fields were not handled, the query tried searching for this child field in item master
- This broke the query
- On trying to reload or go back to all-products page with field filters that are table mutiselect, page breaks
This commit is contained in:
marination 2021-06-23 20:06:11 +05:30
parent 1b9b72d12e
commit f913e0dd05

View File

@ -115,6 +115,17 @@ class ProductQuery:
if not values:
continue
# handle multiselect fields in filter addition
meta = frappe.get_meta('Item', cached=True)
df = meta.get_field(field)
if df.fieldtype == 'Table MultiSelect':
child_doctype = df.options
child_meta = frappe.get_meta(child_doctype, cached=True)
fields = child_meta.get("fields", { "fieldtype": "Link", "in_list_view": 1 })
if fields:
self.filters.append([child_doctype, fields[0].fieldname, 'IN', values])
continue
if isinstance(values, list):
# If value is a list use `IN` query
self.filters.append([field, 'IN', values])