- url = request.httprequest.headers['Referer'] or request.httprequest.base_url
- rule = registry.get('im_livechat.channel.rule').match_rule(cr, uid, channel_id, url, context=context)
+ # find the country from the request
+ country_id = False
+ country_code = request.session.geoip and request.session.geoip.get('country_name', False) or False
+ if country_code:
+ country_ids = registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context)
+ if country_ids:
+ country_id = country_ids[0]
+ # extract url
+ url = request.httprequest.headers.get('Referer', False) or request.httprequest.base_url
+ # find the match rule for the given country and url
+ rule = registry.get('im_livechat.channel.rule').match_rule(cr, uid, channel_id, url, country_id, context=context)