Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
3 Răspunsuri
4571 Vizualizări

Hello, is there any way to change the name of the operator in live chat box?

If yes, do you know some articles on how to do it?

Your help is greatly appreciated. Thanks :)

Imagine profil
Abandonează
Autor

I tried to override the methods but it returns the operator name and visitor the same display name. Any idea?

im_livechat_channel.py

@api.model

def get_livechat_info(self, channel_id, username='Visitor'):

info = super(ImLivechatChannel, self).get_livechat_info(channel_id, username)

info['options']['chat_author_nickname'] = self.env.user.nickname

return info

im_livechat.js

add_message: function (data, options) {

var msg = {

id: data.id,

attachment_ids: data.attachment_ids,

author_id: data.author_id,

body: data.body,

date: moment(time.str_to_datetime(data.date)),

is_needaction: false,

is_note: data.is_note,

customer_email_data: []

};

// Compute displayed author name or email

// msg.displayed_author = msg.author_id && msg.author_id[1] ||

// this.options.default_username;

if (msg.author_id && msg.author_id[1]) {

msg.displayed_author = this.options.chat_author_nickname;

}

else {

msg.displayed_author = this.options.default_username;

}

// Compute the avatar_url

msg.avatar_src = this.server_url;

if (msg.author_id && msg.author_id[0]) {

msg.avatar_src += "/web/image/res.partner/" + msg.author_id[0] + "/image_small";

} else {

msg.avatar_src += "/mail/static/src/img/smiley/avatar.jpg";

}

if (options && options.prepend) {

this.messages.unshift(msg);

} else {

this.messages.push(msg);

}

},

Cel mai bun răspuns

Not sure but maybe this app may help you to change the name of the operator in live chat.

Imagine profil
Abandonează
Autor

thanks for your help but I am looking for an answer/articles which helps me to do my code.

Cel mai bun răspuns

There now is an option in your Odoo profile to input a preferred name in the "Online Chat Name" field on your profile (top right of Odoo screen).
select My Profile > Preferences > Online Chat Name

Imagine profil
Abandonează
Autor Cel mai bun răspuns

Rewriting the code.


python

class ImLivechatChannel(models.Model):
    _inherit = "im_livechat.channel"
    @api.model
    def get_livechat_info(self, channel_id, username='Visitor'):
        info = super(ImLivechatChannel, self).get_livechat_info(channel_id, username)
        info['options']['chat_author_nickname'] = self.env.user.nickname
        return info




js

add_message: function (data, options) {
        var msg = {
            id: data.id,
            attachment_ids: data.attachment_ids,
            author_id: data.author_id,
            body: data.body,
            date: moment(time.str_to_datetime(data.date)),
            is_needaction: false,
            is_note: data.is_note,
            customer_email_data: []
        };
        
        // Compute displayed author name or email
        // msg.displayed_author = msg.author_id && msg.author_id[1] ||
        //                        this.options.default_username;
        if (msg.author_id && msg.author_id[1]) {
           msg.displayed_author = this.options.chat_author_nickname;
        }
        else {
           msg.displayed_author = this.options.default_username;
        }
        // Compute the avatar_url
        msg.avatar_src = this.server_url;
        if (msg.author_id && msg.author_id[0]) {
            msg.avatar_src += "/web/image/res.partner/" + msg.author_id[0] + "/image_small";
        } else {
            msg.avatar_src += "/mail/static/src/img/smiley/avatar.jpg";
        }
        if (options && options.prepend) {
            this.messages.unshift(msg);
        } else {
            this.messages.push(msg);
        }
    },
Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
ian. 23
1701
1
nov. 15
7134
0
nov. 23
1165
3
dec. 23
7332
0
dec. 21
2365