Skip to content

Commit

Permalink
T1706 - Support request partner assignation (#1950)
Browse files Browse the repository at this point in the history
* match the email with that of a partner or its linked partners

* Formatting fix
  • Loading branch information
alexis-allemann authored Aug 22, 2024
1 parent 2ff83f2 commit 7f73bb3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crm_request/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def message_new(self, msg, custom_values=None):

if "partner_id" not in custom_values:
match_obj = self.env["res.partner.match"]
partner = match_obj.match_values_to_partner(
{"email": email_normalize(defaults["email_from"])}, match_create=False
partner = match_obj._match_email(
{"email": email_normalize(defaults["email_from"])}
)
if partner:
defaults["partner_id"] = partner.id
Expand Down Expand Up @@ -216,7 +216,7 @@ def message_update(self, msg_dict, update_vals=None):
in_leave.write({"stage_id": stage_new, "user_id": False})
return result

@api.returns('mail.message', lambda value: value.id)
@api.returns("mail.message", lambda value: value.id)
def message_post(self, **kwargs):
"""Change the stage to "Resolve" when the employee answer
to the supporter but not if it's an automatic answer.
Expand Down
5 changes: 4 additions & 1 deletion crm_request/models/res_partner_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ class ResPartnerMatch(models.AbstractModel):
def _match_email(self, vals):
# Redefine email rule to include aliases in search
email = vals["email"].strip()
return self.env["res.partner"].search(
partner = self.env["res.partner"].search(
[
"|",
"|",
("email", "=ilike", email),
("email_alias_ids.email", "=ilike", email),
("other_contact_ids.email", "=ilike", email),
]
)
return partner
4 changes: 2 additions & 2 deletions interaction_resume/models/crm_request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, api
from odoo import api, models
from odoo.tools.mail import html2plaintext


Expand Down Expand Up @@ -51,7 +51,7 @@ def _get_interaction_partner_domain(self, partner):
("email_from", "=", partner.email),
]

@api.returns('mail.message', lambda value: value.id)
@api.returns("mail.message", lambda value: value.id)
def message_post(self, **kwargs):
res = super().message_post(**kwargs)
self.partner_id.with_delay().fetch_interactions()
Expand Down

0 comments on commit 7f73bb3

Please sign in to comment.