Browse Source

[IMP] using ir.config_parameter for geonames URL

pull/22/head
Lorenzo Battistini 10 years ago
parent
commit
9e426a0226
  1. 8
      base_location_geonames_import/__openerp__.py
  2. 5
      base_location_geonames_import/wizard/geonames_import.py

8
base_location_geonames_import/__openerp__.py

@ -34,8 +34,12 @@ Base Location Geonames Import
=============================
This module adds a wizard to import better zip entries from Geonames
(http://download.geonames.org/export/zip/). When you start the wizard,
it will ask you to select a country ; then, for the selected country,
(http://download.geonames.org/export/zip/).
If want want/need to modify the URL, you can set the 'geonames.url'
system parameter.
When you start the wizard,
it will ask you to select a country. Then, for the selected country,
it will delete all the current better zip entries, download the latest version
of the list of cities from geonames.org and create new better zip entries.

5
base_location_geonames_import/wizard/geonames_import.py

@ -96,7 +96,10 @@ class better_zip_geonames_import(models.TransientModel):
bzip_obj = self.env['res.better.zip']
country_id = self.country_id.id
country_code = self.country_id.code.upper()
url = 'http://download.geonames.org/export/zip/%s.zip' % country_code
config_url = self.pool['ir.config_parameter'].get_param(
'geonames.url',
default='http://download.geonames.org/export/zip/%s.zip')
url = config_url % country_code
logger.info('Starting to download %s' % url)
res_request = requests.get(url)
if res_request.status_code != requests.codes.ok:

Loading…
Cancel
Save