[minor] [query] expense and income account queries should exclude customer and supplier accounts

This commit is contained in:
Anand Doshi 2013-11-04 12:55:24 +05:30
parent 4144b1c841
commit 06757a19ef
2 changed files with 13 additions and 3 deletions

View File

@ -468,12 +468,17 @@ class DocType(BuyingController):
@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,

View File

@ -925,11 +925,16 @@ def get_bank_cash_account(mode_of_payment):
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,