Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
17829 Lượt xem

I want to send notifications programatically in odoo8.

According to the post below, 

      https://www.odoo.com/nl_NL/forum/help-1/question/how-to-send-a-message-programmatically-3389  

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 ?


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi

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)



Ảnh đại diện
Huỷ bỏ
Tác giả

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?

Tác giả

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...

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 7 25
324
2
thg 7 23
6011
2
thg 12 22
14884
1
thg 11 21
5011
0
thg 1 21
2337