From 337397eec5570fc9b3938d655a1ec0e4efcd73d9 Mon Sep 17 00:00:00 2001 From: "Didier (did)" Date: Fri, 11 Dec 2020 09:34:01 +0000 Subject: [FIX] mail: clean sub-queries when searching error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thread search with `message_has_error` should only return threads containing messages with failure of which the current user is author. Follow up on https://github.com/odoo/odoo/pull/52403 that changed how sub-queries were built. The current fix using `_search` is a non-ideal solution until task-2366651 brings a new domain operator for this use case. task-2409543 closes odoo/odoo#62813 Signed-off-by: Sébastien Theys (seb) --- addons/mail/models/mail_thread.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/mail/models/mail_thread.py') diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index c0dd08b9b64..d694f4f913e 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -233,7 +233,8 @@ class MailThread(models.AbstractModel): @api.model def _search_message_has_error(self, operator, operand): - return ['&', ('message_ids.has_error', operator, operand), ('message_ids.author_id', '=', self.env.user.partner_id.id)] + message_ids = self.env['mail.message']._search([('has_error', operator, operand), ('author_id', '=', self.env.user.partner_id.id)]) + return [('message_ids', 'in', message_ids)] def _compute_message_attachment_count(self): read_group_var = self.env['ir.attachment'].read_group([('res_id', 'in', self.ids), ('res_model', '=', self._name)], -- cgit v1.2.3