[ADD]: email_template: Added unlink method to move email to trash/Completely remove according to its current folder

bzr revid: rpa@tinyerp.com-20100825072423-fztz58owf6mm9f17
This commit is contained in:
rpa (Open ERP) 2010-08-25 12:54:23 +05:30
parent 3709122dd8
commit c87d3a76d2
1 changed files with 18 additions and 0 deletions

View File

@ -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: