parameters: (self)
return_statement: return mails_sudo
docstring: Send an email to the responsible of each finished mailing with the statistics.
docstring_summary: Send an email to the responsible of each finished mailing with the statistics.
docstring_tokens: Send an email to the responsible of each finished mailing with the statistics .
function: def _action_send_statistics(self):
          """Send an email to the responsible of each finished mailing with the statistics."""
          self.kpi_mail_required = False
  
          mails_sudo = self.env['mail.mail'].sudo()
          for mailing in self:
              if mailing.user_id:
                  mailing = mailing.with_user(mailing.user_id).with_context(
                      lang=mailing.user_id.lang or self._context.get('lang')
                  )
              mailing_type = mailing._get_pretty_mailing_type()
              mail_user = mailing.user_id or self.env.user
              mail_company = mail_user.company_id
  
              link_trackers = self.env['link.tracker'].search(
                  [('mass_mailing_id', '=', mailing.id)]
              ).sorted('count', reverse=True)
              link_trackers_body = self.env['ir.qweb']._render(
                  'mass_mailing.mass_mailing_kpi_link_trackers',
                  {
                      'object': mailing,
                      'link_trackers': link_trackers,
                      'mailing_type': mailing_type,
                  },
              )
  
              rendered_body = self.env['ir.qweb']._render(
                  'digest.digest_mail_main',
                  {
                      'body': tools.html_sanitize(link_trackers_body),
                      'company': mail_company,
                      'user': mail_user,
                      'display_mobile_banner': True,
                      ** mailing._prepare_statistics_email_values()
                  },
              )
  
              full_mail = self.env['mail.render.mixin']._render_encapsulate(
                  'digest.digest_mail_layout',
                  rendered_body,
              )
  
              mail_values = {
                  'auto_delete': True,
                  'author_id': mail_user.partner_id.id,
                  'email_from': mail_user.email_formatted,
                  'email_to': mail_user.email_formatted,
                  'body_html': full_mail,
                  'reply_to': mail_company.email_formatted or mail_user.email_formatted,
                  'state': 'outgoing',
                  'subject': _('24H Stats of %(mailing_type)s "%(mailing_name)s"',
                               mailing_type=mailing._get_pretty_mailing_type(),
                               mailing_name=mailing.subject
                              ),
              }
              mails_sudo += self.env['mail.mail'].sudo().create(mail_values)
          return mails_sudo
function_tokens: def _action_send_statistics ( self ) : self . kpi_mail_required = False mails_sudo = self . env [ 'mail.mail' ] . sudo ( ) for mailing in self : if mailing . user_id : mailing = mailing . with_user ( mailing . user_id ) . with_context ( lang = mailing . user_id . lang or self . _context . get ( 'lang' ) ) mailing_type = mailing . _get_pretty_mailing_type ( ) mail_user = mailing . user_id or self . env . user mail_company = mail_user . company_id link_trackers = self . env [ 'link.tracker' ] . search ( [ ( 'mass_mailing_id' , '=' , mailing . id ) ] ) . sorted ( 'count' , reverse = True ) link_trackers_body = self . env [ 'ir.qweb' ] . _render ( 'mass_mailing.mass_mailing_kpi_link_trackers' , { 'object' : mailing , 'link_trackers' : link_trackers , 'mailing_type' : mailing_type , } , ) rendered_body = self . env [ 'ir.qweb' ] . _render ( 'digest.digest_mail_main' , { 'body' : tools . html_sanitize ( link_trackers_body ) , 'company' : mail_company , 'user' : mail_user , 'display_mobile_banner' : True , * * mailing . _prepare_statistics_email_values ( ) } , ) full_mail = self . env [ 'mail.render.mixin' ] . _render_encapsulate ( 'digest.digest_mail_layout' , rendered_body , ) mail_values = { 'auto_delete' : True , 'author_id' : mail_user . partner_id . id , 'email_from' : mail_user . email_formatted , 'email_to' : mail_user . email_formatted , 'body_html' : full_mail , 'reply_to' : mail_company . email_formatted or mail_user . email_formatted , 'state' : 'outgoing' , 'subject' : _ ( '24H Stats of %(mailing_type)s "%(mailing_name)s"' , mailing_type = mailing . _get_pretty_mailing_type ( ) , mailing_name = mailing . subject ) , } mails_sudo += self . env [ 'mail.mail' ] . sudo ( ) . create ( mail_values ) return mails_sudo