'Return for each menu entry in ``self``:
- whether it uses the needaction mechanism (needaction_enabled)
- the needaction counter of the related action, taking into account
the action domain'

@api.multi
def get_needaction_data(self):

    menu_ids = set()
    for menu in self:
        menu_ids.add(menu.id)
        ctx = {}
        if (menu.action and (menu.action.type in ('ir.actions.act_window', 'ir.actions.client')) and menu.action.context):
            with tools.ignore(Exception):
                eval_ctx = tools.UnquoteEvalContext(self._context)
                ctx = (safe_eval(menu.action.context, locals_dict=eval_ctx, nocopy=True) or {})
        menu_refs = ctx.get('needaction_menu_ref')
        if menu_refs:
            if (not isinstance(menu_refs, list)):
                menu_refs = [menu_refs]
            for menu_ref in menu_refs:
                record = self.env.ref(menu_ref, False)
                if (record and (record._name == 'ir.ui.menu')):
                    menu_ids.add(record.id)
    res = {}
    for menu in self.browse(menu_ids):
        res[menu.id] = {'needaction_enabled': False, 'needaction_counter': False}
        if (menu.action and (menu.action.type in ('ir.actions.act_window', 'ir.actions.client')) and menu.action.res_model):
            if (menu.action.res_model in self.env):
                model = self.env[menu.action.res_model]
                if model._needaction:
                    if (menu.action.type == 'ir.actions.act_window'):
                        eval_context = self.env['ir.actions.act_window']._get_eval_context()
                        dom = safe_eval((menu.action.domain or '[]'), eval_context)
                    else:
                        dom = safe_eval((menu.action.params_store or '{}'), {'uid': self._uid}).get('domain')
                    res[menu.id]['needaction_enabled'] = model._needaction
                    res[menu.id]['needaction_counter'] = model._needaction_count(dom)
    return res
