Commonify code
- use get_permitted_documents function to avoid code redundancy
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index d72a7a6..1085cdd 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -5,7 +5,7 @@
import frappe, erpnext
from frappe import _, msgprint, scrub
-from frappe.defaults import get_user_permissions
+from frappe.core.doctype.user_permission.user_permission import get_permitted_documents
from frappe.model.utils import get_fetch_values
from frappe.utils import (add_days, getdate, formatdate, date_diff,
add_years, get_timestamp, nowdate, flt, add_months, get_last_day)
@@ -151,8 +151,7 @@
def set_price_list(out, party, party_type, given_price_list):
# price list
- price_list = [d.get('doc') for d in get_user_permissions().get('Price List', []) \
- if d.get('doc')]
+ price_list = get_permitted_documents('Price List')
if price_list:
price_list = price_list[0]
diff --git a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py
index 7628368..176a221 100644
--- a/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py
+++ b/erpnext/stock/report/warehouse_wise_item_balance_age_and_value/warehouse_wise_item_balance_age_and_value.py
@@ -85,10 +85,10 @@
filters["company"] = frappe.defaults.get_user_default("Company")
def get_warehouse_list(filters):
- from frappe.defaults import get_user_permissions
+ from frappe.core.doctype.user_permission.user_permission import get_permitted_documents
+
condition = ''
- user_permitted_warehouse = [d.get('doc') for d in get_user_permissions().get('Warehouse', []) \
- if d.get('doc')]
+ user_permitted_warehouse = get_permitted_documents('Warehouse')
value = ()
if user_permitted_warehouse:
condition = "and name in %s"