From dcc90e3312ffccee0a40c3347a52b7949115d109 Mon Sep 17 00:00:00 2001 From: Suraj Shetty Date: Fri, 4 May 2018 17:52:57 +0530 Subject: [PATCH] Add fix to support changes in user permission (#13923) https://github.com/frappe/frappe/pull/5494 --- erpnext/accounts/party.py | 16 ++++++++-------- .../warehouse_wise_item_balance_age_and_value.py | 8 +++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 6f272cf833..f7179d6b5b 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -130,15 +130,15 @@ def get_default_price_list(party): def set_price_list(out, party, party_type, given_price_list): # price list - price_list = filter(None, get_user_permissions().get("Price List", [])) - if isinstance(price_list, list): - price_list = price_list[0] if len(price_list)==1 else None + price_list = filter(None, get_user_permissions() + .get("Price List", {}) + .get("docs", [])) + price_list = list(price_list) - if not price_list: - price_list = get_default_price_list(party) - - if not price_list: - price_list = given_price_list + if price_list: + price_list = price_list[0] + else: + price_list = get_default_price_list(party) or given_price_list if price_list: out.price_list_currency = frappe.db.get_value("Price List", price_list, "currency") 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 c5fb51809a..d73f83d559 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 @@ -39,7 +39,7 @@ def execute(filters=None): item_value.setdefault((item, item_map[item]["item_group"]),[]) item_value[(item, item_map[item]["item_group"])].append(total_stock_value) - + # sum bal_qty by item for (item, item_group), wh_balance in item_balance.items(): total_stock_value = sum(item_value[(item, item_group)]) @@ -87,7 +87,9 @@ def validate_filters(filters): def get_warehouse_list(filters): from frappe.defaults import get_user_permissions condition = '' - user_permitted_warehouse = filter(None, get_user_permissions().get("Warehouse", [])) + user_permitted_warehouse = filter(None, get_user_permissions() + .get("Warehouse", {}) + .get("docs", [])) value = () if user_permitted_warehouse: condition = "and name in %s" @@ -96,7 +98,7 @@ def get_warehouse_list(filters): condition = "and name = %s" value = filters.get("warehouse") - return frappe.db.sql("""select name + return frappe.db.sql("""select name from `tabWarehouse` where is_group = 0 {condition}""".format(condition=condition), value, as_dict=1)