Commonify code
- use get_permitted_documents function to avoid code redundancy
This commit is contained in:
parent
7ae2d59ffd
commit
7ed37ae6c3
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import frappe, erpnext
|
import frappe, erpnext
|
||||||
from frappe import _, msgprint, scrub
|
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.model.utils import get_fetch_values
|
||||||
from frappe.utils import (add_days, getdate, formatdate, date_diff,
|
from frappe.utils import (add_days, getdate, formatdate, date_diff,
|
||||||
add_years, get_timestamp, nowdate, flt, add_months, get_last_day)
|
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):
|
def set_price_list(out, party, party_type, given_price_list):
|
||||||
# price list
|
# price list
|
||||||
price_list = [d.get('doc') for d in get_user_permissions().get('Price List', []) \
|
price_list = get_permitted_documents('Price List')
|
||||||
if d.get('doc')]
|
|
||||||
|
|
||||||
if price_list:
|
if price_list:
|
||||||
price_list = price_list[0]
|
price_list = price_list[0]
|
||||||
|
@ -85,10 +85,10 @@ def validate_filters(filters):
|
|||||||
filters["company"] = frappe.defaults.get_user_default("Company")
|
filters["company"] = frappe.defaults.get_user_default("Company")
|
||||||
|
|
||||||
def get_warehouse_list(filters):
|
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 = ''
|
condition = ''
|
||||||
user_permitted_warehouse = [d.get('doc') for d in get_user_permissions().get('Warehouse', []) \
|
user_permitted_warehouse = get_permitted_documents('Warehouse')
|
||||||
if d.get('doc')]
|
|
||||||
value = ()
|
value = ()
|
||||||
if user_permitted_warehouse:
|
if user_permitted_warehouse:
|
||||||
condition = "and name in %s"
|
condition = "and name in %s"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user