[REV] ir_ui_menu: needaction on menus back to their previous state (as in current trunk as ok 2012/12/04; another branch exist for speeding them up, this one is for improving the parsing.

bzr revid: tde@openerp.com-20121204145608-lah4uk40ok5litf0
This commit is contained in:
Thibault Delavallée 2012-12-04 15:56:08 +01:00
parent 9e6c2805ab
commit 52bd6459ef
1 changed files with 7 additions and 14 deletions

View File

@ -265,18 +265,7 @@ class ir_ui_menu(osv.osv):
return res
def _get_needaction_enabled(self, cr, uid, ids, field_names, args, context=None):
""" needaction_enabled: tell whether the menu has a related action
that uses the needaction mechanism. """
res = dict.fromkeys(ids, False)
for menu in self.browse(cr, uid, ids, context=context):
if menu.action and menu.action.type in ('ir.actions.act_window', 'ir.actions.client') and menu.action.res_model:
obj = self.pool.get(menu.action.res_model)
if obj and obj._needaction:
res[menu.id] = True
return res
def get_needaction_data(self, cr, uid, ids, context=None):
def get_needaction_data(self, cr, uid, ids, field_names, args, context=None):
""" Return for each menu entry of ids :
- if it uses the needaction mechanism (needaction_enabled)
- the needaction counter of the related action, taking into account
@ -315,11 +304,15 @@ class ir_ui_menu(osv.osv):
'web_icon_hover': fields.char('Web Icon File (hover)', size=128),
'web_icon_data': fields.function(_get_image_icon, string='Web Icon Image', type='binary', readonly=True, store=True, multi='icon'),
'web_icon_hover_data': fields.function(_get_image_icon, string='Web Icon Image (hover)', type='binary', readonly=True, store=True, multi='icon'),
'needaction_enabled': fields.function(_get_needaction_enabled,
type='boolean',
'needaction_enabled': fields.function(get_needaction_data,
type='boolean', multi='get_needaction_data',
store=True,
string='Target model uses the need action mechanism',
help='If the menu entry action is an act_window action, and if this action is related to a model that uses the need_action mechanism, this field is set to true. Otherwise, it is false.'),
'needaction_counter': fields.function(get_needaction_data,
type='integer', multi='get_needaction_data',
string='Number of actions the user has to perform',
help='If the target model uses the need action mechanism, this field gives the number of actions the current user has to perform.'),
'action': fields.function(_action, fnct_inv=_action_inv,
type='reference', string='Action',
selection=[