refactor: ignore disabled account while selecting Income Accounts
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index d4d9239..b1a7b10 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -187,7 +187,6 @@
erpnext.accounts.unreconcile_payments.add_unreconcile_btn(me.frm);
}
-
make_maintenance_schedule() {
frappe.model.open_mapped_doc({
method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.make_maintenance_schedule",
@@ -563,15 +562,6 @@
}
}
-// Income Account in Details Table
-// --------------------------------
-cur_frm.set_query("income_account", "items", function(doc) {
- return{
- query: "erpnext.controllers.queries.get_income_account",
- filters: {'company': doc.company}
- }
-});
-
// Cost Center in Details Table
// -----------------------------
cur_frm.fields_dict["items"].grid.get_field("cost_center").get_query = function(doc) {
@@ -666,6 +656,16 @@
};
});
+ frm.set_query("income_account", "items", function() {
+ return{
+ query: "erpnext.controllers.queries.get_income_account",
+ filters: {
+ 'company': frm.doc.company,
+ "disabled": 0
+ }
+ }
+ });
+
frm.custom_make_buttons = {
'Delivery Note': 'Delivery',
'Sales Invoice': 'Return / Credit Note',
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 5ec2474..199732b 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -611,6 +611,8 @@
if filters.get("company"):
condition += "and tabAccount.company = %(company)s"
+ condition += f"and tabAccount.disabled = {filters.get('disabled', 0)}"
+
return frappe.db.sql(
"""select tabAccount.name from `tabAccount`
where (tabAccount.report_type = "Profit and Loss"