From 56f505ece937ebbdcb1c5c37f37c85d51b077ea0 Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Tue, 12 Mar 2024 10:14:59 +0100 Subject: [PATCH] [FIX] im_livechat: show operator name in chat bot channels When a live chat starts with a bot, the channel name is missing the operator and the visitor name. This makes it challenging for live chat managers to review the session history. This PR resolves the issue by updating the channel name when an operator is found. closes odoo/odoo#157385 X-original-commit: 725316e22f52780c7c96aedebbd9f5c4700bb3b2 Signed-off-by: Matthieu Stockbauer (tsm) Co-authored-by: Matthieu Stockbauer <48757558+tsm-odoo@users.noreply.github.com> --- addons/im_livechat/models/chatbot_script_step.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/im_livechat/models/chatbot_script_step.py b/addons/im_livechat/models/chatbot_script_step.py index 3392f0c2091..ffb45ffe059 100644 --- a/addons/im_livechat/models/chatbot_script_step.py +++ b/addons/im_livechat/models/chatbot_script_step.py @@ -342,6 +342,12 @@ class ChatbotScriptStep(models.Model): open_chat_window=True, post_joined_message=False) + # rename the channel to include the operator's name + discuss_channel.sudo().name = ' '.join([ + self.env.user.display_name if not self.env.user._is_public() else discuss_channel.anonymous_name, + human_operator.livechat_username if human_operator.livechat_username else human_operator.name + ]) + if self.message: # first post the message of the step (if we have one) posted_message = discuss_channel._chatbot_post_message(self.chatbot_script_id, plaintext2html(self.message))