[FIX] mass_mailing: fix email import by skipping invalid lines
When importing email in mass mailing through the form (not with an excel file), incorrect email lines were concatenated with the following next valid email line, resulting to an incorrect import. This solves the problem by ignoring incorrect email lines. Technical note: the test test_mailing_contact_import has been slightly modified to include invalid lines in the text to import, not only at the end but also at the beginning and in the middle (the test fails before the fix and not after). Task-2924241 X-original-commit: bd4a933f2b3259c3482b811227de0e06c7018969 Part-of: odoo/odoo#97560
This commit is contained in:
@@ -195,14 +195,18 @@ class TestMailingContactImport(MassMailCommon):
|
||||
))
|
||||
|
||||
contact_import.contact_list = '''
|
||||
invalid line1
|
||||
alice@example.com
|
||||
bob@example.com
|
||||
invalid line2
|
||||
"Bob" <bob@EXAMPLE.com>
|
||||
"Test" <bob@example.com>
|
||||
|
||||
invalid line3, with a comma
|
||||
already_exists_list_1@example.com
|
||||
already_exists_list_2@example.com
|
||||
"Test" <already_exists_list_1_and_2@example.com>
|
||||
invalid line
|
||||
invalid line4
|
||||
'''
|
||||
contact_import = contact_import.save()
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class MailingContactImport(models.TransientModel):
|
||||
"""Import each lines of "contact_list" as a new contact."""
|
||||
self.ensure_one()
|
||||
|
||||
contacts = tools.email_split_tuples(self.contact_list)
|
||||
contacts = tools.email_split_tuples(', '.join(self.contact_list.splitlines()))
|
||||
if not contacts:
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
|
||||
Reference in New Issue
Block a user