diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 5f1b54dd7a4..d0f021e170f 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -6,14 +6,6 @@ from openerp.addons.web import http from openerp.addons.web.http import request from openerp.tools.translate import _ from openerp.addons.website.models.website import slug -import logging -_logger = logging.getLogger(__name__) - -try: - import GeoIP -except ImportError: - GeoIP = None - _logger.warn("Please install GeoIP python module to use Ecommerce checkout localisation.") PPG = 20 # Products Per Page PPR = 4 # Products Per Row @@ -381,13 +373,11 @@ class website_sale(http.Controller): checkout["shipping_different"] = True # Default search by user country - if GeoIP and not checkout.get('country_id'): - GI = GeoIP.open('/usr/share/GeoIP/GeoIP.dat', 0) - country_code = GI.country_code_by_addr(request.httprequest.remote_addr) - if country_code: - country_ids = request.registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context) - if country_ids: - checkout['country_id'] = country_ids[0] + country_code = request.session['geoip'].get('country_code') + if country_code: + country_ids = request.registry.get('res.country').search(cr, uid, [('code', '=', country_code)], context=context) + if country_ids: + checkout['country_id'] = country_ids[0] values = { 'countries': countries,