'Return the ids of the menu items visible to the user.'

@api.model
@tools.ormcache('frozenset(self.env.user.groups_id.ids)', 'debug')
def _visible_menu_ids(self, debug=False):

    context = {'ir.ui.menu.full_list': True}
    menus = self.with_context(context).search([])
    groups = self.env.user.groups_id
    if (not debug):
        groups = (groups - self.env.ref('base.group_no_one'))
    menus = menus.filtered((lambda menu: ((not menu.groups_id) or (menu.groups_id & groups))))
    action_menus = menus.filtered((lambda m: (m.action and m.action.exists())))
    folder_menus = (menus - action_menus)
    visible = self.browse()
    access = self.env['ir.model.access']
    model_fname = {'ir.actions.act_window': 'res_model', 'ir.actions.report.xml': 'model', 'ir.actions.server': 'model_id'}
    for menu in action_menus:
        fname = model_fname.get(menu.action._name)
        if ((not fname) or (not menu.action[fname]) or access.check(menu.action[fname], 'read', False)):
            visible += menu
            menu = menu.parent_id
            while (menu and (menu in folder_menus) and (menu not in visible)):
                visible += menu
                menu = menu.parent_id
    return set(visible.ids)
