odoo/enterprise#27399

Created by SM Learn, Julien Castiaux (juc)
Merged at bc80577c6a95b07effc5bf9fe6c78cdedf96ba88

Statuses:

label
odoo-dev:master-smarter_geoip-juc
head
9306b5e48a87d3fe9cf7153f500dd6057248c87f
merged
3 years ago by SM Learn, Julien Castiaux (juc)
odoo/odoo odoo/enterprise odoo/documentation
master #91337 #27399 #2151

[IMP] *: update modules to use the new geoip API

request.geoip is no more a dictionnary cached in the session. It is now
a full blown object with lazy and smart geolocalisation capabilities.

Among other things, the previous dictionnary API is now deprecated. The
changes are:

  • request.geoip['country_name'] -> request.geoip.country_name
  • request.geoip['country_code'] -> request.geoip.country_code
  • request.geoip['city'] -> request.geoip.city.name
  • request.geoip['latitude'] -> request.geoip.location.latitude
  • request.geoip['longitude'] -> request.geoip.location.longitude
  • request.geoip['region'] -> (request.geoip.subdivisions[0].iso_code if request.geoip.subdivisions else None)
  • request.geoip['time_zone'] -> request.geoip.location.time_zone

It is safe to access all the attributes. Doing request.geoip.city.name
when the geolocalization failed (missing db, invalid address, ...)
evaluates to None. It does not raise an AttributeError.

task-2848206

Related to odoo/odoo#91337