Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
9105 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hello try :

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

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 12 24
5545
1
thg 3 21
7092
0
thg 10 15
3896
0
thg 7 24
1267
2
thg 4 23
3035