'Sync portal menu items'

def sync_menu(self):

    dirty = False
    for item in frappe.get_hooks(u'standard_portal_menu_items'):
        if (item.get(u'role') and (not frappe.db.exists(u'Role', item.get(u'role')))):
            frappe.get_doc({u'doctype': u'Role', u'role_name': item.get(u'role'), u'desk_access': 0}).insert()
        if self.add_item(item):
            dirty = True
    if dirty:
        self.save()
