[IMP] various: update query counters

Update query counters now that fields are editable computed fields. Some
counters are higher as the usage of composer in code is now closer to the
usage in view, with fields being correctly computed. Some other counters
are a bit lessened, but it globally stays the same.

Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#107356
This commit is contained in:
Thibault Delavallée
2023-01-27 19:56:08 +01:00
parent 300ae603d1
commit 6218d84f04
2 changed files with 43 additions and 43 deletions
+41 -41
View File
@@ -216,19 +216,19 @@ class TestBaseMailPerformance(BaseMailPerformance):
@warmup
def test_create_mail_with_tracking(self):
""" Create records inheriting from 'mail.thread' (with field tracking). """
with self.assertQueryCount(admin=8, demo=8):
with self.assertQueryCount(admin=7, demo=7):
self.env['mail.performance.thread'].create({'name': 'X'})
@users('admin', 'employee')
@warmup
def test_create_mail_simple(self):
with self.assertQueryCount(admin=7, employee=7):
with self.assertQueryCount(admin=6, employee=6):
self.env['mail.test.simple'].create({'name': 'Test'})
@users('admin', 'employee')
@warmup
def test_create_mail_simple_multi(self):
with self.assertQueryCount(admin=7, employee=7):
with self.assertQueryCount(admin=6, employee=6):
self.env['mail.test.simple'].create([{'name': 'Test'}] * 5)
@users('admin', 'employee')
@@ -256,7 +256,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_adv_activity(self):
model = self.env['mail.test.activity']
with self.assertQueryCount(admin=7, employee=7):
with self.assertQueryCount(admin=6, employee=6):
model.create({'name': 'Test'})
@users('admin', 'employee')
@@ -321,7 +321,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
record.write({'name': 'Dupe write'})
with self.assertQueryCount(admin=19, employee=19): # com+tm 18/18
with self.assertQueryCount(admin=18, employee=18): # com+tm 17/17
record.action_close('Dupe feedback', attachment_ids=attachments.ids)
# notifications
@@ -337,7 +337,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_mail_composer(self):
test_record, _test_template = self._create_test_records()
customer_id = self.customer.id
with self.assertQueryCount(admin=4, employee=4):
with self.assertQueryCount(admin=3, employee=3):
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': test_record._name,
@@ -347,7 +347,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer_id)],
})
with self.assertQueryCount(admin=32, employee=32):
with self.assertQueryCount(admin=29, employee=29):
composer._action_send_mail()
@users('admin', 'employee')
@@ -357,7 +357,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
test_record, _test_template = self._create_test_records()
customer = self.env['res.partner'].browse(self.customer.ids)
attachments = self.env['ir.attachment'].with_user(self.env.user).create(self.test_attachments_vals)
with self.assertQueryCount(admin=5, employee=5):
with self.assertQueryCount(admin=3, employee=3):
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': test_record._name,
@@ -368,7 +368,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer.id)],
})
with self.assertQueryCount(admin=37, employee=37):
with self.assertQueryCount(admin=33, employee=33):
composer._action_send_mail()
@users('admin', 'employee')
@@ -378,7 +378,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
test_record, _test_template = self._create_test_records()
customer = self.env['res.partner'].browse(self.customer.ids)
attachments = self.env['ir.attachment'].with_user(self.env.user).create(self.test_attachments_vals)
with self.assertQueryCount(admin=13, employee=13): # tm 12/12
with self.assertQueryCount(admin=11, employee=11):
composer_form = Form(
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
@@ -392,7 +392,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
composer_form.attachment_ids.add(attachment)
composer = composer_form.save()
with self.assertQueryCount(admin=47, employee=47): # tm+com 46/46
with self.assertQueryCount(admin=43, employee=43): # tm+com 42/42
composer._action_send_mail()
# notifications
@@ -406,7 +406,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_mail_composer_mass_w_template(self):
_partners, test_records, test_template = self._create_test_records_for_batch()
with self.assertQueryCount(admin=4, employee=4):
with self.assertQueryCount(admin=3, employee=3):
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'mass_mail',
'default_model': test_records._name,
@@ -414,7 +414,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'default_template_id': test_template.id,
}).create({})
with self.assertQueryCount(admin=141, employee=141), self.mock_mail_gateway():
with self.assertQueryCount(admin=118, employee=121), self.mock_mail_gateway():
composer._action_send_mail()
self.assertEqual(len(self._new_mails), 10)
@@ -425,7 +425,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_mail_composer_nodelete(self):
test_record, _test_template = self._create_test_records()
customer_id = self.customer.id
with self.assertQueryCount(admin=4, employee=4):
with self.assertQueryCount(admin=3, employee=3):
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': test_record._name,
@@ -436,7 +436,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer_id)],
})
with self.assertQueryCount(admin=32, employee=32):
with self.assertQueryCount(admin=29, employee=29):
composer._action_send_mail()
@users('admin', 'employee')
@@ -454,7 +454,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'default_template_id': test_template.id,
}).create({})
with self.assertQueryCount(admin=31, employee=31):
with self.assertQueryCount(admin=28, employee=28):
composer._action_send_mail()
# notifications
@@ -470,7 +470,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_mail_composer_w_template_attachments(self):
test_record, test_template = self._create_test_records()
with self.assertQueryCount(admin=26, employee=26): # tm 16/16 / com 25/25
with self.assertQueryCount(admin=25, employee=25): # tm 15/15 / com 24/24
composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
'default_model': test_record._name,
@@ -478,7 +478,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'default_template_id': test_template.id,
}).create({})
with self.assertQueryCount(admin=44, employee=44):
with self.assertQueryCount(admin=39, employee=39):
composer._action_send_mail()
# notifications
@@ -499,7 +499,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
test_template.write({'attachment_ids': [(5, 0)]})
customer = self.env['res.partner'].browse(self.customer.ids)
with self.assertQueryCount(admin=37, employee=37): # tm 26/26 / com 36/36
with self.assertQueryCount(admin=37, employee=37): # tm 27/27 / com 36/36
composer_form = Form(
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
@@ -510,7 +510,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
)
composer = composer_form.save()
with self.assertQueryCount(admin=41, employee=41):
with self.assertQueryCount(admin=38, employee=38):
composer._action_send_mail()
# notifications
@@ -529,7 +529,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
test_record, test_template = self._create_test_records()
customer = self.env['res.partner'].browse(self.customer.ids)
with self.assertQueryCount(admin=38, employee=38): # tm 27/27 / com 37/37
with self.assertQueryCount(admin=37, employee=37): # tm 27/27 / com 36/36
composer_form = Form(
self.env['mail.compose.message'].with_context({
'default_composition_mode': 'comment',
@@ -540,7 +540,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
)
composer = composer_form.save()
with self.assertQueryCount(admin=64, employee=64):
with self.assertQueryCount(admin=59, employee=59):
composer._action_send_mail()
# notifications
@@ -567,7 +567,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
# use another user already pre-defined with the email notification type,
# so the ormcache is preserved.
record = self.env['mail.test.track'].create({'name': 'Test'})
with self.assertQueryCount(admin=28, employee=28):
with self.assertQueryCount(admin=25, employee=25):
record.write({
'user_id': self.user_test_email.id,
})
@@ -576,7 +576,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
@warmup
def test_message_assignation_inbox(self):
record = self.env['mail.test.track'].create({'name': 'Test'})
with self.assertQueryCount(admin=20, employee=20):
with self.assertQueryCount(admin=18, employee=18):
record.write({
'user_id': self.user_test_inbox.id,
})
@@ -650,7 +650,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_post_one_email_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(admin=26, employee=26):
with self.assertQueryCount(admin=24, employee=24):
record.message_post(
body='<p>Test Post Performances with an email ping</p>',
partner_ids=self.customer.ids,
@@ -662,7 +662,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_post_one_inbox_notification(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(admin=18, employee=18):
with self.assertQueryCount(admin=17, employee=17):
record.message_post(
body='<p>Test Post Performances with an inbox ping</p>',
partner_ids=self.user_test.partner_id.ids,
@@ -675,7 +675,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
def test_message_subscribe_default(self):
record = self.env['mail.test.simple'].create({'name': 'Test'})
with self.assertQueryCount(admin=6, employee=6):
with self.assertQueryCount(admin=5, employee=5):
record.message_subscribe(partner_ids=self.user_test.partner_id.ids)
with self.assertQueryCount(admin=3, employee=3):
@@ -688,7 +688,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
record = self.env['mail.test.simple'].create({'name': 'Test'})
subtype_ids = (self.env.ref('test_mail.st_mail_test_simple_external') | self.env.ref('mail.mt_comment')).ids
with self.assertQueryCount(admin=5, employee=5):
with self.assertQueryCount(admin=4, employee=4):
record.message_subscribe(partner_ids=self.user_test.partner_id.ids, subtype_ids=subtype_ids)
with self.assertQueryCount(admin=2, employee=2):
@@ -844,7 +844,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
record = self.container.with_user(self.env.user)
# about 20 (19?) queries per additional customer group
with self.assertQueryCount(admin=36, employee=36):
with self.assertQueryCount(admin=35, employee=34):
record.message_post(
body='<p>Test Post Performances</p>',
message_type='comment',
@@ -862,7 +862,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
template = self.env.ref('test_mail.mail_test_container_tpl')
# about 20 (19 ?) queries per additional customer group
with self.assertQueryCount(admin=45, employee=45):
with self.assertQueryCount(admin=42, employee=41):
record.message_post_with_source(
template,
message_type='comment',
@@ -878,8 +878,8 @@ class TestMailComplexPerformance(BaseMailPerformance):
def test_complex_message_post_view(self):
_partners, test_records, test_template = self._create_test_records_for_batch()
with self.assertQueryCount(admin=4, employee=4):
composer = self.env['mail.compose.message'].with_context({
with self.assertQueryCount(admin=3, employee=3):
_composer = self.env['mail.compose.message'].with_context({
'default_composition_mode': 'mass_mail',
'default_model': test_records._name,
'default_res_ids': test_records.ids,
@@ -913,7 +913,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
self.assertEqual(rec1.message_partner_ids, self.env.user.partner_id | self.user_portal.partner_id)
# subscribe new followers with forced given subtypes
with self.assertQueryCount(admin=4, employee=4):
with self.assertQueryCount(admin=3, employee=3):
rec.message_subscribe(
partner_ids=pids[:4],
subtype_ids=subtype_ids
@@ -922,7 +922,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
self.assertEqual(rec1.message_partner_ids, self.env.user.partner_id | self.user_portal.partner_id | self.partners[:4])
# subscribe existing and new followers with force=False, meaning only some new followers will be added
with self.assertQueryCount(admin=5, employee=5):
with self.assertQueryCount(admin=4, employee=4):
rec.message_subscribe(
partner_ids=pids[:6],
subtype_ids=None
@@ -931,7 +931,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
self.assertEqual(rec1.message_partner_ids, self.env.user.partner_id | self.user_portal.partner_id | self.partners[:6])
# subscribe existing and new followers with force=True, meaning all will have the same subtypes
with self.assertQueryCount(admin=4, employee=4):
with self.assertQueryCount(admin=3, employee=3):
rec.message_subscribe(
partner_ids=pids,
subtype_ids=subtype_ids
@@ -952,7 +952,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
})
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id)
with self.assertQueryCount(admin=26, employee=26):
with self.assertQueryCount(admin=23, employee=23):
rec.write({'user_id': self.user_portal.id})
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
# write tracking message
@@ -972,7 +972,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
customer_id = self.customer.id
user_id = self.user_portal.id
with self.assertQueryCount(admin=58, employee=58): # tm 58/58
with self.assertQueryCount(admin=52, employee=52):
rec = self.env['mail.test.ticket'].create({
'name': 'Test',
'container_id': container_id,
@@ -1001,7 +1001,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
self.assertEqual(len(rec1.message_ids), 1)
with self.assertQueryCount(admin=36, employee=36):
with self.assertQueryCount(admin=33, employee=33):
rec.write({
'name': 'Test2',
'container_id': self.container.id,
@@ -1038,7 +1038,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.user_portal.partner_id | self.env.user.partner_id)
with self.assertQueryCount(admin=36, employee=36):
with self.assertQueryCount(admin=33, employee=33):
rec.write({
'name': 'Test2',
'container_id': container_id,
@@ -1071,7 +1071,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
rec1 = rec.with_context(active_test=False) # to see inactive records
self.assertEqual(rec1.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)
with self.assertQueryCount(admin=22, employee=22):
with self.assertQueryCount(admin=21, employee=21):
rec.write({
'name': 'Test2',
'customer_id': customer_id,
@@ -1301,7 +1301,7 @@ class TestMailHeavyPerformancePost(BaseMailPerformance):
attachments = self.env['ir.attachment'].with_user(self.env.user).create(self.test_attachments_vals)
# enable_logging = self.cr._enable_logging() if self.warm else nullcontext()
# with self.assertQueryCount(employee=49), enable_logging:
with self.assertQueryCount(employee=49):
with self.assertQueryCount(employee=45):
record_container.with_context({}).message_post(
body='<p>Test body <img src="cid:cid1"> <img src="cid:cid2"></p>',
subject='Test Subject',
@@ -47,7 +47,7 @@ class TestMassMailPerformance(TestMassMailPerformanceBase):
})
# runbot needs +2 compared to local
with self.assertQueryCount(__system__=426, marketing=427): # tm 424/425
with self.assertQueryCount(__system__=427, marketing=428): # tm 425/426
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)
@@ -94,7 +94,7 @@ class TestMassMailBlPerformance(TestMassMailPerformanceBase):
})
# runbot needs +2 compared to local
with self.assertQueryCount(__system__=488, marketing=489): # tm 486/487
with self.assertQueryCount(__system__=489, marketing=490): # tm 487/488
mailing.action_send_mail()
self.assertEqual(mailing.sent, 50)