[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#126594 X-original-commit: cb9c003700d2d8eb3be326260bae5fa5e599b89c Signed-off-by: Matthieu Stockbauer (tsm) <tsm@odoo.com> Signed-off-by: Nasreddin Boulif (bon) <bon@odoo.com>
This commit is contained in:
@@ -85,6 +85,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,
|
||||
@@ -153,7 +155,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_discuss_channel(
|
||||
anonymous_name,
|
||||
|
||||
Reference in New Issue
Block a user