fix: add condition to fetch active accounts

(cherry picked from commit 7c8dd86a35)
This commit is contained in:
mithili
2025-07-30 11:19:23 +05:30
committed by Mergify
parent e0d9a47ff7
commit 8fc8aa2dfd
2 changed files with 1 additions and 3 deletions

View File

@@ -31,7 +31,6 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying.
query: "erpnext.controllers.queries.get_expense_account",
filters: {
company: doc.company,
disabled: 0,
},
};
});

View File

@@ -640,14 +640,13 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
condition = ""
if filters.get("company"):
condition += "and tabAccount.company = %(company)s"
condition += f"and tabAccount.disabled = {filters.get('disabled', 0)}"
return frappe.db.sql(
f"""select tabAccount.name from `tabAccount`
where (tabAccount.report_type = "Profit and Loss"
or tabAccount.account_type in ("Expense Account", "Fixed Asset", "Temporary", "Asset Received But Not Billed", "Capital Work in Progress"))
and tabAccount.is_group=0
and tabAccount.docstatus!=2
and tabAccount.disabled = 0
and tabAccount.{searchfield} LIKE %(txt)s
{condition} {get_match_cond(doctype)}""",
{"company": filters.get("company", ""), "txt": "%" + txt + "%"},