From 3234f0d299a420c010b0bf76446847e42bc6fe72 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Mon, 12 Aug 2019 16:18:36 +0530 Subject: [PATCH] fix: Check if account passed is accessible under Payment Entry --- .../accounts/doctype/payment_entry/payment_entry.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py index 8c2ea73b56..3e1bd62ee9 100644 --- a/erpnext/accounts/doctype/payment_entry/payment_entry.py +++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py @@ -755,6 +755,17 @@ def get_party_details(company, party_type, party, date, cost_center=None): @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),