From e0d9a47ff7df6bba391fe3662e2340e4142582ad 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 (cherry picked from commit c3111db6e2d9135c01f93d6f94c1c459b1ee7b37) --- .../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 11bfc5e8dde..c14b8528f38 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -29,7 +29,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 be965e41b3e..96b2629b17a 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -640,6 +640,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 8fc8aa2dfd4009af77d8660fb05a8d7485878018 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 (cherry picked from commit 7c8dd86a35ee3029404943542358ec66430edec1) --- 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 c14b8528f38..cc274335fe5 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -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, }, }; }); diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index 96b2629b17a..1e0e01211e6 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -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 + "%"}, From a230a0d94ca6a0b4bab042a089788ae725781c90 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 (cherry picked from commit 23308f6d10e1e804c969cca928ca110de03c52b2) --- 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 cc274335fe5..c14b8528f38 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -31,6 +31,7 @@ erpnext.accounts.PurchaseInvoice = class PurchaseInvoice extends erpnext.buying. query: "erpnext.controllers.queries.get_expense_account", filters: { company: doc.company, + disabled: 0, }, }; });