Browse Source

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
develop
marination 3 years ago
parent
commit
f913e0dd05
  1. 11
      erpnext/shopping_cart/product_query.py

11
erpnext/shopping_cart/product_query.py

@ -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])

Loading…
Cancel
Save