Skip to Content
Menu
This question has been flagged
2 Replies
6284 Views

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])
Avatar
Discard
Best Answer

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

Avatar
Discard
Best Answer

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



Avatar
Discard
Related Posts Replies Views Activity
1
Jul 24
467
2
Jul 24
602
1
May 24
1198
2
May 24
799
1
Apr 24
1384