跳至内容
菜单
此问题已终结
3 回复
15171 查看

I have a custom module and some fields.

user_id = fields.Many2many('res.users', string="Responsible")#responsible user

When the record is created I want to send the popup message like "Enquiries are created".
Notes

please give the idea behind this.Thanks in advance


形象
丢弃
编写者

Thanks, Amal. I will check the module.

编写者 最佳答案

I get the solution of this problem.Here I share my code
Firstly call the send_to_channel method in create.Must create the channel between 2 users for activate the popup message functioanlity.

code sample

def send_to_channel(self, body, result):

         users = result.user_id

        ch_obj = self.env['mail.channel']

        body = body +' '+ result.seq_no

        if users:

            for user in users:

                ch_name = user.name+', '+self.env.user.name

                ch = ch_obj.sudo().search([('name', 'ilike', str(ch_name))])

                if not ch:

                    ch = ch_obj.sudo().search([('name', 'ilike', str(self.env.user.name+', '+user.name))])

            ch.message_post(attachment_ids=[],body=body,content_subtype='html',

                            message_type='comment',partner_ids=[],subtype='mail.mt_comment',

                            email_from=self.env.user.partner_id.email,author_id=self.env.user.partner_id.id)

        return True


形象
丢弃

How to send direct message/chat to any user without using a channel?

When you send a message to another user for first time, a private channel it's created and sender and receiver are added to that channel. So when you send a message to another user, you are not sending a direct message, you are sending a message to a private channel.

相关帖文 回复 查看 活动
5
9月 24
10211
1
12月 22
3608
2
9月 22
2925
5
9月 19
8065
1
11月 17
5416