Skip to Content
Menú
This question has been flagged
1 Respondre
9063 Vistes

I'm triying to pass context to the email template but keep an error:

TypeError: send_mail() got an unexpected keyword argument 'context'

And the code:

def payment_email(self):
        template_id = self.env.ref('seguro.email_template_payment_info').id
        context = {
        'unpaid_employees':self.search_salaries_unpaid()
        }
            
        self.env['mail.template'].browse(template_id).send_mail(self.id, force_send=True, context=context)

Without the context parameter all works fine. I'm using version 13.0

Is there a way to pass the context? All that I found it is for older versions.

Avatar
Descartar
Best Answer

Hello try :

self.env['mail.template'].browse(template_id).with_context(context).send_mail(args)

Avatar
Descartar
Related Posts Respostes Vistes Activitat
3
de des. 24
5529
1
de març 21
7061
0
d’oct. 15
3888
0
de jul. 24
1263
2
d’abr. 23
3028