Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
9084 Zobrazení

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
Zrušit
Nejlepší odpověď

Hello try :

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
3
pro 24
5540
1
bře 21
7079
0
říj 15
3894
0
čvc 24
1264
2
dub 23
3031