From 9d535ee2c78d527a8365a64776b1865709469278 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 24 Jan 2017 13:26:22 +0100 Subject: [PATCH] [FIX] mail: check all parameters are set Since `model` is not a required field, the invalidation may crash when one is missing. It should never happen than a mail.message has a res_id but not a model as it makes no business sence. However it is possible than a message temporarly misses one of the two, e.g: ``` self.model = False self.res_id = False ``` will trigger two writes and will crash at the first. Above code should probably be refactored to have only one write but this commit fixes a regression introduced at 8f1c2bfc (the above code did not crash). Closes #15199 --- addons/mail/mail_message.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index ac68a4bfd7f..d3eebeb1af0 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -795,7 +795,7 @@ class mail_message(osv.Model): def _invalidate_documents(self): """ Invalidate the cache of the documents followed by ``self``. """ for record in self: - if record.res_id: + if record.model and record.res_id: self.env[record.model].invalidate_cache(ids=[record.res_id]) def create(self, cr, uid, values, context=None):