From 6bfb52868256b5fbd13aee705981c5df4bcce435 Mon Sep 17 00:00:00 2001 From: Franco Tampieri Date: Sat, 16 Dec 2017 14:39:25 +0100 Subject: [PATCH 1/2] [Fix] Port of MP #529 --- base_location_geonames_import/README.rst | 1 + base_location_geonames_import/__init__.py | 1 + base_location_geonames_import/__manifest__.py | 4 +++- .../data/res_country_data.xml | 11 +++++++++++ .../models/__init__.py | 5 +++++ .../models/res_country.py | 17 +++++++++++++++++ .../views/res_country_view.xml | 15 +++++++++++++++ .../wizard/geonames_import.py | 4 ++++ 8 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 base_location_geonames_import/data/res_country_data.xml create mode 100644 base_location_geonames_import/models/__init__.py create mode 100644 base_location_geonames_import/models/res_country.py create mode 100644 base_location_geonames_import/views/res_country_view.xml diff --git a/base_location_geonames_import/README.rst b/base_location_geonames_import/README.rst index c37fdadebee..038299d8db9 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 3b4c3edf09c..35e7c9600c5 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 4462f7a99f9..f1e2da91959 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 00000000000..cd27f2ed582 --- /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 00000000000..3a4c215d420 --- /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 00000000000..279d2ce799a --- /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 00000000000..61086aac61c --- /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 f3f24a5c72d..163491f27c6 100644 --- a/base_location_geonames_import/wizard/geonames_import.py +++ b/base_location_geonames_import/wizard/geonames_import.py @@ -164,6 +164,10 @@ def _get_state(self, country_id, code, name): @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], ) From c6218acb9551660d26f58ea8b7c08d2acbcd0b11 Mon Sep 17 00:00:00 2001 From: Franco Tampieri Date: Tue, 2 Jan 2018 16:43:43 +0100 Subject: [PATCH 2/2] [Fix] Fix list error on README.MD file --- base_location_geonames_import/README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base_location_geonames_import/README.rst b/base_location_geonames_import/README.rst index 038299d8db9..62eac8eab93 100644 --- a/base_location_geonames_import/README.rst +++ b/base_location_geonames_import/README.rst @@ -63,7 +63,7 @@ Contributors * Pedro M. Baeza * Dave Lasley * Jordi Ballester -# Franco Tampieri +* Franco Tampieri Icon ----