[FIX] crm: improve duplicate finding when converting

SPECIFICATIONS

Improve heuristic used to find lead to convert duplicates

  * check email_normalized instead of email_from, as it may contain formatted
    emails. Normalized email are sanitized and normalized version of emails
    and ease comparisons;
  * use lead email if its customer has no email;
  * if no email is available but a customer is set, use it anyway;

This notably reverts 2917b38f28 . Indeed no reason has been found why
this fix is necessary.

LINKS

Task ID 2088565 (crm: from onchange to compute)
This commit is contained in:
Thibault Delavallée
2020-03-23 11:42:11 +00:00
parent 03afd0f2a1
commit aeed763b03
3 changed files with 14 additions and 15 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ class Lead2OpportunityPartner(models.TransientModel):
result['lead_id'] = lead.id
partner = lead._find_matching_partner()
email = lead.partner_id.email if lead.partner_id else lead.email_from
email = lead.partner_id.email if lead.partner_id.email else lead.email_from
tomerge.update(self.env['crm.lead']._get_lead_duplicates(partner, email, include_lost=True).ids)