improve mode_of_payment validate_accounts
using frappe.db.get_value instead of frappe.get_list
diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py
index 4a9ea9c..36d54b6 100644
--- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py
+++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py
@@ -24,13 +24,5 @@
def validate_accounts(self):
for entry in self.accounts:
"""Error when Company of Ledger account doesn't match with Company Selected"""
- account = frappe.get_list("Account",
- fields=["name"],
- filters = {
- "company": entry.company,
- "name": entry.default_account
- })
- try:
- account[0].name
- except IndexError:
+ if frappe.db.get_value("Account", entry.default_account, "company") != entry.company:
frappe.throw(_("Account does not match with Company"))