From dbb6cfdbf803d2ab86ba11450b5928abf5ab658b Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Tue, 20 Aug 2019 13:09:55 +0000 Subject: [REF] mail: remove deprecated email formataddr [PEP 594] is going to depreciate the legacy `email.message.Message` API and its related modules. Among them the `email.utils.formataddr` function, this function takes a `(name, email)` pair and returns a string value suitable for From, To and Cc headers. The stdlib function is capable of handling several character encoding and two binary-to-ascii encoding. Odoo only uses `utf-8` which is compatible with the base64 b2a encoding. The re-implementation of that function has been simplified to only support base64-ed utf-8 and ascii. [PEP 594]: https://www.python.org/dev/peps/pep-0594/\#email-lagacy-api --- addons/mail/wizard/mail_compose_message.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'addons/mail/wizard/mail_compose_message.py') diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index aeeba8c2339..b8b516f878c 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from email.utils import formataddr - import base64 import re @@ -68,7 +66,7 @@ class MailComposer(models.TransientModel): elif 'email_from' not in result: author = self.env['res.partner'].browse(result['author_id']) if author.email: - result['email_from'] = formataddr((author.name, author.email)) + result['email_from'] = tools.formataddr((author.name, author.email)) # v6.1 compatibility mode result['composition_mode'] = result.get('composition_mode', self._context.get('mail.compose.message.mode', 'comment')) -- cgit v1.2.3