[IMP] mail_message: attachments deleted when unlinking are those with model=self...
authorThibault Delavallée <tde@openerp.com>
Thu, 6 Sep 2012 12:52:17 +0000 (14:52 +0200)
committerThibault Delavallée <tde@openerp.com>
Thu, 6 Sep 2012 12:52:17 +0000 (14:52 +0200)
bzr revid: tde@openerp.com-20120906125217-27nlyveznh12bk63

addons/mail/mail_message.py
addons/mail/wizard/mail_compose_message.py

index dd499f6..c76d073 100644 (file)
@@ -310,11 +310,11 @@ class mail_message(osv.Model):
         attachments_to_delete = []
         for mail in self.browse(cr, uid, ids, context=context):
             for attach in mail.attachment_ids:
-                if attach.res_model == 'mail.message' and attach.res_id == mail.id:
+                if attach.res_model == self._name and attach.res_id == mail.id:
                     attachments_to_delete.append(attach.id)
         if attachments_to_delete:
             self.pool.get('ir.attachment').unlink(cr, uid, attachments_to_delete, context=context)
-        return super(mail_message,self).unlink(cr, uid, ids, context=context)
+        return super(mail_message, self).unlink(cr, uid, ids, context=context)
 
     def notify(self, cr, uid, newid, context=None):
         """ Add the related record followers to the destination partner_ids.
index 3153ccc..b62cb11 100644 (file)
@@ -221,12 +221,6 @@ class mail_compose_message(osv.TransientModel):
         res.update(self._verify_partner_email(cr, uid, value[0][2], context=context))
         return res
 
-    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