From 7ed37ae6c3ba7d556d650a5b0d2540941b2846ac Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Wed, 19 Dec 2018 19:56:42 +0530 Subject: [PATCH] Commonify code - use get_permitted_documents function to avoid code redundancy --- erpnext/accounts/party.py | 5 ++--- .../warehouse_wise_item_balance_age_and_value.py | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index d72a7a6b65..1085cddab5 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals 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 get_default_price_list(party): 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 7628368051..176a221064 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 @@ def validate_filters(filters): 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"