From 31cb27154a853687e86c1b2835f520b98c618cb4 Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Mon, 12 Oct 2015 14:17:40 +0200 Subject: [PATCH] [FIX] board: creating a dashboard Introduced by 72e94beeb5c12602bbe71ea68bf22f48c3032047 opw:651811 --- addons/board/board.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/addons/board/board.py b/addons/board/board.py index a69bcd1857f..b484e7546ad 100644 --- a/addons/board/board.py +++ b/addons/board/board.py @@ -13,6 +13,29 @@ class board_board(osv.osv): _auto = False _columns = {} + @tools.cache() + def list(self, cr, uid, context=None): + Actions = self.pool.get('ir.actions.act_window') + Menus = self.pool.get('ir.ui.menu') + IrValues = self.pool.get('ir.values') + + act_ids = Actions.search(cr, uid, [('res_model', '=', self._name)], context=context) + refs = ['%s,%s' % (Actions._name, act_id) for act_id in act_ids] + + # cannot search "action" field on menu (non stored function field without search_fnct) + irv_ids = IrValues.search(cr, uid, [ + ('model', '=', 'ir.ui.menu'), + ('key', '=', 'action'), + ('key2', '=', 'tree_but_open'), + ('value', 'in', refs), + ], context=context) + menu_ids = map(itemgetter('res_id'), IrValues.read(cr, uid, irv_ids, ['res_id'], context=context)) + menu_names = Menus.name_get(cr, uid, menu_ids, context=context) + return [dict(id=m[0], name=m[1]) for m in menu_names] + + def _clear_list_cache(self): + self.list.clear_cache(self) + def create(self, cr, user, vals, context=None): return 0