diff options
| -rw-r--r-- | odoo/addons/test_access_rights/tests/test_ir_rules.py | 20 | ||||
| -rw-r--r-- | odoo/osv/expression.py | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/odoo/addons/test_access_rights/tests/test_ir_rules.py b/odoo/addons/test_access_rights/tests/test_ir_rules.py index c1ce6cc6b80..6724bdbf1e4 100644 --- a/odoo/addons/test_access_rights/tests/test_ir_rules.py +++ b/odoo/addons/test_access_rights/tests/test_ir_rules.py @@ -35,6 +35,26 @@ class TestRules(TransactionCase): with self.assertRaises(AccessError): self.assertEqual(browse2.val, -1) + def test_group_rule(self): + env = self.env(user=self.browse_ref('base.public_user')) + + # we forbid access to the public group, to which the public user belongs + self.env['ir.rule'].create({ + 'name': 'Forbid public group', + 'model_id': self.browse_ref('test_access_rights.model_test_access_right_some_obj').id, + 'groups': [(6, 0, [self.browse_ref('base.group_public').id])], + 'domain_force': "[(0, '=', 1)]" + }) + + browse2 = env['test_access_right.some_obj'].browse(self.id2) + browse1 = env['test_access_right.some_obj'].browse(self.id1) + + # everything should blow up + with self.assertRaises(AccessError): + self.assertEqual(browse2.val, -1) + with self.assertRaises(AccessError): + self.assertEqual(browse1.val, 1) + def test_many2many(self): """ Test assignment of many2many field where rules apply. """ ids = [self.id1, self.id2] diff --git a/odoo/osv/expression.py b/odoo/osv/expression.py index 483f325322c..f5518fead94 100644 --- a/odoo/osv/expression.py +++ b/odoo/osv/expression.py @@ -251,6 +251,8 @@ def combine(operator, unit, zero, domains): """ result = [] count = 0 + if domains == [unit]: + return unit for domain in domains: if domain == unit: continue |
