forked from angedras/l10n-italy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] l10n_it_base_location_geonames_import
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'" |