Account common get_query
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index a4d2b52..789e7a3 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -236,13 +236,21 @@
'page_len': page_len})
def get_account_list(doctype, txt, searchfield, start, page_len, filters):
- if isinstance(filters, dict):
- if not filters.get("group_or_ledger"):
- filters["group_or_ledger"] = "Ledger"
- elif isinstance(filters, list):
- if "group_or_ledger" not in [d[0] for d in filters]:
- filters.append(["Account", "group_or_ledger", "=", "Ledger"])
+ filter_list = []
- return frappe.widgets.reportview.execute("Account", filters = filters,
+ if isinstance(filters, dict):
+ for key, val in filters.items():
+ if isinstance(val, (list, tuple)):
+ filter_list.append([doctype, key, val[0], val[1]])
+ else:
+ filter_list.append([doctype, key, "=", val])
+
+ if "group_or_ledger" not in [d[1] for d in filter_list]:
+ filter_list.append(["Account", "group_or_ledger", "=", "Ledger"])
+
+ if searchfield and txt:
+ filter_list.append([doctype, searchfield, "like", "%%%s%%" % txt])
+
+ return frappe.widgets.reportview.execute("Account", filters = filter_list,
fields = ["name", "parent_account"],
limit_start=start, limit_page_length=page_len, as_list=True)