Browse Source

[IMP] base_location_geonames_import: Add conf for selecting state columns based on country_id (#534)

pull/643/head
Franco Tampieri 7 years ago
committed by Pedro M. Baeza
parent
commit
e07c1d6faa
  1. 1
      base_location_geonames_import/README.rst
  2. 1
      base_location_geonames_import/__init__.py
  3. 4
      base_location_geonames_import/__manifest__.py
  4. 11
      base_location_geonames_import/data/res_country_data.xml
  5. 5
      base_location_geonames_import/models/__init__.py
  6. 17
      base_location_geonames_import/models/res_country.py
  7. 15
      base_location_geonames_import/views/res_country_view.xml
  8. 4
      base_location_geonames_import/wizard/geonames_import.py

1
base_location_geonames_import/README.rst

@ -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
----

1
base_location_geonames_import/__init__.py

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from . import models
from . import wizard

4
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,

11
base_location_geonames_import/data/res_country_data.xml

@ -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
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

17
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',
)

15
base_location_geonames_import/views/res_country_view.xml

@ -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
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],
)

Loading…
Cancel
Save