Browse Source

[FIX+IMP] base_location_geonames_import

* Tests
* New menu location
* Wizard options fixed
pull/494/head
Pedro M. Baeza 8 years ago
parent
commit
d3d5a7a843
  1. 18
      base_location_geonames_import/tests/test_base_location_geonames_import.py
  2. 4
      base_location_geonames_import/wizard/geonames_import.py
  3. 10
      base_location_geonames_import/wizard/geonames_import_view.xml

18
base_location_geonames_import/tests/test_base_location_geonames_import.py

@ -21,7 +21,7 @@ class TestBaseLocationGeonamesImport(common.TransactionCase):
('country_id', '=', self.country.id)
])
self.assertTrue(state_count)
# Look if the are imported zips
# Look if there are imported zips
zip_count = self.env['res.better.zip'].search_count([
('country_id', '=', self.country.id)
])
@ -44,3 +44,19 @@ class TestBaseLocationGeonamesImport(common.TransactionCase):
})
self.wizard.run_import()
self.assertFalse(zip_entry.exists())
def test_import_title(self):
self.wizard.letter_case = 'title'
self.wizard.with_context(max_import=1).run_import()
zip = self.env['res.better.zip'].search(
[('country_id', '=', self.country.id)], limit=1
)
self.assertEqual(zip.city, zip.city.title())
def test_import_upper(self):
self.wizard.letter_case = 'upper'
self.wizard.with_context(max_import=1).run_import()
zip = self.env['res.better.zip'].search(
[('country_id', '=', self.country.id)], limit=1
)
self.assertEqual(zip.city, zip.city.upper())

4
base_location_geonames_import/wizard/geonames_import.py

@ -70,10 +70,10 @@ 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.letter_case.title:
if self.letter_case == 'title':
row[2] = row[2].title()
row[3] = row[3].title()
elif self.letter_case.upper:
elif self.letter_case == 'upper':
row[2] = row[2].upper()
row[3] = row[3].upper()
if row[1] and row[2]:

10
base_location_geonames_import/wizard/geonames_import_view.xml

@ -31,9 +31,11 @@
<field name="target">new</field>
</record>
<menuitem id="better_zip_geonames_import_menu"
action="better_zip_geonames_import_action"
parent="sales_team.menu_localisation"
sequence="50"/>
<menuitem
id="better_zip_geonames_import_menu"
action="better_zip_geonames_import_action"
parent="base_location.locations_root_menu"
sequence="50"
/>
</odoo>
Loading…
Cancel
Save