'Returns the preferred reply-to email address that is basically the
alias of the document, if it exists. Override this method to implement
a custom behavior about reply-to for generated emails.'

@api.model
def message_get_reply_to(self, res_ids, default=None):

    model_name = (self.env.context.get('thread_model') or self._name)
    alias_domain = self.env['ir.config_parameter'].get_param('mail.catchall.domain')
    res = dict.fromkeys(res_ids, False)
    aliases = {}
    doc_names = {}
    if alias_domain:
        if (model_name and (model_name != 'mail.thread') and res_ids):
            mail_aliases = self.env['mail.alias'].sudo().search([('alias_parent_model_id.model', '=', model_name), ('alias_parent_thread_id', 'in', res_ids), ('alias_name', '!=', False)])
            for alias in mail_aliases:
                if (alias.alias_parent_thread_id not in aliases):
                    aliases[alias.alias_parent_thread_id] = ('%s@%s' % (alias.alias_name, alias_domain))
            doc_names.update(dict(((ng_res[0], ng_res[1]) for ng_res in self.env[model_name].sudo().browse(aliases.keys()).name_get())))
        left_ids = set(res_ids).difference(set(aliases.keys()))
        if left_ids:
            catchall_alias = self.env['ir.config_parameter'].get_param('mail.catchall.alias')
            if catchall_alias:
                aliases.update(dict(((res_id, ('%s@%s' % (catchall_alias, alias_domain))) for res_id in left_ids)))
        company_name = self.env.user.company_id.name
        for res_id in aliases.keys():
            email_name = ('%s%s' % (company_name, ((doc_names.get(res_id) and ('    ' + doc_names[res_id])) or '')))
            email_addr = aliases[res_id]
            res[res_id] = formataddr((email_name, email_addr))
    left_ids = set(res_ids).difference(set(aliases.keys()))
    if left_ids:
        res.update(dict(((res_id, default) for res_id in res_ids)))
    return res
