From c3111db6e2d9135c01f93d6f94c1c459b1ee7b37 Mon Sep 17 00:00:00 2001 From: mithili Date: Mon, 28 Jul 2025 17:10:46 +0530 Subject: [PATCH 1/3] fix(purchase invoice): filter only enabled account --- .../accounts/doctype/purchase_invoice/purchase_invoice.js | 5 ++++- erpnext/controllers/queries.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index e9ec1dc5712..501c10f5c81 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -35,7 +35,10 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. this.frm.set_query("expense_account", "items", function () { return { query: "erpnext.controllers.queries.get_expense_account", - filters: { company: doc.company }, + filters: { + company: doc.company, + disabled: 0, + }, }; }); } diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index eef40f3dc40..aa3a1697d23 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -700,6 +700,7 @@ 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` From 7c8dd86a35ee3029404943542358ec66430edec1 Mon Sep 17 00:00:00 2001 From: mithili Date: Wed, 30 Jul 2025 11:19:23 +0530 Subject: [PATCH 2/3] fix: add condition to fetch active accounts --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js | 1 - erpnext/controllers/queries.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 501c10f5c81..3527b66404e 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -37,7 +37,6 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. query: "erpnext.controllers.queries.get_expense_account", filters: { company: doc.company, - disabled: 0, }, }; }); diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index aa3a1697d23..f1d8582bf47 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -700,14 +700,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 + "%"}, From 23308f6d10e1e804c969cca928ca110de03c52b2 Mon Sep 17 00:00:00 2001 From: mithili Date: Mon, 4 Aug 2025 18:48:48 +0530 Subject: [PATCH 3/3] chore: add back filter --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js | 1 + 1 file changed, 1 insertion(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 3527b66404e..501c10f5c81 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -37,6 +37,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. query: "erpnext.controllers.queries.get_expense_account", filters: { company: doc.company, + disabled: 0, }, }; });