Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.0] Port of enhancement of geonames import from 10.0 branch #534

Merged
merged 2 commits into from
Jan 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base_location_geonames_import/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Contributors
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Dave Lasley <dave@laslabs.com>
* Jordi Ballester <jordi.ballester@eficent.com>
* Franco Tampieri <franco@tampieri.info>

Icon
----
Expand Down
1 change: 1 addition & 0 deletions base_location_geonames_import/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-

from . import models
from . import wizard
4 changes: 3 additions & 1 deletion base_location_geonames_import/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions base_location_geonames_import/data/res_country_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="base.es" model="res.country">
<field name="geonames_state_code_column" eval="6" />
<field name="geonames_state_name_column" eval="5" />
</record>
<record id="base.it" model="res.country">
<field name="geonames_state_code_column" eval="6" />
<field name="geonames_state_name_column" eval="5" />
</record>
</odoo>
5 changes: 5 additions & 0 deletions base_location_geonames_import/models/__init__.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions base_location_geonames_import/models/res_country.py
Original file line number Diff line number Diff line change
@@ -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',
)
15 changes: 15 additions & 0 deletions base_location_geonames_import/views/res_country_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<record model="ir.ui.view" id="view_country_geonames_form">
<field name="name">res.country.geonames.form</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form"/>
<field name="type">form</field>
<field name="arch" type="xml">
<field name="code" position="after">
<field name="geonames_state_name_column" />
<field name="geonames_state_code_column" />
</field>
</field>
</record>
</odoo>
4 changes: 4 additions & 0 deletions base_location_geonames_import/wizard/geonames_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
)
Expand Down