Community: Framework mailing list archives

Re: Email templates and auto_delete flag inconsistency

Maxim Litnitskiy
- 08/04/2014 08:13:19
I was mistaken with dependency direction.
mail.mail has a reference to mail.message that means when we delete mail.message that has corresponding mail.mail the latter is also deleted on cascade.
When we delete mail.mail having corresponding mail.message the latter is not deleted on database level.
So the issue is not with ON CASCADE but on general mail.mail delete procedure.

res = super(mail_mail, self).unlink(cr, uid, ids, context= 
self.pool.get('mail.message').unlink(cr, uid, parent_msg_ids, context=context)

1. Delete mail.mail
2. Delete mail.message of this mail.
Until second line is removed no lead autoreply will work correctly.

    _columns = {                                                                                                                                                        
        'mail_message_id': fields.many2one('mail.message', 'Message', required=True, ondelete='cascade'),       

Why  delete messages when deleting email?