parameters: (self, emails, records=None, force_create=False, extra_domain=False)
return_statement: return partners
docstring: Utility method to find partners from email addresses. If no partner is
          found, create new partners if force_create is enabled. Search heuristics
  
            * 1: check in records (record set) followers if records is mail.thread
                 enabled and if check_followers parameter is enabled;
            * 2: search for partners with user;
            * 3: search for partners;
  
          :param records: record set on which to check followers;
          :param list emails: list of email addresses for finding partner;
          :param boolean force_create: create a new partner if not found
  
          :return list partners: a list of partner records ordered as given emails.
            If no partner has been found and/or created for a given emails its
            matching partner is an empty record.
docstring_summary: Utility method to find partners from email addresses. If no partner is
          found, create new partners if force_create is enabled. Search heuristics
docstring_tokens: Utility method to find partners from email addresses . If no partner is found create new partners if force_create is enabled . Search heuristics
function: def _mail_find_partner_from_emails(self, emails, records=None, force_create=False, extra_domain=False):
          """ Utility method to find partners from email addresses. If no partner is
          found, create new partners if force_create is enabled. Search heuristics
  
            * 1: check in records (record set) followers if records is mail.thread
                 enabled and if check_followers parameter is enabled;
            * 2: search for partners with user;
            * 3: search for partners;
  
          :param records: record set on which to check followers;
          :param list emails: list of email addresses for finding partner;
          :param boolean force_create: create a new partner if not found
  
          :return list partners: a list of partner records ordered as given emails.
            If no partner has been found and/or created for a given emails its
            matching partner is an empty record.
          """
          if records and issubclass(type(records), self.pool['mail.thread']):
              followers = records.mapped('message_partner_ids')
          else:
              followers = self.env['res.partner']
          catchall_domain = self.env['ir.config_parameter'].sudo().get_param("mail.catchall.domain")
  
          # first, build a normalized email list and remove those linked to aliases to avoid adding aliases as partners
          normalized_emails = [tools.email_normalize(contact) for contact in emails if tools.email_normalize(contact)]
          if catchall_domain:
              domain_left_parts = [email.split('@')[0] for email in normalized_emails if email and email.split('@')[1] == catchall_domain.lower()]
              if domain_left_parts:
                  found_alias_names = self.env['mail.alias'].sudo().search([('alias_name', 'in', domain_left_parts)]).mapped('alias_name')
                  normalized_emails = [email for email in normalized_emails if email.split('@')[0] not in found_alias_names]
  
          done_partners = [follower for follower in followers if follower.email_normalized in normalized_emails]
          remaining = [email for email in normalized_emails if email not in [partner.email_normalized for partner in done_partners]]
  
          user_partners = self._mail_search_on_user(remaining, extra_domain=extra_domain)
          done_partners += [user_partner for user_partner in user_partners]
          remaining = [email for email in normalized_emails if email not in [partner.email_normalized for partner in done_partners]]
  
          partners = self._mail_search_on_partner(remaining, extra_domain=extra_domain)
          done_partners += [partner for partner in partners]
          remaining = [email for email in normalized_emails if email not in [partner.email_normalized for partner in done_partners]]
  
          # iterate and keep ordering
          partners = []
          for contact in emails:
              normalized_email = tools.email_normalize(contact)
              partner = next((partner for partner in done_partners if partner.email_normalized == normalized_email), self.env['res.partner'])
              if not partner and force_create and normalized_email in normalized_emails:
                  partner = self.env['res.partner'].browse(self.env['res.partner'].name_create(contact)[0])
              partners.append(partner)
          return partners
function_tokens: def _mail_find_partner_from_emails ( self , emails , records = None , force_create = False , extra_domain = False ) : if records and issubclass ( type ( records ) , self . pool [ 'mail.thread' ] ) : followers = records . mapped ( 'message_partner_ids' ) else : followers = self . env [ 'res.partner' ] catchall_domain = self . env [ 'ir.config_parameter' ] . sudo ( ) . get_param ( "mail.catchall.domain" ) # first, build a normalized email list and remove those linked to aliases to avoid adding aliases as partners normalized_emails = [ tools . email_normalize ( contact ) for contact in emails if tools . email_normalize ( contact ) ] if catchall_domain : domain_left_parts = [ email . split ( '@' ) [ 0 ] for email in normalized_emails if email and email . split ( '@' ) [ 1 ] == catchall_domain . lower ( ) ] if domain_left_parts : found_alias_names = self . env [ 'mail.alias' ] . sudo ( ) . search ( [ ( 'alias_name' , 'in' , domain_left_parts ) ] ) . mapped ( 'alias_name' ) normalized_emails = [ email for email in normalized_emails if email . split ( '@' ) [ 0 ] not in found_alias_names ] done_partners = [ follower for follower in followers if follower . email_normalized in normalized_emails ] remaining = [ email for email in normalized_emails if email not in [ partner . email_normalized for partner in done_partners ] ] user_partners = self . _mail_search_on_user ( remaining , extra_domain = extra_domain ) done_partners += [ user_partner for user_partner in user_partners ] remaining = [ email for email in normalized_emails if email not in [ partner . email_normalized for partner in done_partners ] ] partners = self . _mail_search_on_partner ( remaining , extra_domain = extra_domain ) done_partners += [ partner for partner in partners ] remaining = [ email for email in normalized_emails if email not in [ partner . email_normalized for partner in done_partners ] ] # iterate and keep ordering partners = [ ] for contact in emails : normalized_email = tools . email_normalize ( contact ) partner = next ( ( partner for partner in done_partners if partner . email_normalized == normalized_email ) , self . env [ 'res.partner' ] ) if not partner and force_create and normalized_email in normalized_emails : partner = self . env [ 'res.partner' ] . browse ( self . env [ 'res.partner' ] . name_create ( contact ) [ 0 ] ) partners . append ( partner ) return partners