diff options
| author | Raphael Collet <rco@odoo.com> | 2019-04-11 08:21:54 +0000 |
|---|---|---|
| committer | Raphael Collet <rco@odoo.com> | 2019-05-23 05:47:11 +0000 |
| commit | d0bb596f1d51b72a6aa20d56eef3e65aefbd09b2 (patch) | |
| tree | 8d56a32b6f0eea496d0e9af26a4349e8979dfc37 /odoo/addons/test_performance | |
| parent | 60be9f2c098cfead8a5e3fd23453b7e93243e0c5 (diff) | |
[IMP] fields: x2many fields of new records are new records
The value of an x2many field on a new record are new records, possibly
related to a real record, called its "origin".
Diffstat (limited to 'odoo/addons/test_performance')
| -rw-r--r-- | odoo/addons/test_performance/tests/test_performance.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/odoo/addons/test_performance/tests/test_performance.py b/odoo/addons/test_performance/tests/test_performance.py index 7ea5fbcdadc..c05a62cc4d9 100644 --- a/odoo/addons/test_performance/tests/test_performance.py +++ b/odoo/addons/test_performance/tests/test_performance.py @@ -355,14 +355,26 @@ class TestPerformance(TransactionCase): ) records = self.env['test_performance.base'].search([]) self.assertEqual(len(records), 1280) + # should only cause 2 queries thanks to prefetching with self.assertQueryCount(__system__=2, demo=2): records.mapped('value') + records.invalidate_cache(['value']) + with self.assertQueryCount(__system__=2, demo=2): + records.mapped('value') + records.invalidate_cache(['value']) + with self.assertQueryCount(__system__=2, demo=2): + new_recs = records.browse(records.new(origin=record).id for record in records) + new_recs.mapped('value') + + records.invalidate_cache(['value']) with self.assertQueryCount(__system__=2, demo=2): with self.env.do_in_onchange(): records.mapped('value') + + # clean up after each pass self.env.cr.execute( 'delete from test_performance_base where id not in %s', (tuple(initial_records.ids),) |
