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

Hi there,

I wanted to know if there's a way to trigger the send by email button by code.

Let's say I have a boolean field on my sales order. I want to know if it's possible to trigger the send by email button, once the boolean field becomes True.

I can trigger the sale order confirmation button by code (record.action_confirm()). But when I do this with send by email button, nothin happens. I assume it is because the mail.compose.message wizard opens, but can I not trigger the send button on that wizard too?

Thanks,

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Yes, you need to create/call the compose mail wizard as well from automated action.
Use the following python code in your automated action.

MCM = self.env['mail.compose.message']
for record in records:
# Call SO method to retrieve the context
so_mcm_vals = record.action_quotation_send().get('context', {})
# Create record of compose mail
compose_msg = MCM.with_context(so_mcm_vals).create({})
compose_msg.onchange_template_id_wrapper()
compose_msg.action_send_mail()



อวตาร
ละทิ้ง

Thanks. This is great. How would you go about selecting a non-default email template?

ผู้เขียน

You could try adding the template id to the piece of code:
compose_msg.onchange_template_id_wrapper(2)

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
ต.ค. 23
8414
0
มี.ค. 23
1857
0
ต.ค. 21
3182
Available on the Website แก้ไขแล้ว
2
มี.ค. 24
1414
2
ม.ค. 25
3571