[minor] [query] expense and income account queries should exclude customer and supplier accounts
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index f3d359b..55776d9 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -468,12 +468,17 @@
@webnotes.whitelist()
def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
from controllers.queries import get_match_cond
-
+
+ # expense account can be any Debit account,
+ # but can also be a Liability account with account_type='Expense Account' in special circumstances.
+ # Hence the first condition is an "OR"
return webnotes.conn.sql("""select tabAccount.name from `tabAccount`
where (tabAccount.debit_or_credit="Debit"
- or tabAccount.account_type = "Expense Account")
+ or tabAccount.account_type = "Expense Account")
and tabAccount.group_or_ledger="Ledger"
and tabAccount.docstatus!=2
+ and ifnull(tabAccount.master_type, "")=""
+ and ifnull(tabAccount.master_name, "")=""
and tabAccount.company = '%(company)s'
and tabAccount.%(key)s LIKE '%(txt)s'
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index 3ae74e4..6c02bbe 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -925,11 +925,16 @@
def get_income_account(doctype, txt, searchfield, start, page_len, filters):
from 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"
return webnotes.conn.sql("""select tabAccount.name from `tabAccount`
where (tabAccount.debit_or_credit="Credit"
or tabAccount.account_type = "Income Account")
and tabAccount.group_or_ledger="Ledger"
- and tabAccount.docstatus!=2
+ and tabAccount.docstatus!=2
+ and ifnull(tabAccount.master_type, "")=""
+ and ifnull(tabAccount.master_name, "")=""
and tabAccount.company = '%(company)s'
and tabAccount.%(key)s LIKE '%(txt)s'
%(mcond)s""" % {'company': filters['company'], 'key': searchfield,