diff options
| author | Aaron Bohy <aab@odoo.com> | 2015-12-16 11:10:30 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-12-16 15:48:43 +0100 |
| commit | c58c8f4bd2a4cffa97eaa3cafa9bb46e4be6851b (patch) | |
| tree | c54413a4462ca24279dc637f1ba7311e9c96d9eb | |
| parent | 0c92788d88b85107ede2457256d906a72a7dd041 (diff) | |
[FIX] im_livechat: use correct url to find rules that apply
The problem was that, when calling 'match_rules()' from the loader template,
we compared the wrong url with the url regexp defined in rules. Indeed, we used
the url of the page we were leaving, not the one we were going to.
We thus need to know if we are coming from the controller, or from the loader
template directly as the way to get the correct url differs.
Courtesy of JEM
| -rw-r--r-- | addons/im_livechat/controllers/main.py | 2 | ||||
| -rw-r--r-- | addons/im_livechat/models/im_livechat_channel.py | 5 |
2 files changed, 5 insertions, 2 deletions
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: |
