diff --git a/addons/im_livechat/controllers/main.py b/addons/im_livechat/controllers/main.py index 4b1f5775da9..c8006fd2df1 100644 --- a/addons/im_livechat/controllers/main.py +++ b/addons/im_livechat/controllers/main.py @@ -29,7 +29,7 @@ class LivechatController(http.Controller): def loader(self, channel_id, **kwargs): username = kwargs.get("username", _("Visitor")) channel = request.env['im_livechat.channel'].sudo().browse(channel_id) - info = request.env['im_livechat.channel'].match_rules(request, channel.id, username=username) + info = request.env['im_livechat.channel'].with_context(from_external_page=True).match_rules(request, channel.id, username=username) return request.render('im_livechat.loader', {'info': info, 'web_session_required': True}) if info else False @http.route('/im_livechat/available', type='json', auth="public") diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index a308fde4c09..e4733816ba8 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -207,7 +207,10 @@ class ImLivechatChannel(models.Model): if country_ids: country_id = country_ids[0].id # extract url - url = request.httprequest.headers.get('Referer') or request.httprequest.base_url + if self.env.context.get('from_external_page', False): + url = request.httprequest.headers.get('Referer') + else: + url = request.httprequest.base_url # find the match rule for the given country and url rule = self.env['im_livechat.channel.rule'].sudo().match_rule(channel_id, url, country_id) if rule: