[IMP] core: avoid to check access rules on empty recordset
Checking access rules only makes sence if we have some records, _filter_access_rules will always return a subset or current recordset, and a subset or a empty recordset is an empty recordset. closes odoo/odoo#32313 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
@@ -76,3 +76,9 @@ class TestRules(TransactionCase):
|
||||
container_user.write({'some_ids': [(5,)]})
|
||||
self.assertItemsEqual(container_user.some_ids.ids, [])
|
||||
self.assertItemsEqual(container_admin.some_ids.ids, [self.id2])
|
||||
|
||||
def test_access_rule_performance(self):
|
||||
env = self.env(user=self.browse_ref('base.public_user'))
|
||||
Model = env['test_access_right.some_obj']
|
||||
with self.assertQueryCount(0):
|
||||
Model._filter_access_rules('read')
|
||||
|
||||
@@ -3102,6 +3102,9 @@ Fields:
|
||||
if self._uid == SUPERUSER_ID:
|
||||
return self
|
||||
|
||||
if not self._ids:
|
||||
return self
|
||||
|
||||
if self.is_transient():
|
||||
# Only one single implicit access rule for transient models: owner only!
|
||||
# This is ok to hardcode because we assert that TransientModels always
|
||||
|
||||
Reference in New Issue
Block a user