[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:
parent
28ec23e828
commit
9d535ee2c7
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue