Skip to content
Snippets Groups Projects
Commit cb9c0037 authored by Nasreddin Boulif (bon)'s avatar Nasreddin Boulif (bon)
Browse files

[FIX] im_livechat: display chatbot in website or user language


Steps to reproduce:

  - Install the module `crm_livechat`
  - Activate another language (e.g. fr_FR)
  - Open a new incognito window and go to the website
  - On website, switch to the activated language
  - Open contact page
  - Open the chatbot

Issue:

  The chatbot is displayed in `en_US`.

Cause:

  The chatbot is displayed in the current user language (not website
  language).
  Public user have by default `en_US` as language.

Solution:

  Retrieve the chatbot with the website activated language if set,
  otherwise, retrieve the chatbot in the user language.
  Fallback on `en_US`.

opw-3284807

closes odoo/odoo#126341

Signed-off-by: default avatarMatthieu Stockbauer (tsm) <tsm@odoo.com>
parent 6b66ef3f
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,8 @@ class LivechatController(http.Controller):
# find the first matching rule for the given country and url
matching_rule = request.env['im_livechat.channel.rule'].sudo().match_rule(channel_id, url, country_id)
if matching_rule and (not matching_rule.chatbot_script_id or matching_rule.chatbot_script_id.script_step_ids):
frontend_lang = request.httprequest.cookies.get('frontend_lang', request.env.user.lang or 'en_US')
matching_rule = matching_rule.with_context(lang=frontend_lang)
rule = {
'action': matching_rule.action,
'auto_popup_timer': matching_rule.auto_popup_timer,
......@@ -134,7 +136,8 @@ class LivechatController(http.Controller):
chatbot_script = False
if chatbot_script_id:
chatbot_script = request.env['chatbot.script'].sudo().browse(chatbot_script_id)
frontend_lang = request.httprequest.cookies.get('frontend_lang', request.env.user.lang or 'en_US')
chatbot_script = request.env['chatbot.script'].sudo().with_context(lang=frontend_lang).browse(chatbot_script_id)
return request.env["im_livechat.channel"].with_context(lang=False).sudo().browse(channel_id)._open_livechat_mail_channel(
anonymous_name,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment