From b8401b09f8b5505440e88028386f7ad9902cb0cb Mon Sep 17 00:00:00 2001 From: David Beguin Date: Wed, 25 Sep 2019 11:13:44 +0000 Subject: [PATCH] [FIX] crm_iap_lead_enrich : fix lost semantic in lead iap_enrich process Since the default value of probability is not set anymore, the probability of a new lead is equivalent to 0. In Lead enrichement, we filter out won and lost leads. But probability = 0 is not a good ways anymore to filter out lost leads. Lost reprensents archived leads. Task ID: 2044539 PR #37413 --- addons/crm_iap_lead_enrich/models/crm_lead.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/crm_iap_lead_enrich/models/crm_lead.py b/addons/crm_iap_lead_enrich/models/crm_lead.py index 48df18f3c77..dd6e4b9ee1d 100644 --- a/addons/crm_iap_lead_enrich/models/crm_lead.py +++ b/addons/crm_iap_lead_enrich/models/crm_lead.py @@ -19,10 +19,11 @@ class Lead(models.Model): @api.model def _iap_enrich_leads_cron(self): timeDelta = fields.datetime.now() - datetime.timedelta(hours=1) + # Get all leads not lost nor won (lost: active = False) leads = self.search([ ('iap_enrich_done', '=', False), ('reveal_id', '=', False), - ('probability', 'not in', (0, 100)), + ('probability', '<', 100), ('create_date', '>', timeDelta) ]) leads._iap_enrich(from_cron=True) @@ -30,7 +31,8 @@ class Lead(models.Model): def _iap_enrich(self, from_cron=False): lead_emails = {} for lead in self: - if lead.probability in (0, 100) or lead.iap_enrich_done: + # If lead is lost, active == False, but is anyway removed from the search in the cron. + if lead.probability == 100 or lead.iap_enrich_done: continue normalized_email = tools.email_normalize(lead.partner_address_email) or tools.email_normalize(lead.email_from) if normalized_email: