diff --git a/odoo/addons/test_performance/tests/test_performance.py b/odoo/addons/test_performance/tests/test_performance.py index dd4e147b07b..f3ba19a68ae 100644 --- a/odoo/addons/test_performance/tests/test_performance.py +++ b/odoo/addons/test_performance/tests/test_performance.py @@ -75,20 +75,26 @@ class TestPerformance(TransactionCase): 'tag_ids': [(0, 0, {'name': val}) for val in range(10)], }) - - @queryCount(admin=5, demo=5) + @users('admin', 'demo') + @warmup def test_several_prefetch(self): initial_records = self.env['test_performance.base'].search([]) self.assertEqual(len(initial_records), 5) - for i in range(8): - self.env.cr.execute('insert into test_performance_base(value) select value from test_performance_base') + for _i in range(8): + self.env.cr.execute( + 'insert into test_performance_base(value) select value from test_performance_base' + ) records = self.env['test_performance.base'].search([]) self.assertEqual(len(records), 1280) - self.resetQueryCount() # should only cause 2 queries thanks to prefetching - records.mapped('value') - records.invalidate_cache(['value']) - # should only cause 2 queries thanks to prefetching - with self.env.do_in_onchange(): + with self.assertQueryCount(admin=2, demo=2): records.mapped('value') - self.env.cr.execute('delete from test_performance_base where id not in %s', (tuple(initial_records.ids),)) \ No newline at end of file + records.invalidate_cache(['value']) + + with self.assertQueryCount(admin=2, demo=2): + with self.env.do_in_onchange(): + records.mapped('value') + self.env.cr.execute( + 'delete from test_performance_base where id not in %s', + (tuple(initial_records.ids),) + )