fix: check if doctype exists

This commit is contained in:
Himanshu Warekar 2019-09-27 16:27:10 +05:30
parent 204867e649
commit 04fa1b5957

View file

@ -42,6 +42,7 @@ def reset_global_search_settings_doctypes():
def update_global_search_doctypes():
global_search_doctypes = frappe.get_hooks("global_search_doctypes")
doctype_list = set([dt.name for dt in frappe.get_list("DocType")])
allowed_in_global_search = []
for dt in global_search_doctypes:
@ -54,6 +55,9 @@ def update_global_search_doctypes():
global_search_settings = frappe.get_single("Global Search Settings")
global_search_settings.allowed_in_global_search = []
for dt in allowed_in_global_search:
if dt not in doctype_list:
continue
global_search_settings.append("allowed_in_global_search", {
"document_type": dt
})