(self, partner=None, email=None, include_lost=False)
return self.with_context(active_test=False).search(domain)
Search for leads that seem duplicated based on partner / email.

        :param partner : optional customer when searching duplicated
        :param email: email (possibly formatted) to search
        :param boolean include_lost: if True, search includes archived opportunities
          (still only active leads are considered). If False, search for active
          and not won leads and opportunities;
Search for leads that seem duplicated based on partner / email.
Search for leads that seem duplicated based on partner / email .
def _get_lead_duplicates(self, partner=None, email=None, include_lost=False):
        """ Search for leads that seem duplicated based on partner / email.

        :param partner : optional customer when searching duplicated
        :param email: email (possibly formatted) to search
        :param boolean include_lost: if True, search includes archived opportunities
          (still only active leads are considered). If False, search for active
          and not won leads and opportunities;
        """
        if not email and not partner:
            return self.env['crm.lead']

        domain = []
        for normalized_email in [tools.email_normalize(email) for email in tools.email_split(email)]:
            domain.append(('email_normalized', '=', normalized_email))
        if partner:
            domain.append(('partner_id', '=', partner.id))

        if not domain:
            return self.env['crm.lead']

        domain = ['|'] * (len(domain) - 1) + domain
        if include_lost:
            domain += ['|', ('type', '=', 'opportunity'), ('active', '=', True)]
        else:
            domain += ['&', ('active', '=', True), '|', ('stage_id', '=', False), ('stage_id.is_won', '=', False)]

        return self.with_context(active_test=False).search(domain)
def _get_lead_duplicates ( self , partner = None , email = None , include_lost = False ) : if not email and not partner : return self . env [ 'crm.lead' ] domain = [ ] for normalized_email in [ tools . email_normalize ( email ) for email in tools . email_split ( email ) ] : domain . append ( ( 'email_normalized' , '=' , normalized_email ) ) if partner : domain . append ( ( 'partner_id' , '=' , partner . id ) ) if not domain : return self . env [ 'crm.lead' ] domain = [ '|' ] * ( len ( domain ) - 1 ) + domain if include_lost : domain += [ '|' , ( 'type' , '=' , 'opportunity' ) , ( 'active' , '=' , True ) ] else : domain += [ '&' , ( 'active' , '=' , True ) , '|' , ( 'stage_id' , '=' , False ) , ( 'stage_id.is_won' , '=' , False ) ] return self . with_context ( active_test = False ) . search ( domain )