diff --git a/crm_request/models/request.py b/crm_request/models/request.py index 58bfec670..e35fb0785 100644 --- a/crm_request/models/request.py +++ b/crm_request/models/request.py @@ -161,14 +161,15 @@ def message_new(self, msg, custom_values=None): "alias_id": alias.id, "categ_id": category_id, "name": subject, - "email_from": msg.get("from"), + # Our contact forms use the reply-to field for the sponsor's email + "email_from": msg.get("in-reply-to", msg.get("from")), } if "partner_id" not in custom_values: match_obj = self.env["res.partner.match"] partner = match_obj._match_email( {"email": email_normalize(defaults["email_from"])} - ) + )[:1] if partner: defaults["partner_id"] = partner.id defaults["language"] = partner.lang diff --git a/crm_request/models/res_partner_match.py b/crm_request/models/res_partner_match.py index f23a2f7a8..d3b2de9c1 100644 --- a/crm_request/models/res_partner_match.py +++ b/crm_request/models/res_partner_match.py @@ -16,9 +16,11 @@ class ResPartnerMatch(models.AbstractModel): @api.model def _match_email(self, vals): # Redefine email rule to include aliases in search + # and exclude Compassion addresses email = vals["email"].strip() partner = self.env["res.partner"].search( [ + ("email", "not like", "compassion"), "|", "|", ("email", "=ilike", email),