Technical mailing list archives

Email templates and auto_delete flag inconsistency

Maxim Litnitskiy
- 08/01/2014 16:17:02
Hi dear Developers!
I am testing 8.0 but I think this is the same in trunk.
Imagine the most usual situation - new lead auto reply with email_template "Thanks for your interest".
Let  this email_template has auto_delete = True.
We also have automated action on new lead creation with server action Send email with "thank you"  template having auto_delete = True.
So thank you email is sent to customer and both mail.mail and mail.message are deleted due to auto_delete flag.
Here comes the issue.
When customer replies mail_thread.message_route cannot route this mail to existing lead and creates a new lead instead.
This is because there is no mail.message with such message_id (as sent mail.mail and mail.message were deleted). 
If we set email_template.auto_delete = False the system keeps both sent mail.mail and creates mail.message.
When customer replies his reply gets the correct route as message_id is found:
msg_references = thread_references.split()                                                                                                                      
        mail_message_ids =, uid, [('message_id', 'in', msg_references)], context=context)
Now imagine that we do not use automated action and instead manually send 'thank you' email to customer from newly created lead.
Despite the fact email_template.auto_delete = True the system creates mail.message and deletes mail.mail after successful delivery.
In this case customer's reply can find the correct route to existing lead.
So as far as I can understand in the 2-nd case we first create mail.message and keep it. In the 1-st case we first create mail.mail and after that mail.message but when we delete mail.mail mail.message is deleted.
How can this be solved?
Thanks for your attenstion.