跳至内容
菜单
此问题已终结
1 回复
9111 查看

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.

形象
丢弃
最佳答案

Hello try :

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

形象
丢弃
相关帖文 回复 查看 活动
3
12月 24
5549
1
3月 21
7098
0
10月 15
3898
0
7月 24
1269
2
4月 23
3036