diff options
Diffstat (limited to 'odoo/addons/test_performance/tests/test_performance.py')
| -rw-r--r-- | odoo/addons/test_performance/tests/test_performance.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/odoo/addons/test_performance/tests/test_performance.py b/odoo/addons/test_performance/tests/test_performance.py index 01bab7187e2..7ace0d3ea96 100644 --- a/odoo/addons/test_performance/tests/test_performance.py +++ b/odoo/addons/test_performance/tests/test_performance.py @@ -65,6 +65,24 @@ class TestPerformance(SavepointCaseWithUserDemo): for record in records: record.value_pc + @warmup + def test_read_base_depends_context(self): + """ Compute in batch even when in cache in another context. """ + records = self.env['test_performance.base'].search([]) + self.assertEqual(len(records), 5) + + with self.assertQueryCount(1): + for record in records.with_context(key=1): + self.assertEqual(record.value_ctx, 1) + + with self.assertQueryCount(1): + for record in records.with_context(key=2): + self.assertEqual(record.value_ctx, 2) + + with self.assertQueryCount(1): + for record in records: + self.assertEqual(record.with_context(key=3).value_ctx, 3) + @users('__system__', 'demo') @warmup def test_write_base(self): |
