Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ

Hello,

I am using odoo v.11 . I am trying to send notification to another user and the other user should be able to view the notification by logging in his account whenever he/she wants. I have seen many techniques in different websites and tried almost everything. For example: notify_info, message_post, creating a record in mail.message but none of them worked correctly. For example if I use notify_info then the other user gets the notification but it vanishes immediately. Is there any method or technique that really works? Is there any way to do that programmatically ? 

I have also tried things mentioned here:

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

But nothing works. When other user logs in his account, he sees no new messages in his inbox.

Thanks


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

hello, do like below code.

inherit mail.thread object into your object.

and on the any action wherever you want add the code like 

@api.multi
def your_method(self):
    self.message_post(body="your message", partner_ids=<list of partner ids>)

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

i create article about that here, hope it can solve your problem

https://www.linkedin.com/pulse/send-inbox-message-notification-specific-user-odoo-13-alvin-adji/?trackingId=I9Rr8N3mQfyA%2Bh5JAtBzsw%3D%3D

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

Try This work with me to send an inbox message to the user

if users:
notification_ids = [(0, 0,
{
'res_partner_id': user.partner_id.id,
'notification_type': 'inbox'
}
) for user in users if users]

self.env['mail.message'].create({
'message_type': "notification",
'body': "Your Body",
'subject': "Your Subject",
'partner_ids': [(4, user.partner_id.id) for user in users if users],
'model': self._name,
'res_id': self.id,
'notification_ids': notification_ids,
'author_id': self.env.user.partner_id and self.env.user.partner_id.id
})
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

https://www.linkedin.com/pulse/send-inbox-message-notification-specific-user-odoo-13-alvin-adji/?trackingId=I9Rr8N3mQfyA%2Bh5JAtBzsw%3D%3D

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 5 16
3786
2
thg 6 25
767
1
thg 3 15
4335
2
thg 2 25
5055