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

Hello! 


I want to show these messages but their body is empty so in the chatter appears nothing. 

I mean, model 'mail.message' with message_type = 'notification'.

How can i do it?

Thanks!

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

def send_notification(self, message):
target_user_group = self.env.ref('module.group_name')

target_users = self.env['res.users'].search(
[('groups_id', '=', target_user_group.id)]
)

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

self.message_post(body=message, message_type='notification', subtype='mail.mt_comment',
notification_ids=notification_ids)
you can do something like this here i'm getting all target users through a specific group and append notifications to them the notification will be shown in each user chat notification drop down list and also at the Discuss Home page

Hope it helped 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 6 19
9085
1
thg 2 25
1601
2
thg 12 24
2590
0
thg 11 24
2304
3
thg 5 24
4823