Ejemplo n.º 1
0
    def get_email(self, record, sender, to, cc, bcc, languages):
        pool = Pool()
        Attachment = pool.get('notification.email.attachment')

        # TODO order languages to get default as last one for title
        content, title = get_email(self.content, record, languages)
        language = list(languages)[-1]
        from_ = sender
        with Transaction().set_context(language=language.code):
            notification = self.__class__(self.id)
            if notification.from_:
                from_ = notification.from_
            if self.subject:
                title = (TextTemplate(
                    notification.subject).generate(record=record).render())

        if self.attachments:
            msg = MIMEMultipart('mixed')
            msg.attach(content)
            for report in self.attachments:
                msg.attach(Attachment.get_mime(report, record, language.code))
        else:
            msg = content

        set_from_header(msg, sender, from_)
        msg['To'] = ', '.join(to)
        msg['Cc'] = ', '.join(cc)
        msg['Subject'] = Header(title, 'utf-8')
        msg['Auto-Submitted'] = 'auto-generated'
        return msg
Ejemplo n.º 2
0
 def get_email_unsubscribe(self, report_name='marketing.email.unsubscribe'):
     pool = Pool()
     ActionReport = pool.get('ir.action.report')
     report, = ActionReport.search([
         ('report_name', '=', report_name),
     ],
                                   limit=1)
     return get_email(report, self, [self.list_.language])
Ejemplo n.º 3
0
 def _email(self, from_, to, cc, bcc, languages):
     # TODO order languages to get default as last one for title
     msg, title = get_email(self.level.email_template, self, languages)
     msg['From'] = from_
     msg['To'] = ', '.join(to)
     msg['Cc'] = ', '.join(cc)
     msg['Bcc'] = ', '.join(bcc)
     msg['Subject'] = Header(title, 'utf-8')
     msg['Auto-Submitted'] = 'auto-generated'
     return msg
Ejemplo n.º 4
0
    def get_email(self, record, from_, to, cc, bcc, languages):
        pool = Pool()
        Attachment = pool.get('notification.email.attachment')

        # TODO order languages to get default as last one for title
        content, title = get_email(self.content, record, languages)

        if self.attachments:
            msg = MIMEMultipart('mixed')
            msg.attach(content)
            language = list(languages)[-1]
            for report in self.attachments:
                msg.attach(Attachment.get_mime(report, record, language.code))
        else:
            msg = content

        msg['From'] = from_
        msg['To'] = ', '.join(to)
        msg['Cc'] = ', '.join(cc)
        msg['Subject'] = Header(title, 'utf-8')
        msg['Auto-Submitted'] = 'auto-generated'
        return msg
Ejemplo n.º 5
0
 def get_email_reset_password(self):
     return get_email('res.user.email_reset_password', self, self.languages)
Ejemplo n.º 6
0
 def get_email_validation(self):
     return get_email(
         'web.user.email_validation', self, self.languages)