Odoo Help


new api for message_post??

on 2/14/16, 9:21 AM 2,640 views

I want to send notifications programatically in odoo8.

According to the post below, 


I modified the code to new api version as below:

post_vars = {'subject': "Message subject", 'body': "Message body", 'partner_ids': [(4, 3)],}
thread_pool = self.env['mail.thread']
thread_pool.message_post(False, type="notification", subtype="mt_comment", **post_vars)

But I got the following error.
TypeError: message_post() got multiple values for keyword argument 'body'.

If  I removed the False parameter, thread_id will be [], and I got index error for the following code in message_post()

if isinstance(thread_id, (list, tuple)):
    thread_id = thread_id[0]

So, how to call message_post() with new api ?


Jérémy Kersten (jke)

--Jérémy Kersten (jke)--

| 3 3 5
Jodoigne, Belgium
--Jérémy Kersten (jke)--

Jérémy is a member of the core R&D team since september 2013. He developed several projects for OpenERP version 8 including the eCommerce, the Google Calendar synchronization and the new product variants/configurator. Now, he manages Odoo website and themes for saas.

Jérémy Kersten (jke)
On 2/14/16, 10:06 AM


1) You need to remove the False argument.

2) You need to post message on a record.

     record = self.env['my.model'].browse(id)
post_vars = {'subject': "Message subject", 'body': "Message body", 'partner_ids': [(4, 3)],}
record.message_post(type="notification", subtype="mt_comment", **post_vars)

Thanks, Jeremy. Is that to say i have to inherit mail.thread for my model? For your example, does it mean thread_id would be the record.id? Is it possible to set thread_id to False?

on 2/14/16, 8:48 PM

My requirement is simple. I just want to send some notification message to user's Inbox, and I don't need a thread or followers...

on 2/14/16, 8:56 PM

Ok, so why you don't call message_post on the user browse_record ?

Jérémy Kersten (jke)
on 2/15/16, 4:46 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 2/14/16, 9:21 AM
Seen: 2640 times
Last updated: 2/14/16, 10:06 AM