Browse Source

[MIG] base_location_geonames_import to v14

14.0
Alexis de Lattre 4 years ago
committed by Pedro M. Baeza
parent
commit
db8612e270
  1. 3
      base_location_geonames_import/__manifest__.py
  2. 2
      base_location_geonames_import/models/res_country.py
  3. 5
      base_location_geonames_import/readme/CONFIGURE.rst
  4. 3
      base_location_geonames_import/readme/INSTALL.rst
  5. 8
      base_location_geonames_import/readme/USAGE.rst
  6. 2
      base_location_geonames_import/security/ir.model.access.csv
  7. 5
      base_location_geonames_import/views/res_country_view.xml
  8. 5
      base_location_geonames_import/wizard/geonames_import.py
  9. 2
      base_location_geonames_import/wizard/geonames_import_view.xml

3
base_location_geonames_import/__manifest__.py

@ -8,7 +8,7 @@
{ {
"name": "Base Location Geonames Import", "name": "Base Location Geonames Import",
"version": "13.0.2.0.0",
"version": "14.0.1.0.0",
"category": "Partner Management", "category": "Partner Management",
"license": "AGPL-3", "license": "AGPL-3",
"summary": "Import zip entries from Geonames", "summary": "Import zip entries from Geonames",
@ -22,6 +22,7 @@
"website": "https://github.com/OCA/partner-contact", "website": "https://github.com/OCA/partner-contact",
"depends": ["base_location"], "depends": ["base_location"],
"data": [ "data": [
"security/ir.model.access.csv",
"data/res_country_data.xml", "data/res_country_data.xml",
"views/res_country_view.xml", "views/res_country_view.xml",
"wizard/geonames_import_view.xml", "wizard/geonames_import_view.xml",

2
base_location_geonames_import/models/res_country.py

@ -4,7 +4,7 @@
from odoo import fields, models from odoo import fields, models
class ResCountryState(models.Model):
class ResCountry(models.Model):
_inherit = "res.country" _inherit = "res.country"

5
base_location_geonames_import/readme/CONFIGURE.rst

@ -1,7 +1,6 @@
To access the menu to import city zip entries from Geonames To access the menu to import city zip entries from Geonames
you must add yourself to the groups *Administration / Settings* or, if you have sale module
installed, *Sales / Manager* group.
you must be part of the group *Administration / Settings*.
If you want/need to modify the default URL
If you want/need to modify the default Geonames URL
(http://download.geonames.org/export/zip/), you can set the *geonames.url* (http://download.geonames.org/export/zip/), you can set the *geonames.url*
system parameter. system parameter.

3
base_location_geonames_import/readme/INSTALL.rst

@ -1,3 +0,0 @@
To install this module, you need the Python library 'requests'::
pip install requests

8
base_location_geonames_import/readme/USAGE.rst

@ -1,8 +1,6 @@
Go to *Contacts > Configuration > Localization > Import from Geonames*,
and click on it to open a wizard.
Go to the menu *Contacts > Configuration > Localization > Import from Geonames*.
In the wizard, select one or several countries and click on the *Import* button.
When you start the wizard, it will ask you to select a country.
Then, for the selected country, it will delete all not detected entries, download
For each selected country, the wizard will delete all not detected entries, download
the latest version of the list of cities from geonames.org and create new the latest version of the list of cities from geonames.org and create new
city zip entries. city zip entries.

2
base_location_geonames_import/security/ir.model.access.csv

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_city_zip_geonames_import,Full access on city.zip.geonames.import to Settings group,model_city_zip_geonames_import,base.group_system,1,1,1,1

5
base_location_geonames_import/views/res_country_view.xml

@ -4,11 +4,10 @@
<field name="name">res.country.geonames.form</field> <field name="name">res.country.geonames.form</field>
<field name="model">res.country</field> <field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form" /> <field name="inherit_id" ref="base.view_country_form" />
<field name="type">form</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="code" position="after"> <field name="code" position="after">
<field name="geonames_state_name_column" />
<field name="geonames_state_code_column" />
<field name="geonames_state_name_column" groups="base.group_no_one" />
<field name="geonames_state_code_column" groups="base.group_no_one" />
</field> </field>
</field> </field>
</record> </record>

5
base_location_geonames_import/wizard/geonames_import.py

@ -25,11 +25,8 @@ logger = logging.getLogger(__name__)
class CityZipGeonamesImport(models.TransientModel): class CityZipGeonamesImport(models.TransientModel):
_name = "city.zip.geonames.import" _name = "city.zip.geonames.import"
_description = "Import City Zips from Geonames" _description = "Import City Zips from Geonames"
_rec_name = "country_id"
country_ids = fields.Many2many("res.country", string="Countries") country_ids = fields.Many2many("res.country", string="Countries")
# Remove field country_id in future versions
country_id = fields.Many2one("res.country", string="Country")
letter_case = fields.Selection( letter_case = fields.Selection(
[("unchanged", "Unchanged"), ("title", "Title Case"), ("upper", "Upper Case")], [("unchanged", "Unchanged"), ("title", "Title Case"), ("upper", "Upper Case")],
@ -187,7 +184,7 @@ class CityZipGeonamesImport(models.TransientModel):
return city_dict return city_dict
def run_import(self): def run_import(self):
for country in self.country_ids or self.country_id:
for country in self.country_ids:
parsed_csv = self.get_and_parse_csv(country) parsed_csv = self.get_and_parse_csv(country)
self._process_csv(parsed_csv, country) self._process_csv(parsed_csv, country)
return True return True

2
base_location_geonames_import/wizard/geonames_import_view.xml

@ -27,7 +27,7 @@
<button <button
name="run_import" name="run_import"
type="object" type="object"
class="oe_highlight"
class="btn-primary"
string="Import" string="Import"
/> />
<button special="cancel" string="Cancel" class="oe_link" /> <button special="cancel" string="Cancel" class="oe_link" />

Loading…
Cancel
Save