~initos.com/openerp-hr/7.0-add-holiday-weekend

« back to all changes in this revision

Viewing changes to patches/openobject-server-openerp-addons-base-ir-ir_ui_menu.patch.txt

  • Committer: Maxime Chambreuil
  • Date: 2013-09-28 15:04:52 UTC
  • Revision ID: maxime.chambreuil@savoirfairelinux.com-20130928150452-vsxz2dmfedj5bdn2
[DEL] openobject-server patch
[REN] hr_payroll patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
4
 
@@ -281,6 +281,19 @@
5
 
 
6
 
         return res
7
 
 
8
 
+    def _children_needaction_enabled(self, menu):
9
 
+        """return True if at least one descendant menu item uses the needaction mechanism"""
10
 
+        
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:
15
 
+                    return True
16
 
+            else:
17
 
+                return self._children_needaction_enabled(child)
18
 
+        
19
 
+        return False
20
 
+    
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. """
24
 
@@ -290,6 +303,9 @@
25
 
                 obj = self.pool.get(menu.action.res_model)
26
 
                 if obj and obj._needaction:
27
 
                     res[menu.id] = True
28
 
+            else:
29
 
+                if self._children_needaction_enabled(menu):
30
 
+                    res[menu.id] = True
31
 
         return res
32
 
 
33
 
     def get_needaction_data(self, cr, uid, ids, context=None):
34
 
@@ -338,7 +354,42 @@
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)
38
 
+            else:
39
 
+                counter = self._get_needaction_counter(cr, uid, menu, context=context)
40
 
+                if counter > 0:
41
 
+                    res[menu.id]['needaction_enabled'] = True
42
 
+                    res[menu.id]['needaction_counter'] = counter
43
 
         return res
44
 
+    
45
 
+    def _get_needaction_counter(self, cr, uid, menu, context=None):
46
 
+        
47
 
+        total = 0
48
 
+        res_list = []
49
 
+        for child in menu.child_id:
50
 
+            found = False
51
 
+            counter = 0
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 []
57
 
+                    else:
58
 
+                        dom = eval(child.action.params_store or '{}', {'uid': uid}).get('domain')
59
 
+                    counter = obj._needaction_count(cr, uid, dom, context=context)
60
 
+                    for r in res_list:
61
 
+                        if r['obj'] == obj._name:
62
 
+                            found = True
63
 
+                            if r['count'] < counter:
64
 
+                                r['count'] = counter
65
 
+                    if not found:
66
 
+                        res_list.append({'obj': obj._name,
67
 
+                                         'count': counter})
68
 
+            else:
69
 
+                total +=self._get_needaction_counter(cr, uid, child, context=context)
70
 
+        
71
 
+        for r in res_list:
72
 
+            total += r['count']
73
 
+        return total
74
 
 
75
 
     _columns = {
76
 
         'name': fields.char('Menu', size=64, required=True, translate=True),
77