Skip to content

Commit

Permalink
T1857 FIX fetchmail for support requests
Browse files Browse the repository at this point in the history
- Use reply-to field to checking the sponsor email
- Limit the search to avoid finding compassion email addresses
- Avoid crashes when multiple partners are found, take the first
  • Loading branch information
ecino committed Sep 24, 2024
1 parent 33af52a commit b8b8cc4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crm_request/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions crm_request/models/res_partner_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit b8b8cc4

Please sign in to comment.