Browse Source

Added option to convert retreived names to Title Case.

pull/494/head
Iván Todorovich 9 years ago
committed by Pedro M. Baeza
parent
commit
9efa63b5ef
  1. 7
      base_location_geonames_import/wizard/geonames_import.py
  2. 3
      base_location_geonames_import/wizard/geonames_import_view.xml

7
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(

3
base_location_geonames_import/wizard/geonames_import_view.xml

@ -12,6 +12,9 @@
<label string="For the country selected above, this wizard will download the latest version of the list of cities from geonames.org, create new location entries if not found already in the system, and DELETE MISSING ENTRIES from new file."
colspan="2" name="import-help"/>
</group>
<group name="options">
<field name="title_case"/>
</group>
<footer>
<button name="run_import" type="object"
class="oe_highlight" string="Import"/>

Loading…
Cancel
Save