fix: Check if account passed is accessible under Payment Entry
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 8c2ea73..3e1bd62 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -755,6 +755,17 @@
@frappe.whitelist()
def get_account_details(account, date, cost_center=None):
frappe.has_permission('Payment Entry', throw=True)
+
+ # to check if passed account is accessible under Payment Entry
+ # There might be user permissions which can only allow account under certain doctypes
+ # except Payment Entry
+ account_list = frappe.get_list('Account', {
+ 'name': account
+ }, reference_doctype='Payment Entry', limit=1)
+
+ if not account_list:
+ frappe.throw(_('Account: {0} is not permitted under Payment Entry').format(account))
+
return frappe._dict({
"account_currency": get_account_currency(account),
"account_balance": get_balance_on(account, date, cost_center=cost_center),