Skip to content

Commit

Permalink
[ADD] l10n_it_base_location_geonames_import
Browse files Browse the repository at this point in the history
  • Loading branch information
eLBati committed Aug 11, 2014
1 parent 5e3b643 commit aa51a58
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
22 changes: 22 additions & 0 deletions l10n_it_base_location_geonames_import/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014 Agile Business Group (http://www.agilebg.com)
# @author Lorenzo Battistini <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from . import geonames_import
42 changes: 42 additions & 0 deletions l10n_it_base_location_geonames_import/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014 Agile Business Group (http://www.agilebg.com)
# @author Lorenzo Battistini <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

{
'name': 'Base Location Provinces Import',
'version': '0.1',
'category': 'Extra Tools',
'license': 'AGPL-3',
'summary': 'Import base_location entries (provinces) from Geonames',
'description': """
This module extends base_location_geonames_import in order to correctly import
Italian provinces
""",
'author': 'Agile Business Group',
'website': 'http://www.agilebg.com',
'depends': ['base_location_geonames_import'],
'data': [
],
'test': [
'test/import.yml',
],
'installable': True,
'active': False,
}
33 changes: 33 additions & 0 deletions l10n_it_base_location_geonames_import/geonames_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (C) 2014 Agile Business Group (http://www.agilebg.com)
# @author Lorenzo Battistini <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################

from openerp import models, api


class better_zip_geonames_import(models.TransientModel):
_inherit = 'better.zip.geonames.import'

@api.model
def select_or_create_state(
self, row, country_id, code_row_index=4, name_row_index=3
):
return super(better_zip_geonames_import, self).select_or_create_state(
row, country_id, code_row_index=6, name_row_index=5)
27 changes: 27 additions & 0 deletions l10n_it_base_location_geonames_import/test/import.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-
I create the wizard
-
!record {model: better.zip.geonames.import, id: import_wizard_1, view: base_location_geonames_import.better_zip_geonames_import_form}:
country_id: base.it
-
I run the import
-
!python {model: better.zip.geonames.import}: |
self.run_import(cr, uid, [ref('import_wizard_1')], context=context)
-
I check the data
-
!python {model: res.better.zip}: |
state_obj = self.pool['res.country.state']
state_ids = state_obj.search(cr, uid, [
('code', '=', 'GE'),
('country_id', '=', ref('base.it')),
], context=context)
assert len(state_ids) == 1, "There must be 1 GE"
zip_ids = self.search(cr, uid, [
('name', '=', '16017'),
('city', '=', 'Isola Del Cantone'),
('state_id', '=', state_ids[0]),
('country_id', '=', ref('base.it'))
], context=context)
assert len(zip_ids) == 1, "There must be 1 'Isola Del Cantone'"

0 comments on commit aa51a58

Please sign in to comment.