Browse Source

Added option to convert retreived names to Title Case.

OCA requirements
14.0
Iván Todorovich 9 years ago
committed by Pedro M. Baeza
parent
commit
31ed3929cb
  1. 4
      base_location_geonames_import/__openerp__.py
  2. 9
      base_location_geonames_import/wizard/geonames_import.py
  3. 3
      base_location_geonames_import/wizard/geonames_import_view.xml

4
base_location_geonames_import/__openerp__.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Base Location Geonames Import module for OpenERP
@ -25,7 +25,7 @@
{
'name': 'Base Location Geonames Import',
'version': '8.0.0.2.0',
'version': '8.0.0.3.0',
'category': 'Extra Tools',
'license': 'AGPL-3',
'summary': 'Import better zip entries from Geonames',

9
base_location_geonames_import/wizard/geonames_import.py

@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- coding: utf-8 -*-
##############################################################################
#
# Base Location Geonames Import module for OpenERP
@ -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