Technical mailing list archives

mail.thread, from email, reply_to email, user message aliases and catchall fun

Maxim Litnitskiy
- 09/14/2014 10:37:26
Hi all who ever used open chatter in Odoo :-)
Either I am idiot or smth is wrong with chatter concept in Odoo.
I am trying to use project and project_issue  in Odoo 8.0 latest from github.
Please find a few minutes to read the following.

Case 1: General Settings -> Alias Domain is NOT set.
In this case when user sends a message to followers his email address from res_partner is used.
The problem is when customer replys this email - it is sent to user's mailbox in gmail or somewhere else but not in Odoo.
So Odoo thread never gets this reply.
Possible solution as far as I guessed was to connect Odoo to user's IMAP/POP3 server. But! In this case Odoo will get ALL user mails and here a new problem comes - how to notify user by mail about new thread message? So this is not the right way.
The solution could be to connect projects module to its personal IMAP/POP3 account  ( and to have projects.reply_to address set to on every chatter message sent from projects. May be bind outgoing server to projects add have these options in Outgoing server (smth like override_from, override_reply_to, etc).
To summarize: I was not able to use project_issue with email2issue without domain alias.

Case 2:  General Settings -> Alias Domain IS set.
In this case mail_from is overwritten and user's messaging alias is used.
But again! Reply_to is set to catchall address. I don't want everyproject to have it's own email address.
Messages are matched by thread id and in case of no match new issue is created. It's ok.
I don't want to play with all this mail games like forwarding all * to Odoo for routing.
I guess if user message alias is set, then this alias must be used in reply to header so that user can have his gmail for notifications / signup / password reset / World communications and his Odoo mail account is connected to Odoo for communication with business partners through Odoo.

I did not manage to solve my simple case without hacking.
I had to override _get_reply_to and add the following:
        this = self.pool.get('res.users').browse(cr, SUPERUSER_ID, uid, context=context)                                                                                
        if this.alias_name and this.alias_domain:                                                                                                                       
            return formataddr((, '%s@%s' % (this.alias_name, this.alias_domain)))  

And this made me happy.
How others handle this?

Finally. We loose sender name in ir_mail_server.encode_rfc2822_address_header. It expects email to be "Non-latin name" <>. But in mail_message._get_default_from calls email.utils.formataddr((, and it does not return double quotes thus dropping person name completely from headers. When latin names are used it's ok but as soon as non-latin is used in person's name his name is lost from headers exactly at ir_mail_server.encode_rfc2822_address_header.
Here is my fix (remove double quotes as they are anyway not passed):
#name_with_email_pattern = re.compile(r'("[^<@>]+")\s*<([^ ,<@]+@[^> ,]+)>')
name_with_email_pattern = re.compile(r'([^<@>]+)\s*<([^ ,<@]+@[^> ,]+)>')

P.P.S. I had one more idea. To check context to have 'mail_reply_to' set and use it from mail_message._get_reply_to method. In this case we could add mail_reply_to to action's context and do it for all project actions. I guess it could be a good option from point of flexibility to use context to set mail_from / mail_reply_to values.