[FIX] mail.message: when auto-deleting a message, only delete attachments it owns
There's a peculiar way to manage attachments on mail messages, as there is an explicit many2many on top of regular attachments like for any record, so it is possible to link a mail to attachments that are owned by other records. Such attachments must not be deleted along with the message when the auto-delete flag is set. bzr revid: odo@openerp.com-20120316133026-4wbrwx64nqkeyaou
This commit is contained in:
parent
6242bb6a22
commit
c5f01ad903
|
@ -521,7 +521,9 @@ class mail_message(osv.osv):
|
|||
message.refresh()
|
||||
if message.state == 'sent' and message.auto_delete:
|
||||
self.pool.get('ir.attachment').unlink(cr, uid,
|
||||
[x.id for x in message.attachment_ids],
|
||||
[x.id for x in message.attachment_ids \
|
||||
if x.res_model == self._name and \
|
||||
x.res_id == message.id],
|
||||
context=context)
|
||||
message.unlink()
|
||||
except Exception:
|
||||
|
|
Loading…
Reference in New Issue