This question has been flagged
3 Replies
13143 Views

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


Avatar
Discard
Author

Thanks, Amal. I will check the module.

Author Best Answer

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


Avatar
Discard

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.