set bank account only if there is single bank type account (#11363)

* set bank account only if there is single bank type account

* Update journal_entry.py
This commit is contained in:
Manas Solanki 2017-10-31 13:04:02 +05:30 committed by Rushabh Mehta
parent 21f946f365
commit 160e710ebf

View File

@ -569,14 +569,18 @@ def get_default_bank_cash_account(company, account_type=None, mode_of_payment=No
if account_type=="Bank": if account_type=="Bank":
account = frappe.db.get_value("Company", company, "default_bank_account") account = frappe.db.get_value("Company", company, "default_bank_account")
if not account: if not account:
account = frappe.db.get_value("Account", account_list = frappe.get_all("Account", filters = {"company": company,
{"company": company, "account_type": "Bank", "is_group": 0}) "account_type": "Bank", "is_group": 0})
if len(account_list) > 0:
account = account_list[0].name
elif account_type=="Cash": elif account_type=="Cash":
account = frappe.db.get_value("Company", company, "default_cash_account") account = frappe.db.get_value("Company", company, "default_cash_account")
if not account: if not account:
account = frappe.db.get_value("Account", account_list = frappe.get_all("Account", filters = {"company": company,
{"company": company, "account_type": "Cash", "is_group": 0}) "account_type": "Cash", "is_group": 0})
if len(account_list) > 0:
account = account_list[0].name
if account: if account:
account_details = frappe.db.get_value("Account", account, account_details = frappe.db.get_value("Account", account,