diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 45d66dac6a5..1a69aaa229a 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -402,7 +402,6 @@ class Message(models.Model): 'message_type', 'subtype_id', 'subject', # message specific 'model', 'res_id', 'record_name', # document related 'channel_ids', 'partner_ids', # recipients - 'needaction_partner_ids', # list of partner ids for whom the message is a needaction 'starred_partner_ids', # list of partner ids for whom the message is starred ]) message_tree = dict((m.id, m) for m in self.sudo()) @@ -418,6 +417,7 @@ class Message(models.Model): note_id = self.env['ir.model.data'].xmlid_to_res_id('mail.mt_note') for message in message_values: + message['needaction_partner_ids'] = self.env['mail.notification'].sudo().search([('mail_message_id', '=', message['id']), ('is_read', '=', False)]).mapped('res_partner_id').ids message['is_note'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['id'] == note_id message['is_discussion'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['id'] == com_id message['is_notification'] = message['is_note'] and not message['model'] and not message['res_id'] diff --git a/addons/test_mail/tests/test_performance.py b/addons/test_mail/tests/test_performance.py index b850fdd9227..1e8b594e462 100644 --- a/addons/test_mail/tests/test_performance.py +++ b/addons/test_mail/tests/test_performance.py @@ -206,7 +206,7 @@ class TestAdvMailPerformance(TransactionCase): def test_message_assignation_inbox(self): record = self.env['mail.test.track'].create({'name': 'Test'}) - with self.assertQueryCount(margin=1, admin=42, emp=55): # test_mail only: 42 - 55 + with self.assertQueryCount(margin=1, admin=44, emp=55): # test_mail only: 44 - 55 record.write({ 'user_id': self.user_test.id, }) @@ -262,7 +262,7 @@ class TestAdvMailPerformance(TransactionCase): def test_message_post_one_inbox_notification(self): record = self.env['mail.test.simple'].create({'name': 'Test'}) - with self.assertQueryCount(margin=1, admin=37, emp=48): # com runbot 35 - 46 // test_mail only: 37 - 48 + with self.assertQueryCount(margin=1, admin=39, emp=48): # com runbot 37 - 46 // test_mail only: 39 - 48 record.message_post( body='
Test Post Performances with an inbox ping
', partner_ids=self.user_test.partner_id.ids, @@ -472,7 +472,7 @@ class TestHeavyMailPerformance(TransactionCase): }) self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id) - with self.assertQueryCount(admin=67, emp=87): # com runbot: 66 - 86 // test_mail only: 67 - 87 + with self.assertQueryCount(admin=67, emp=85): # com runbot: 66 - 84 // test_mail only: 67 - 85 rec.write({'user_id': self.user_portal.id}) self.assertEqual(rec.message_partner_ids, self.partners | self.env.user.partner_id | self.user_portal.partner_id)