تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
4057 أدوات العرض

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 :)

الصورة الرمزية
إهمال
الكاتب

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);

}

},

أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب

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

أفضل إجابة

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

الصورة الرمزية
إهمال
الكاتب أفضل إجابة

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);
        }
    },
الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
يناير 23
1239
1
نوفمبر 15
6796
0
نوفمبر 23
912
3
ديسمبر 23
6764
0
ديسمبر 21
2000