fix: remove items linked to non-existing doctypes from portal settings (#22417)

* fix: remove non-existing ref doctypes from portal settings

* fix: use separate list to iterate
This commit is contained in:
Gursheen Kaur Anand 2023-09-15 15:06:51 +05:30 committed by GitHub
parent 87c1a9d7d7
commit e03525efba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,6 +49,7 @@ class PortalSettings(Document):
dirty = True
if dirty:
self.remove_deleted_doctype_items()
self.save()
def on_update(self):
@ -65,3 +66,9 @@ class PortalSettings(Document):
# clears role based home pages
frappe.clear_cache()
def remove_deleted_doctype_items(self):
existing_doctypes = set(frappe.get_list("DocType", pluck="name"))
for menu_item in list(self.get("menu")):
if menu_item.reference_doctype not in existing_doctypes:
self.remove(menu_item)