From d1490e27774193487df81733fdabf5f3d1f97f55 Mon Sep 17 00:00:00 2001 From: len-odoo Date: Tue, 27 Nov 2018 15:41:08 +0000 Subject: [FIX] mail: do not have _get_message_needaction crash on empty task list Suppose that a Task is added on a task via a studio customisation. Then the _get_message_needaction method gets called on the onchange of the toplevel task, which triggers another call to _get_message_needaction. During that update, we get a self with a model.newID; its ids field is empty, so the list of tasks res itself is empty. As a result the method crashes on a malformed query. This can in turn prevent the completion of some higher-level operation, e.g. a state change on the task. opw 1909043 closes odoo/odoo#29084 --- addons/mail/models/mail_thread.py | 2 ++ 1 file changed, 2 insertions(+) (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 56214df2fcb..aab526995f6 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -196,6 +196,8 @@ class MailThread(models.AbstractModel): @api.multi def _get_message_needaction(self): res = dict((res_id, 0) for res_id in self.ids) + if not res: + return # search for unread messages, directly in SQL to improve performances self._cr.execute(""" SELECT msg.res_id FROM mail_message msg -- cgit v1.2.3