diff --git a/hantec_api_ecommerce/controllers/main.py b/hantec_api_ecommerce/controllers/main.py index 64ec7f1..80cc012 100644 --- a/hantec_api_ecommerce/controllers/main.py +++ b/hantec_api_ecommerce/controllers/main.py @@ -37,16 +37,14 @@ def create_contact(self): contact_data = data.get("contact_data", {}) if email or phone: - # Email pattern to get the value before @ - email_pattern = r"^([a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*)" - email_prefix = re.match(email_pattern, email).group() if email else None phone_suffix = phone[len(phone) - 4 :] if phone else None domain = [] - if email_prefix: - domain.append(("email", "=", f"{email_prefix}%")) + if email: + domain.append(("email", "=", f"{email}")) if phone_suffix: - domain.append(("phone", "=", f"%{phone_suffix}")) + # Use "like" operator to use the "%" wildcard + domain.append(("phone", "like", f"%{phone_suffix}")) existing_contact = env["res.partner"].search(domain, limit=1)