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

I trying to send an email to a partner while create a document. The message is creates but not sending to the partner. Below is my code.

*.py

@api.model
def create(self,vals):
    result = super(HRHolidays,self).create(vals)
    message_sent = result.message_post(message_type='notification', subtype='mt_comment', partner_ids=[25])
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

I have a code that sends email on button click, you can use this on our create method as well.

Have a look please: http://learnopenerp.blogspot.com/2017/08/odoo-how-to-send-email-on-button-click.html

Thanks

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

Hi Kabeer,

 

1st solution,

  • result.message_subscribe([25])

  • result.message_post(body="Test Message",  message_type="notification", subtype="mail.mt_comment")


2nd solution,

  • result.message_post(body="Test Message",  message_type="notification", subtype="mail.mt_comment", partner_ids=[25] )


in your case,

@api.model
def create(self,vals):
    result = super(HRHolidays,self).create(vals)
    result.message_post(
        message_type='notification',
        subtype='mail.mt_comment',
        partner_ids=[25]
    )
    return result



อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ก.ค. 24
1808
1
ก.ค. 25
740
5
พ.ค. 25
18166
0
เม.ย. 25
1059
1
เม.ย. 25
1552