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
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 790003c..6864305 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -569,14 +569,18 @@
if account_type=="Bank":
account = frappe.db.get_value("Company", company, "default_bank_account")
if not account:
- account = frappe.db.get_value("Account",
- {"company": company, "account_type": "Bank", "is_group": 0})
+ account_list = frappe.get_all("Account", filters = {"company": company,
+ "account_type": "Bank", "is_group": 0})
+ if len(account_list) > 0:
+ account = account_list[0].name
elif account_type=="Cash":
account = frappe.db.get_value("Company", company, "default_cash_account")
if not account:
- account = frappe.db.get_value("Account",
- {"company": company, "account_type": "Cash", "is_group": 0})
+ account_list = frappe.get_all("Account", filters = {"company": company,
+ "account_type": "Cash", "is_group": 0})
+ if len(account_list) > 0:
+ account = account_list[0].name
if account:
account_details = frappe.db.get_value("Account", account,