Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

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


Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Nejlepší odpověď

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
})
Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
2
kvě 16
3786
2
čvn 25
767
1
bře 15
4332
2
úno 25
5054