Is it possible to create a function that sends a specific notification through the Odoo mobile app?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
Is it possible to create a function that sends a specific notification through the Odoo mobile app?
I use this function :
def action_alert(self):
user_ids = [21,6]
subject = f'Message from {self.env.user.name}:'
body = f'Title of notification '
for user_id in user_ids:
user = self.env['res.users'].browse(user_id)
if user.partner_id:
channel = self.env['mail.channel'].search([
('channel_partner_ids', 'in', [self.env.user.partner_id.id]),
('channel_partner_ids', 'in', [user.partner_id.id]),
('channel_type', '=', 'chat')
], limit=1)
if not channel:
channel = self.env['mail.channel'].create({
'channel_partner_ids': [(4, self.env.user.partner_id.id), (4, user.partner_id.id)],
'channel_type': 'chat',
'name': 'Direct Message'
})
channel.message_post(
subject=subject,
body=body,
message_type='comment',
subtype_id=self.env.ref('mail.mt_comment').id,
partner_ids=[user.partner_id.id]
)
self.message_post(
body=f'Body of message',
message_type='notification',
subtype_id=self.env.ref('mail.mt_note').id
)
Best regards
Thank you, that works!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
5
thg 7 25
|
2562 | ||
|
6
thg 11 24
|
7549 | ||
|
0
thg 5 25
|
2254 | ||
|
1
thg 7 23
|
6587 | ||
|
0
thg 9 20
|
3088 |