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:
parent
87c1a9d7d7
commit
e03525efba
1 changed files with 7 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue