diff --git a/trytond/ir/ui/menu.py b/trytond/ir/ui/menu.py
index 0cdc90e5e4..a99eeeebc9 100644
--- a/trytond/ir/ui/menu.py
+++ b/trytond/ir/ui/menu.py
@@ -225,27 +225,4 @@ class UIMenu(OSV):
new_id, '', context.get('module')))
return new_id
- def search(self, cursor, user, args, offset=0, limit=2000, order=None,
- context=None, count=False, query_string=False):
- res_user_obj = self.pool.get('res.user')
- if context is None:
- context = {}
- ids = super(UIMenu, self).search(cursor, user, args, offset, limit,
- order, context=context)
- user_groups = res_user_obj.read(cursor, user, [user])[0]['groups_id']
- result = []
- for menu in self.browse(cursor, user, ids):
- if not len(menu.groups):
- result.append(menu.id)
- continue
- for group in menu.groups:
- if group.id in user_groups:
- result.append(menu.id)
- break
- if count:
- return len(result)
- if query_string:
- return (','.join(['%d' for x in result]), result)
- return result
-
UIMenu()
diff --git a/trytond/osv/orm.py b/trytond/osv/orm.py
index b9d49264a7..109c1eba50 100644
--- a/trytond/osv/orm.py
+++ b/trytond/osv/orm.py
@@ -1471,6 +1471,12 @@ class ORM(object):
self._validate(cursor, user, ids)
+ # Restart rule cache
+ if self.pool.get('ir.rule.group').search(cursor, 0, [
+ ('model.model', '=', self._name),
+ ], context=context):
+ self.pool.get('ir.rule').domain_get()
+
if context.has_key('read_delta'):
del context['read_delta']
@@ -2069,8 +2075,22 @@ class ORM(object):
args[i][1], context=context)]
else:
res_ids = args[i][2]
- if not len(res_ids):
- args[i] = ('id', 'in', [0])
+ if res_ids == False:
+ cursor.execute('SELECT id ' \
+ 'FROM "' + self._table + '" ' \
+ 'WHERE id NOT IN ( ' \
+ 'SELECT "' + field._id1 + '" ' \
+ 'FROM "' + field._rel + '" ' \
+ ')')
+ args[i] = ('id', 'in',
+ [x[0] for x in cursor.fetchall()])
+ elif res_ids == True:
+ cursor.execute('SELECT "' + field._id1 + '" ' \
+ 'FROM "' + field._rel + '"')
+ args[i] = ('id', 'in',
+ [x[0] for x in cursor.fetchall()])
+ elif not res_ids:
+ args[i] = ('id', '=', '0')
else:
cursor.execute(
'SELECT "' + field._id1 + '" ' \
diff --git a/trytond/res/ir.xml b/trytond/res/ir.xml
index cb107cfabb..72e123ffd2 100644
--- a/trytond/res/ir.xml
+++ b/trytond/res/ir.xml
@@ -376,5 +376,21 @@
+
+
+