This question has been flagged
2 Replies
6024 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