Merge pull request #4671 from Zlash65/listdown-valid-doctype

Listdown doman-activated doctype in Contacts & Address
This commit is contained in:
Prateeksha Singh 2018-01-08 12:53:41 +05:30 committed by GitHub
commit b1ccc5d35a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -146,4 +146,18 @@ def filter_dynamic_link_doctypes(doctype, txt, searchfield, start, page_len, fil
order_by="dt asc", as_list=True)
all_doctypes = doctypes + _doctypes
return sorted(all_doctypes, key=lambda item: item[0])
valid_doctypes = []
user_roles = frappe.get_roles()
for ctype in all_doctypes:
if frappe.db.exists('Custom DocPerm', {"parent": ctype[0]}):
dtype = 'Custom DocPerm'
else:
dtype = 'DocPerm'
valid_doctypes.append(frappe.db.get_all(dtype, {
'parent': ctype[0],
'role': ('in', user_roles)
}, 'distinct parent', as_list=True))
return sorted(valid_doctypes, key=lambda item: item[0])