diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py index 73e49983fb2..a12b217d1be 100644 --- a/erpnext/accounts/report/financial_statements.py +++ b/erpnext/accounts/report/financial_statements.py @@ -527,7 +527,16 @@ def get_accounting_entries( account_filter_query = get_account_filter_query(root_lft, root_rgt, root_type, gl_entry) query = query.where(ExistsCriterion(account_filter_query)) - entries = query.run(as_dict=True) + query = query.get_sql() + + from frappe.desk.reportview import build_match_conditions + + match_conditions = build_match_conditions(doctype) + + if match_conditions: + query += "and" + match_conditions + + entries = frappe.db.sql(query, as_dict=True) return entries