[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) <tsm@odoo.com>
Co-authored-by: Matthieu Stockbauer <48757558+tsm-odoo@users.noreply.github.com>
This commit is contained in:
tsm-odoo
2024-03-12 15:08:30 +00:00
co-authored by Matthieu Stockbauer
parent a57c23be70
commit 56f505ece9
@@ -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))