[IMP] crm, hr_work_entry_holidays, test_mail{_full}: update query count

In order to display the unfollow link or not in emails or in the inbox, the
system need to query the followers of the document. This is what explains the
added queries.

See odoo/odoo#107978

Task-3061864
This commit is contained in:
Pierre-Yves Dufays
2023-05-10 13:21:07 +02:00
parent 3e57dc295c
commit c8b27bd3a0
4 changed files with 28 additions and 28 deletions
@@ -32,7 +32,7 @@ class TestWorkEntryHolidaysPerformance(TestWorkEntryHolidaysBase):
self.richard_emp.generate_work_entries(date(2018, 1, 1), date(2018, 1, 2))
leave = self.create_leave(datetime(2018, 1, 1, 7, 0), datetime(2018, 1, 1, 18, 0))
with self.assertQueryCount(__system__=92, admin=96):
with self.assertQueryCount(__system__=94, admin=98):
leave.action_validate()
leave.action_refuse()
+20 -20
View File
@@ -348,7 +348,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer_id)],
})
with self.assertQueryCount(admin=34, employee=34):
with self.assertQueryCount(admin=36, employee=36):
composer._action_send_mail()
@users('admin', 'employee')
@@ -369,7 +369,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer.id)],
})
with self.assertQueryCount(admin=35, employee=35):
with self.assertQueryCount(admin=37, employee=37):
composer._action_send_mail()
@users('admin', 'employee')
@@ -393,7 +393,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
composer_form.attachment_ids.add(attachment)
composer = composer_form.save()
with self.assertQueryCount(admin=46, employee=46): # tm+com 45/45
with self.assertQueryCount(admin=49, employee=49): # tm+com 48/48
composer._action_send_mail()
# notifications
@@ -437,7 +437,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'partner_ids': [(4, customer_id)],
})
with self.assertQueryCount(admin=34, employee=34):
with self.assertQueryCount(admin=36, employee=36):
composer._action_send_mail()
@users('admin', 'employee')
@@ -455,7 +455,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'default_template_id': test_template.id,
}).create({})
with self.assertQueryCount(admin=34, employee=34):
with self.assertQueryCount(admin=36, employee=36):
composer._action_send_mail()
# notifications
@@ -479,7 +479,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
'default_template_id': test_template.id,
}).create({})
with self.assertQueryCount(admin=42, employee=42):
with self.assertQueryCount(admin=44, employee=44):
composer._action_send_mail()
# notifications
@@ -511,7 +511,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
)
composer = composer_form.save()
with self.assertQueryCount(admin=43, employee=43):
with self.assertQueryCount(admin=46, employee=46):
composer._action_send_mail()
# notifications
@@ -541,7 +541,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
)
composer = composer_form.save()
with self.assertQueryCount(admin=61, employee=61):
with self.assertQueryCount(admin=64, employee=64):
composer._action_send_mail()
# notifications
@@ -568,7 +568,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=37, employee=37):
with self.assertQueryCount(admin=39, employee=39):
record.write({
'user_id': self.user_test_email.id,
})
@@ -577,7 +577,7 @@ class TestMailAPIPerformance(BaseMailPerformance):
@warmup
def test_message_assignation_inbox(self):
record = self.env['mail.test.track'].create({'name': 'Test'})
with self.assertQueryCount(admin=18, employee=18):
with self.assertQueryCount(admin=19, employee=19):
record.write({
'user_id': self.user_test_inbox.id,
})
@@ -651,7 +651,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=30, employee=30):
with self.assertQueryCount(admin=31, employee=31):
record.message_post(
body=Markup('<p>Test Post Performances with an email ping</p>'),
partner_ids=self.customer.ids,
@@ -663,7 +663,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=17, employee=17):
with self.assertQueryCount(admin=18, employee=18):
record.message_post(
body=Markup('<p>Test Post Performances with an inbox ping</p>'),
partner_ids=self.user_test.partner_id.ids,
@@ -852,7 +852,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
record = self.container.with_user(self.env.user)
# about 20 (19?) queries per additional customer group
with self.assertQueryCount(admin=53, employee=52):
with self.assertQueryCount(admin=56, employee=55):
record.message_post(
body=Markup('<p>Test Post Performances</p>'),
message_type='comment',
@@ -870,7 +870,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=60, employee=59):
with self.assertQueryCount(admin=63, employee=62):
record.message_post_with_source(
template,
message_type='comment',
@@ -894,7 +894,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
'default_template_id': test_template.id,
}).create({})
with self.assertQueryCount(admin=131, employee=131):
with self.assertQueryCount(admin=141, employee=141):
messages_as_sudo = test_records.message_post_with_source(
'test_mail.mail_template_simple_test',
render_values={'partner': self.user_test.partner_id},
@@ -960,7 +960,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=37, employee=37):
with self.assertQueryCount(admin=39, employee=39):
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
@@ -980,7 +980,7 @@ class TestMailComplexPerformance(BaseMailPerformance):
customer_id = self.customer.id
user_id = self.user_portal.id
with self.assertQueryCount(admin=88, employee=88):
with self.assertQueryCount(admin=94, employee=94):
rec = self.env['mail.test.ticket'].create({
'name': 'Test',
'container_id': container_id,
@@ -1009,7 +1009,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=56, employee=56):
with self.assertQueryCount(admin=59, employee=59):
rec.write({
'name': 'Test2',
'container_id': self.container.id,
@@ -1046,7 +1046,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=62, employee=62):
with self.assertQueryCount(admin=65, employee=65):
rec.write({
'name': 'Test2',
'container_id': container_id,
@@ -1309,7 +1309,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=63), enable_logging:
with self.assertQueryCount(employee=60):
with self.assertQueryCount(employee=62):
record_container.with_context({}).message_post(
body=Markup('<p>Test body <img src="cid:cid1"> <img src="cid:cid2"></p>'),
subject='Test Subject',
@@ -82,7 +82,7 @@ class TestMailPerformance(BaseMailPerformance):
record_ticket = self.env['mail.test.ticket.mc'].browse(self.record_ticket.ids)
attachments = self.env['ir.attachment'].create(self.test_attachments_vals)
with self.assertQueryCount(employee=85): # tmf: 85
with self.assertQueryCount(employee=91): # tmf: 90
new_message = record_ticket.message_post(
attachment_ids=attachments.ids,
body=Markup('<p>Test Content</p>'),
+6 -6
View File
@@ -172,25 +172,25 @@ class TestRatingPerformance(TestRatingCommon):
@users('employee')
@warmup
def test_rating_last_value_perfs(self):
with self.assertQueryCount(employee=1213): # tmf 1213 / com 1217
with self.assertQueryCount(employee=1313): # tmf 1313 / com 1313
self.create_ratings('mail.test.rating.thread')
with self.assertQueryCount(employee=1801): # tmf 1801
with self.assertQueryCount(employee=1901): # tmf 1901
self.apply_ratings(1)
with self.assertQueryCount(employee=1700): # tmf 1700
with self.assertQueryCount(employee=1800): # tmf 1800
self.apply_ratings(5)
@users('employee')
@warmup
def test_rating_last_value_perfs_with_rating_mixin(self):
with self.assertQueryCount(employee=1319): # tmf 1319 / com 1319
with self.assertQueryCount(employee=1419): # tmf 1419 / com 1419
self.create_ratings('mail.test.rating')
with self.assertQueryCount(employee=2004): # tmf 2004
with self.assertQueryCount(employee=2104): # tmf 2104
self.apply_ratings(1)
with self.assertQueryCount(employee=2003): # tmf 2003
with self.assertQueryCount(employee=2103): # tmf 2103
self.apply_ratings(5)
with self.assertQueryCount(employee=1):