From b2e25a9ce322bac7c95f46934e81f38fb0cbd18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Todorovich?= Date: Mon, 21 Dec 2015 17:51:00 -0300 Subject: [PATCH] Added option to convert retreived names to Title Case. --- base_location_geonames_import/wizard/geonames_import.py | 7 +++++++ .../wizard/geonames_import_view.xml | 3 +++ 2 files changed, 10 insertions(+) diff --git a/base_location_geonames_import/wizard/geonames_import.py b/base_location_geonames_import/wizard/geonames_import.py index a3535be8f..80b90fcac 100644 --- a/base_location_geonames_import/wizard/geonames_import.py +++ b/base_location_geonames_import/wizard/geonames_import.py @@ -45,6 +45,10 @@ class BetterZipGeonamesImport(models.TransientModel): _rec_name = 'country_id' country_id = fields.Many2one('res.country', 'Country', required=True) + title_case = fields.Boolean( + string='Title Case', + help='Converts retreived city and state names to Title Case.' + ) @api.model def transform_city_name(self, city, country): @@ -80,6 +84,9 @@ class BetterZipGeonamesImport(models.TransientModel): "correspond to the selected country (%s).") % (row[0], country.code)) logger.debug('ZIP = %s - City = %s' % (row[1], row[2])) + if (self.title_case): + row[2] = row[2].title() + row[3] = row[3].title() if row[1] and row[2]: zip_model = self.env['res.better.zip'] zips = zip_model.search(self._domain_search_better_zip( diff --git a/base_location_geonames_import/wizard/geonames_import_view.xml b/base_location_geonames_import/wizard/geonames_import_view.xml index ce535f799..ea7a102a6 100644 --- a/base_location_geonames_import/wizard/geonames_import_view.xml +++ b/base_location_geonames_import/wizard/geonames_import_view.xml @@ -12,6 +12,9 @@