Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
5 ตอบกลับ
11418 มุมมอง

Hi, 

I want to dynamically set email_to field in the email template. If I press the send email button the email should only send to the corresponding sales person's and division manager's mail id ie, partner specified in the invoice line. Please do help.  

อวตาร
ละทิ้ง

Hello Shaffaf R S,

In your custom send mail method add code like as below,

template_id = self.env['ir.model.data'].get_object_reference('module_name', 'template_name')

template_rec = self.env['mail.template'].browse(template_id[1])

template_rec.write({'email_to': 'xyz@xyz.com'})

template_rec.send_mail(emp, force_send = True)

Thanks.

ผู้เขียน

thank you Dipak Shah for your response, but in this case i can't hard-code a particular email address because there are multiple lines and i need to send mail to each sales person of the partner.

Yeah so instead of hard coded email address you can use with ur emails .if it's multiple emails you can add that all into a single list and write email to Field according once only !!

Thanks.

คำตอบที่ดีที่สุด

You can do this sending context to the send_mail function

ex:

email_context = {
'email_to': 'some_email@email.com',
'partner_id': False,
}
self.env.ref("sale.email_template_edi_sale").send_mail(sale.id, email_values=email_context,
notif_layout="mail.mail_notification_paynow", force_send=True)
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

            email = res.customer_id.email

            mail_template = self.env.ref('absale_booking.vocher_email_template')

            mail_template.email_to = email

            mail_template.send_mail(res.id, True)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 20
2792
4
ม.ค. 19
4400
1
ม.ค. 19
7628
[SOLVED] Invisible Button After Clicked แก้ไขแล้ว
2
ม.ค. 19
10241
7
ก.พ. 18
3764