From f4c2bd121f36ef7a8dd589d1c631f9c42b12ae3a Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 24 Aug 2012 13:23:12 +0200 Subject: [PATCH] [IMP] mail.compose.message: cascade delete attachments upon vacuum-clean bzr revid: odo@openerp.com-20120824112312-zs5raruc4qdprlnp --- addons/mail/mail_message.py | 2 +- addons/mail/wizard/mail_compose_message.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 79e7eb81456..4ce552d6b05 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -220,7 +220,7 @@ class mail_message(osv.Model): for notification in not_obj.browse(cr, uid, not_ids, context=context): if notification.message_id.id in ids: pass - # FO Note: we should put this again !!! + # FP Note: we should put this again !!! #ids.remove(notification.message_id.id) # check messages according to related documents diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 46ef8a4786f..8a172bd62e4 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -19,7 +19,6 @@ # ############################################################################## -import ast import re import tools @@ -281,6 +280,12 @@ class mail_compose_message(osv.TransientModel): return tools.ustr(result) return template and EXPRESSION_PATTERN.sub(merge, template) + def unlink(self, cr, uid, ids, context=None): + # Cascade delete all attachments, as they are owned by the composition wizard + for wizard in self.read(cr, uid, ids, ['attachment_ids'], context=context): + self.pool.get('ir.attachment').unlink(cr, uid, wizard['attachment_ids'], context=context) + return super(mail_compose_message,self).unlink(cr, uid, ids, context=context) + def dummy(self, cr, uid, ids, context=None): """ TDE: defined to have buttons that do basically nothing. It is currently impossible to have buttons that do nothing special