[17.0] mail_composer_cc_bcc : Error when send email from partner with multiple emails (Split by ';')
For example, on a res_partner who have an email field with 2 emails (split by ';').
When we try to send the email, we get this error :
' File "/root/projects/shared-addons/17.0/OCA/social/mail_composer_cc_bcc/models/mail_mail.py", line 12, in format_emails tools.formataddr((p.name or "", tools.email_normalize(p.email))) File "/root/projects/shared-addons/17.0/odoo/odoo/odoo/tools/mail.py", line 826, in formataddr local, _, domain = address.rpartition('@') ^^^^^^^^^^^^^^^^^^ AttributeError: 'bool' object has no attribute 'rpartition' '
So after investigate the problem, i can say that the error occur on method 'format_emails' in models/mail_mail.py because the format_emails doesn't care about multiple email split by ';'
I think the method 'format_emails_raw' need to be refactored too.
To resolve my problem, i have updated these methods :
def format_emails(partners):
"""
@Override
We overide this method because module 'mail_composer_cc_bcc'
raise an error when we send an email with multiple email split by ';'
"""
emails = []
for p in partners:
if not p.email:
continue
raw_emails = [e.strip() for e in p.email.split(';') if e.strip()]
emails.extend(
tools.formataddr((p.name or "", tools.email_normalize(email)))
for email in raw_emails
if email
)
return ", ".join(emails)
def format_emails_raw(partners):
"""
@Override
We overide this method because module 'mail_composer_cc_bcc'
raise an error when we send an email with multiple email split by ';'
"""
emails = []
for p in partners:
if p.email:
split_emails = [email.strip() for email in p.email.split(';') if email.strip()]
emails.extend(split_emails)
return ", ".join(emails)
Hello @FlorianGenicq, as far as I know, multiple-email for single recipient is not allowed in standard
In standard we can send email to multiple email split by ';'