[fix] Allowed accounts with account type='Income Account' for default income account in item
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index a6bfa53..e2de6c3 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -293,3 +293,27 @@
fields = ["name", "parent_account"],
limit_start=start, limit_page_length=page_len, as_list=True)
+
+@frappe.whitelist()
+def get_income_account(doctype, txt, searchfield, start, page_len, filters):
+ from erpnext.controllers.queries import get_match_cond
+
+ # income account can be any Credit account,
+ # but can also be a Asset account with account_type='Income Account' in special circumstances.
+ # Hence the first condition is an "OR"
+ if not filters: filters = {}
+
+ condition = ""
+ if filters.get("company"):
+ condition += "and tabAccount.company = %(company)s"
+
+ return frappe.db.sql("""select tabAccount.name from `tabAccount`
+ where (tabAccount.report_type = "Profit and Loss"
+ or tabAccount.account_type in ("Income Account", "Temporary"))
+ and tabAccount.is_group=0
+ and tabAccount.`{key}` LIKE %(txt)s
+ {condition} {match_condition}"""
+ .format(condition=condition, match_condition=get_match_cond(doctype), key=searchfield), {
+ 'txt': "%%%s%%" % frappe.db.escape(txt),
+ 'company': filters.get("company", "")
+ })
\ No newline at end of file