[FIX] mail : fix traceback while creating invalid blacklist email address

The objective of not creating the record if the email was invalid
was to avoid crash on import. But if the number of record created does not
match the number of record that would have been created (see in flush()
in models.py), this cannot work.

Also, it's necessary to tell the user that his import file has an error
and where. This is why a UserError must be returned.

Task ID 1902139
Closes PR #28011
This commit is contained in:
David Beguin
2018-10-31 10:51:56 +00:00
parent 1f16c2aabe
commit c28ae53417
2 changed files with 7 additions and 2 deletions
+6
View File
@@ -2434,6 +2434,12 @@ msgstr ""
msgid "Invalid email address"
msgstr ""
#. module: mail
#: code:addons/mail/models/mail_blacklist.py:35
#, python-format
msgid "Invalid email address %r"
msgstr ""
#. module: mail
#: code:addons/mail/models/mail_alias.py:88
#, python-format
+1 -2
View File
@@ -32,8 +32,7 @@ class MailBlackList(models.Model):
for value in values:
email = self._sanitize_email(value.get('email'))
if not email:
_logger.warning('Blacklist: invalid email value %s' % value['email'])
continue
raise UserError(_('Invalid email address %r') % value['email'])
if email in all_emails:
continue
all_emails.append(email)