From 9e426a0226d042099b6d60d6a3b57cc5f393c9ce Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Mon, 15 Sep 2014 16:28:14 +0200 Subject: [PATCH] [IMP] using ir.config_parameter for geonames URL --- base_location_geonames_import/__openerp__.py | 8 ++++++-- base_location_geonames_import/wizard/geonames_import.py | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/base_location_geonames_import/__openerp__.py b/base_location_geonames_import/__openerp__.py index 1af0a5567..f4baecd64 100644 --- a/base_location_geonames_import/__openerp__.py +++ b/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. diff --git a/base_location_geonames_import/wizard/geonames_import.py b/base_location_geonames_import/wizard/geonames_import.py index ee125b6d5..2efd03f57 100644 --- a/base_location_geonames_import/wizard/geonames_import.py +++ b/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: