parameters: (self)
return_statement: return seen_list
docstring: Returns a set of emails already targeted by current mailing/campaign (no duplicates)
docstring_summary: Returns a set of emails already targeted by current mailing/campaign (no duplicates)
docstring_tokens: Returns a set of emails already targeted by current mailing / campaign ( no duplicates )
function: def _get_seen_list(self):
          """Returns a set of emails already targeted by current mailing/campaign (no duplicates)"""
          self.ensure_one()
          target = self.env[self.mailing_model_real]
  
          # avoid loading a large number of records in memory
          # + use a basic heuristic for extracting emails
          query = """
              SELECT lower(substring(t.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)'))
                FROM mailing_trace s
                JOIN %(target)s t ON (s.res_id = t.id)
               WHERE substring(t.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)') IS NOT NULL
          """
  
          # Apply same 'get email field' rule from mail_thread.message_get_default_recipients
          if 'partner_id' in target._fields:
              mail_field = 'email'
              query = """
                  SELECT lower(substring(p.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)'))
                    FROM mailing_trace s
                    JOIN %(target)s t ON (s.res_id = t.id)
                    JOIN res_partner p ON (t.partner_id = p.id)
                   WHERE substring(p.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)') IS NOT NULL
              """
          elif issubclass(type(target), self.pool['mail.thread.blacklist']):
              mail_field = 'email_normalized'
          elif 'email_from' in target._fields:
              mail_field = 'email_from'
          elif 'partner_email' in target._fields:
              mail_field = 'partner_email'
          elif 'email' in target._fields:
              mail_field = 'email'
          else:
              raise UserError(_("Unsupported mass mailing model %s", self.mailing_model_id.name))
  
          if self.ab_testing_enabled:
              query += """
                 AND s.campaign_id = %%(mailing_campaign_id)s;
              """
          else:
              query += """
                 AND s.mass_mailing_id = %%(mailing_id)s
                 AND s.model = %%(target_model)s;
              """
          query = query % {'target': target._table, 'mail_field': mail_field}
          params = {'mailing_id': self.id, 'mailing_campaign_id': self.campaign_id.id, 'target_model': self.mailing_model_real}
          self._cr.execute(query, params)
          seen_list = set(m[0] for m in self._cr.fetchall())
          _logger.info(
              "Mass-mailing %s has already reached %s %s emails", self, len(seen_list), target._name)
          return seen_list
function_tokens: def _get_seen_list ( self ) : self . ensure_one ( ) target = self . env [ self . mailing_model_real ] # avoid loading a large number of records in memory # + use a basic heuristic for extracting emails query = """
              SELECT lower(substring(t.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)'))
                FROM mailing_trace s
                JOIN %(target)s t ON (s.res_id = t.id)
               WHERE substring(t.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)') IS NOT NULL
          """ # Apply same 'get email field' rule from mail_thread.message_get_default_recipients if 'partner_id' in target . _fields : mail_field = 'email' query = """
                  SELECT lower(substring(p.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)'))
                    FROM mailing_trace s
                    JOIN %(target)s t ON (s.res_id = t.id)
                    JOIN res_partner p ON (t.partner_id = p.id)
                   WHERE substring(p.%(mail_field)s, '([^ ,;<@]+@[^> ,;]+)') IS NOT NULL
              """ elif issubclass ( type ( target ) , self . pool [ 'mail.thread.blacklist' ] ) : mail_field = 'email_normalized' elif 'email_from' in target . _fields : mail_field = 'email_from' elif 'partner_email' in target . _fields : mail_field = 'partner_email' elif 'email' in target . _fields : mail_field = 'email' else : raise UserError ( _ ( "Unsupported mass mailing model %s" , self . mailing_model_id . name ) ) if self . ab_testing_enabled : query += """
                 AND s.campaign_id = %%(mailing_campaign_id)s;
              """ else : query += """
                 AND s.mass_mailing_id = %%(mailing_id)s
                 AND s.model = %%(target_model)s;
              """ query = query % { 'target' : target . _table , 'mail_field' : mail_field } params = { 'mailing_id' : self . id , 'mailing_campaign_id' : self . campaign_id . id , 'target_model' : self . mailing_model_real } self . _cr . execute ( query , params ) seen_list = set ( m [ 0 ] for m in self . _cr . fetchall ( ) ) _logger . info ( "Mass-mailing %s has already reached %s %s emails" , self , len ( seen_list ) , target . _name ) return seen_list