1
=== modified file 'openerp/addons/base/ir/ir_ui_menu.py'
2
--- openerp/addons/base/ir/ir_ui_menu.py 2013-05-07 10:40:25 +0000
3
+++ openerp/addons/base/ir/ir_ui_menu.py 2013-07-18 11:15:26 +0000
8
+ def _children_needaction_enabled(self, menu):
9
+ """return True if at least one descendant menu item uses the needaction mechanism"""
11
+ for child in menu.child_id:
12
+ if child.action and child.action.type in ('ir.actions.act_window', 'ir.actions.client') and child.action.res_model:
13
+ obj = self.pool.get(child.action.res_model)
14
+ if obj and obj._needaction:
17
+ return self._children_needaction_enabled(child)
21
def _get_needaction_enabled(self, cr, uid, ids, field_names, args, context=None):
22
""" needaction_enabled: tell whether the menu has a related action
23
that uses the needaction mechanism. """
25
obj = self.pool.get(menu.action.res_model)
26
if obj and obj._needaction:
29
+ if self._children_needaction_enabled(menu):
33
def get_needaction_data(self, cr, uid, ids, context=None):
35
dom = eval(menu.action.params_store or '{}', {'uid': uid}).get('domain')
36
res[menu.id]['needaction_enabled'] = obj._needaction
37
res[menu.id]['needaction_counter'] = obj._needaction_count(cr, uid, dom, context=context)
39
+ counter = self._get_needaction_counter(cr, uid, menu, context=context)
41
+ res[menu.id]['needaction_enabled'] = True
42
+ res[menu.id]['needaction_counter'] = counter
45
+ def _get_needaction_counter(self, cr, uid, menu, context=None):
49
+ for child in menu.child_id:
52
+ if child.action and child.action.type in ('ir.actions.act_window', 'ir.actions.client') and child.action.res_model:
53
+ obj = self.pool.get(child.action.res_model)
54
+ if obj and obj._needaction:
55
+ if child.action.type == 'ir.actions.act_window':
56
+ dom = child.action.domain and eval(child.action.domain, {'uid': uid}) or []
58
+ dom = eval(child.action.params_store or '{}', {'uid': uid}).get('domain')
59
+ counter = obj._needaction_count(cr, uid, dom, context=context)
61
+ if r['obj'] == obj._name:
63
+ if r['count'] < counter:
64
+ r['count'] = counter
66
+ res_list.append({'obj': obj._name,
69
+ total +=self._get_needaction_counter(cr, uid, child, context=context)
76
'name': fields.char('Menu', size=64, required=True, translate=True),