diff --git a/base_location_geonames_import/README.rst b/base_location_geonames_import/README.rst index c37fdadeb..62eac8eab 100644 --- a/base_location_geonames_import/README.rst +++ b/base_location_geonames_import/README.rst @@ -63,6 +63,7 @@ Contributors * Pedro M. Baeza * Dave Lasley * Jordi Ballester +* Franco Tampieri Icon ---- diff --git a/base_location_geonames_import/__init__.py b/base_location_geonames_import/__init__.py index 3b4c3edf0..35e7c9600 100644 --- a/base_location_geonames_import/__init__.py +++ b/base_location_geonames_import/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- +from . import models from . import wizard diff --git a/base_location_geonames_import/__manifest__.py b/base_location_geonames_import/__manifest__.py index 4462f7a99..f1e2da919 100644 --- a/base_location_geonames_import/__manifest__.py +++ b/base_location_geonames_import/__manifest__.py @@ -9,7 +9,7 @@ { 'name': 'Base Location Geonames Import', - 'version': '11.0.1.0.1', + 'version': '11.0.1.1.1', 'category': 'Partner Management', 'license': 'AGPL-3', 'summary': 'Import better zip entries from Geonames', @@ -22,6 +22,8 @@ 'depends': ['base_location'], 'external_dependencies': {'python': ['requests']}, 'data': [ + 'data/res_country_data.xml', + 'views/res_country_view.xml', 'wizard/geonames_import_view.xml', ], 'installable': True, diff --git a/base_location_geonames_import/data/res_country_data.xml b/base_location_geonames_import/data/res_country_data.xml new file mode 100644 index 000000000..cd27f2ed5 --- /dev/null +++ b/base_location_geonames_import/data/res_country_data.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/base_location_geonames_import/models/__init__.py b/base_location_geonames_import/models/__init__.py new file mode 100644 index 000000000..3a4c215d4 --- /dev/null +++ b/base_location_geonames_import/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Franco Tampieri, Freelancer http://franco.tampieri.info +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import res_country diff --git a/base_location_geonames_import/models/res_country.py b/base_location_geonames_import/models/res_country.py new file mode 100644 index 000000000..279d2ce79 --- /dev/null +++ b/base_location_geonames_import/models/res_country.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# Copyright 2017 Franco Tampieri, Freelancer http://franco.tampieri.info +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ResCountryState(models.Model): + + _inherit = 'res.country' + + geonames_state_name_column = fields.Integer( + 'Geonames State Name Column', + ) + geonames_state_code_column = fields.Integer( + 'Geonames State Code Column', + ) diff --git a/base_location_geonames_import/views/res_country_view.xml b/base_location_geonames_import/views/res_country_view.xml new file mode 100644 index 000000000..61086aac6 --- /dev/null +++ b/base_location_geonames_import/views/res_country_view.xml @@ -0,0 +1,15 @@ + + + + res.country.geonames.form + res.country + + form + + + + + + + + diff --git a/base_location_geonames_import/wizard/geonames_import.py b/base_location_geonames_import/wizard/geonames_import.py index f3f24a5c7..163491f27 100644 --- a/base_location_geonames_import/wizard/geonames_import.py +++ b/base_location_geonames_import/wizard/geonames_import.py @@ -164,6 +164,10 @@ class BetterZipGeonamesImport(models.TransientModel): @api.model def select_or_create_state( self, row, country, code_row_index=4, name_row_index=3): + if country.geonames_state_code_column: + code_row_index = country.geonames_state_code_column + if country.geonames_state_name_column: + name_row_index = country.geonames_state_name_column return self._get_state( country.id, row[code_row_index], row[name_row_index], )