[IMP] base: avoid double formatting in partner 'email_formatted' field
PURPOSE Be defensive when dealing with email fields, notably when having multi-emails or email field containing an already-formatted email. SPECIFICATIONS Main fix in this commit: fix multiple nested formatting in 'email_formatted' computation for <res.partner>. Other use cases are mainly left untouched as we let users deal with their input. In summary : * double format: if email already holds a formatted email, we should not use it to compute email_formatted, like name: Name / email: 'Format' <email@domain.com> -> before '"Name" <"Name" <email@domain.com>>" -> after '"Name" <email@domain.com>'' * multi emails: sometimes this field is used to hold several addresses like email1@domain.com, email2@domain.com. We currently let this value globally untouched by extracting emails and joining them, as we do not expect email_formatted to be a list of emails. Extractin emails allows to filter out extra text stored in email field, like name: Name / email: text, email1@domain.com, email2@domain.com -> before: "Name" <text, email1@domain.com, email2@domain.com> -> after: "Name" <email1@domain.com,email2@domain.com> * invalid email: if something is wrong, better keep it in email_formatted than harcoding "False". Indeed this eases management and understanding of failures at mail.mail, mail.notification and mailing.trace level. This behavior does not change as it was already implemented like that even if not sure it was intended; Task-2612945 (Mail: Defensive email formatting) Part-of: odoo/odoo#74474
Showing
- addons/crm/tests/test_crm_lead_notification.py 1 addition, 1 deletionaddons/crm/tests/test_crm_lead_notification.py
- addons/mail/tests/test_res_partner.py 2 additions, 2 deletionsaddons/mail/tests/test_res_partner.py
- addons/test_mail/tests/test_mail_composer.py 16 additions, 16 deletionsaddons/test_mail/tests/test_mail_composer.py
- odoo/addons/base/models/res_partner.py 29 additions, 4 deletionsodoo/addons/base/models/res_partner.py
- odoo/addons/base/tests/test_res_partner.py 7 additions, 7 deletionsodoo/addons/base/tests/test_res_partner.py
- odoo/tools/mail.py 14 additions, 0 deletionsodoo/tools/mail.py
Loading
Please register or sign in to comment