diff --git a/addons/email_template/email_template_mailbox.py b/addons/email_template/email_template_mailbox.py index 015d8ec297e..20103ed7ffc 100644 --- a/addons/email_template/email_template_mailbox.py +++ b/addons/email_template/email_template_mailbox.py @@ -184,6 +184,24 @@ class email_template_mailbox(osv.osv): 'folder': lambda * a: 'outbox', } + def unlink(self, cr, uid, ids, context=None): + """ + It just changes the folder of the item to "Trash", if it is no in Trash folder yet, + or completely deletes it if it is already in Trash. + """ + if not context: + context = {} + to_update = [] + to_remove = [] + for mail in self.browse(cr, uid, ids, context=context): + if mail.folder == 'trash': + to_remove.append(mail.id) + else: + to_update.append(mail.id) + # Changes the folder to trash + self.write(cr, uid, to_update, {'folder': 'trash'}, context=context) + return super(email_template_mailbox, self).unlink(cr, uid, to_remove, context=context) + email_template_mailbox() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: