Do not create contact mechanism for invalid email from Shopify

Closes #14368
This commit is contained in:
Cédric Krier
2025-11-17 14:38:07 +01:00
parent 72b7d9e922
commit d6fad7d10c
+11
View File
@@ -1,11 +1,16 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import logging
from trytond.model import sequence_reorder
from trytond.pool import Pool, PoolMeta
from trytond.tools import remove_forbidden_chars
from trytond.tools.email_ import EmailNotValidError, validate_email
from .common import IdentifiersMixin, setattr_changed
logger = logging.getLogger(__name__)
class Party(IdentifiersMixin, metaclass=PoolMeta):
__name__ = 'party.party'
@@ -41,6 +46,12 @@ class Party(IdentifiersMixin, metaclass=PoolMeta):
contact_mechanisms.pop(i))
break
else:
if types[0] == 'email':
try:
validate_email(value)
except EmailNotValidError as e:
logger.info("Skip email %s", value, exc_info=e)
continue
contact_mechanisms.insert(index, ContactMechanism(
type=types[0], value=value))
party.contact_mechanisms = sequence_reorder(contact_mechanisms)