GeoIP

Note

Cette documentation s’applique uniquement aux bases de données on-premise.

Installation

  1. Download both the GeoLite2 City and Country databases. You should end up with two files called GeoLite2-City.mmdb and GeoLite2-Country.mmdb.

  2. Move the files to the folder /usr/share/GeoIP/.

    mv ~/Downloads/GeoLite2-City.mmdb /usr/share/GeoIP/
    mv ~/Downloads/GeoLite2-Country.mmdb /usr/share/GeoIP/
    
  3. Redémarrer le serveur

Note

If you don’t want to locate the geoip database in /usr/share/GeoIP/, use the --geoip-city-db and --geoip-country-db options of the Odoo command line interface. These options take the absolute path to the GeoIP database file and use it as the GeoIP database. For example:

./odoo-bin --geoip-city-db= ~/Downloads/GeoLite2-City.mmdb

Pour plus d'infos

Test GeoIP geolocation in your Odoo website

Edit a web page to include some geo-ip information such as the country name of the current request IP address. To do so:

  1. Allez à votre site web. Ouvrez la page web sur laquelle vous voulez tester GeoIP.

  2. Choisissez Personnaliser ‣ HTML/CSS/JS Editor.

  3. Ajoutez l’élément XML suivant dans la page :

    <h1 class="text-center" t-esc="request.geoip.country.name or 'geoip failure'"/>
    
  4. Save and refresh the page.

Geo-ip is working if you read your country name displayed in bold in the middle of the page.

In case you read « geoip failure » instead then the geolocalization failed. The common causes are:

  1. The browsing IP address is the localhost (127.0.0.1) or a local area network one. If you don’t know, you can access your website using mobile data.

  2. You are using a reverse-proxy (apache, nginx) in front of Odoo but didn’t start Odoo with the proxy-mode enabled. See proxy mode.

  3. The GeoIP database is corrupt, missing or unaccessible. In such case a warning was logged in the server logs.