[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
This commit is contained in:
Jairo Llopis 2017-01-24 13:26:22 +01:00 committed by Martin Trigaux
parent 28ec23e828
commit 9d535ee2c7
No known key found for this signature in database
GPG Key ID: 7B0E288E7C0F83A7
1 changed files with 1 additions and 1 deletions

View File

@ -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):