[IMP] tools, base, mail: use first found email in 'email_normalized'
PURPOSE Be defensive when dealing with email fields, notably when having multi-emails or email field containing an already-formatted email. SPECIFICATIONS When having multi-emails input in an email field, 'email_normalized' field is currently 'False', as they expect the field to contain a single email. This has several drawbacks * searching partners or fetching information based on emails does not work as most tool methods use 'email_normalized' which is False (see e.g. '_message_partner_info_from_emails', '_mail_find_partner_from_emails' or 'find_or_create'); * blacklist is not available as it is based on 'email_normalized'; * mass_mailing wrongly considers those emails as invalid and cancel their mail and related trace, as it tries to skip sending emails to invalid emails; Be more defensive and use first found email in case of multi-emails field. Other emails are ignored. It is already an improvement that does not break flows in stable and allow more emails to be sent. before -> email: '"Raoul" <raoul1@raoul.fr>, raoul2@raoul.fr' -> email_normalized: False after -> email: '"Raoul" <raoul1@raoul.fr>, raoul2@raoul.fr' -> email_normalized: raoul1@raoul.fr A side effect is that it helps finding back some partners, as indicated in tests where less phantom partners are created. Task-2612945 (Mail: Defensive email formatting) Part-of: odoo/odoo#74474
Showing
- addons/mail/models/mail_thread_blacklist.py 1 addition, 1 deletionaddons/mail/models/mail_thread_blacklist.py
- addons/mail/tests/test_res_partner.py 15 additions, 6 deletionsaddons/mail/tests/test_res_partner.py
- addons/test_mail/tests/test_mail_composer.py 16 additions, 26 deletionsaddons/test_mail/tests/test_mail_composer.py
- addons/test_mail/tests/test_mail_gateway.py 5 additions, 5 deletionsaddons/test_mail/tests/test_mail_gateway.py
- addons/test_mail/tests/test_mail_thread_mixins.py 2 additions, 2 deletionsaddons/test_mail/tests/test_mail_thread_mixins.py
- addons/test_mail/tests/test_mail_tools.py 1 addition, 1 deletionaddons/test_mail/tests/test_mail_tools.py
- addons/test_mass_mailing/tests/test_mailing.py 9 additions, 2 deletionsaddons/test_mass_mailing/tests/test_mailing.py
- odoo/addons/base/tests/test_mail.py 1 addition, 1 deletionodoo/addons/base/tests/test_mail.py
- odoo/tools/mail.py 8 additions, 2 deletionsodoo/tools/mail.py
Loading
Please register or sign in to comment