diff --git a/l10n_it_location_nuts/README.rst b/l10n_it_location_nuts/README.rst new file mode 100644 index 000000000000..710f5cf119b1 --- /dev/null +++ b/l10n_it_location_nuts/README.rst @@ -0,0 +1,104 @@ +================== +ITA - Regioni NUTS +================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--italy-lightgray.png?logo=github + :target: https://github.com/OCA/l10n-italy/tree/12.0/l10n_it_location_nuts + :alt: OCA/l10n-italy +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/l10n-italy-12-0/l10n-italy-12-0-l10n_it_location_nuts + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/122/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +**Italiano** + +Questo modulo permette di collegare le regioni NUTS di livello 4 con le province italiane. + +**English** + +This module allows to link the NUTS regions having level 4 with italian provinces. + +**Table of contents** + +.. contents:: + :local: + +Configuration +============= + +**Italiano** + +Dopo aver installato il modulo, aprire la procedura guidata: + +Contatti / Configurazione / Localizzazione / Importa NUTS 2013 + +e confermare. + +Questo aggiornerà le regioni NUTS con i dati presenti nel `RAMON `__ (Reference And Management Of Nomenclatures) +e le collegherà alle province già presenti in Odoo. + +**English** + +After installing the module, open the wizard: + +Contacts / Configuration / Localization / Import NUTS 2013 + +and confirm. +This will update the NUTS regions with data stored in `RAMON `__ (Reference And Management Of Nomenclatures) +and will link them with states already stored in Odoo. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Agile Business Group + +Contributors +~~~~~~~~~~~~ + +* Simone Rubino +* Sergio Corato + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +This module is part of the `OCA/l10n-italy `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/l10n_it_location_nuts/__init__.py b/l10n_it_location_nuts/__init__.py new file mode 100644 index 000000000000..5a7dc0f2bcae --- /dev/null +++ b/l10n_it_location_nuts/__init__.py @@ -0,0 +1,4 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import wizard +from .hooks import post_init_hook diff --git a/l10n_it_location_nuts/__manifest__.py b/l10n_it_location_nuts/__manifest__.py new file mode 100644 index 000000000000..8b32d4cad286 --- /dev/null +++ b/l10n_it_location_nuts/__manifest__.py @@ -0,0 +1,20 @@ +# Copyright 2018 Simone Rubino - Agile Business Group +# Copyright 2019 Sergio Corato +# Copyright 2021 Leonardo Cazziolati +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + 'name': 'ITA - Regioni NUTS', + 'summary': 'Opzioni NUTS specifiche per l\'Italia', + 'version': '14.0.1.0.1', + 'category': 'Localisation/Europe', + 'website': 'https://github.com/OCA/l10n-italy', + 'author': 'Agile Business Group, ' + 'Odoo Community Association (OCA)', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'depends': [ + 'base_location_nuts', + ], + 'post_init_hook': 'post_init_hook', +} diff --git a/l10n_it_location_nuts/hooks.py b/l10n_it_location_nuts/hooks.py new file mode 100644 index 000000000000..014cb75d18d3 --- /dev/null +++ b/l10n_it_location_nuts/hooks.py @@ -0,0 +1,16 @@ +# Copyright 2018 Simone Rubino - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, SUPERUSER_ID +import logging + +_logger = logging.getLogger(__name__) + + +def post_init_hook(cr, registry): + """Define Italian specific configuration in res.country.""" + with api.Environment.manage(): + env = api.Environment(cr, SUPERUSER_ID, {}) + italy = env.ref('base.it') + _logger.info('Setting Italy NUTS configuration') + italy.write({'state_level': 4}) diff --git a/l10n_it_location_nuts/i18n/it.po b/l10n_it_location_nuts/i18n/it.po new file mode 100644 index 000000000000..54be5005470e --- /dev/null +++ b/l10n_it_location_nuts/i18n/it.po @@ -0,0 +1,22 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_location_nuts +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2020-01-08 12:13+0000\n" +"Last-Translator: Sergio Zanchetta \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 3.10\n" + +#. module: l10n_it_location_nuts +#: model:ir.model,name:l10n_it_location_nuts.model_nuts_import +msgid "Import NUTS items from European RAMON service" +msgstr "Importazione voci NUTS dal servizio europeo RAMON" diff --git a/l10n_it_location_nuts/i18n/l10n_it_location_nuts.pot b/l10n_it_location_nuts/i18n/l10n_it_location_nuts.pot new file mode 100644 index 000000000000..1f807a4b7bee --- /dev/null +++ b/l10n_it_location_nuts/i18n/l10n_it_location_nuts.pot @@ -0,0 +1,20 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * l10n_it_location_nuts +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: l10n_it_location_nuts +#: model:ir.model,name:l10n_it_location_nuts.model_nuts_import +msgid "Import NUTS items from European RAMON service" +msgstr "" + diff --git a/l10n_it_location_nuts/readme/CONFIGURE.rst b/l10n_it_location_nuts/readme/CONFIGURE.rst new file mode 100644 index 000000000000..65bf5ab58063 --- /dev/null +++ b/l10n_it_location_nuts/readme/CONFIGURE.rst @@ -0,0 +1,20 @@ +**Italiano** + +Dopo aver installato il modulo, aprire la procedura guidata: + +Contatti / Configurazione / Localizzazione / Importa NUTS 2013 + +e confermare. + +Questo aggiornerà le regioni NUTS con i dati presenti nel `RAMON `__ (Reference And Management Of Nomenclatures) +e le collegherà alle province già presenti in Odoo. + +**English** + +After installing the module, open the wizard: + +Contacts / Configuration / Localization / Import NUTS 2013 + +and confirm. +This will update the NUTS regions with data stored in `RAMON `__ (Reference And Management Of Nomenclatures) +and will link them with states already stored in Odoo. diff --git a/l10n_it_location_nuts/readme/CONTRIBUTORS.rst b/l10n_it_location_nuts/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..55f595c27520 --- /dev/null +++ b/l10n_it_location_nuts/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Simone Rubino +* Sergio Corato +* Leonardo Cazziolati diff --git a/l10n_it_location_nuts/readme/DESCRIPTION.rst b/l10n_it_location_nuts/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..abcc9e254b43 --- /dev/null +++ b/l10n_it_location_nuts/readme/DESCRIPTION.rst @@ -0,0 +1,7 @@ +**Italiano** + +Questo modulo permette di collegare le regioni NUTS di livello 4 con le province italiane. + +**English** + +This module allows to link the NUTS regions having level 4 with italian provinces. diff --git a/l10n_it_location_nuts/static/description/icon.png b/l10n_it_location_nuts/static/description/icon.png new file mode 100644 index 000000000000..3a0328b516c4 Binary files /dev/null and b/l10n_it_location_nuts/static/description/icon.png differ diff --git a/l10n_it_location_nuts/static/description/index.html b/l10n_it_location_nuts/static/description/index.html new file mode 100644 index 000000000000..56847e0fb4ff --- /dev/null +++ b/l10n_it_location_nuts/static/description/index.html @@ -0,0 +1,439 @@ + + + + + + +ITA - Regioni NUTS + + + +
+

ITA - Regioni NUTS

+ + +

Beta License: AGPL-3 OCA/l10n-italy Translate me on Weblate Try me on Runbot

+

Italiano

+

Questo modulo permette di collegare le regioni NUTS di livello 4 con le province italiane.

+

English

+

This module allows to link the NUTS regions having level 4 with italian provinces.

+

Table of contents

+ +
+

Configuration

+

Italiano

+

Dopo aver installato il modulo, aprire la procedura guidata:

+

Contatti / Configurazione / Localizzazione / Importa NUTS 2013

+

e confermare.

+

Questo aggiornerà le regioni NUTS con i dati presenti nel RAMON (Reference And Management Of Nomenclatures) +e le collegherà alle province già presenti in Odoo.

+

English

+

After installing the module, open the wizard:

+

Contacts / Configuration / Localization / Import NUTS 2013

+

and confirm. +This will update the NUTS regions with data stored in RAMON (Reference And Management Of Nomenclatures) +and will link them with states already stored in Odoo.

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Agile Business Group
  • +
+
+ +
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/l10n-italy project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/l10n_it_location_nuts/tests/__init__.py b/l10n_it_location_nuts/tests/__init__.py new file mode 100644 index 000000000000..45060f2edf2c --- /dev/null +++ b/l10n_it_location_nuts/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import test_nuts diff --git a/l10n_it_location_nuts/tests/test_nuts.py b/l10n_it_location_nuts/tests/test_nuts.py new file mode 100644 index 000000000000..75542529ef96 --- /dev/null +++ b/l10n_it_location_nuts/tests/test_nuts.py @@ -0,0 +1,28 @@ +# Copyright 2018 Simone Rubino - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo.tests.common import SavepointCase + + +class TestNUTS(SavepointCase): + + @classmethod + def setUpClass(cls): + super(TestNUTS, cls).setUpClass() + importer = cls.env['nuts.import'] + importer.run_import() + cls.rome_nuts = cls.env['res.partner.nuts'].search( + [('code', '=', 'ITI43')]) + rome_state_id = cls.env.ref('base.state_it_rm').id + cls.it_partner = cls.env['res.partner'].create({'name': 'it_partner'}) + cls.it_partner.write({'state_id': rome_state_id}) + + def test_italian_nuts(self): + """ + Check that onchange method correctly bind level 4 nuts with + italian states. + """ + self.it_partner.onchange_state_id_base_location_nuts() + self.assertEqual( + self.it_partner.state_id, + self.it_partner.nuts4_id.state_id) diff --git a/l10n_it_location_nuts/wizard/__init__.py b/l10n_it_location_nuts/wizard/__init__.py new file mode 100644 index 000000000000..989078b33251 --- /dev/null +++ b/l10n_it_location_nuts/wizard/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from . import nuts_import diff --git a/l10n_it_location_nuts/wizard/nuts_import.py b/l10n_it_location_nuts/wizard/nuts_import.py new file mode 100644 index 000000000000..75cceacb4b24 --- /dev/null +++ b/l10n_it_location_nuts/wizard/nuts_import.py @@ -0,0 +1,133 @@ +# Copyright 2018 Simone Rubino - Agile Business Group +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, models + + +class NutsImport(models.TransientModel): + _inherit = 'nuts.import' + _it_state_map = { + 'ITG14': 'base.state_it_ag', # Agrigento + 'ITC18': 'base.state_it_al', # Alessandria + 'ITI32': 'base.state_it_an', # Ancona + 'ITI18': 'base.state_it_ar', # Arezzo + 'ITI34': 'base.state_it_ap', # Ascoli Piceno + 'ITC17': 'base.state_it_at', # Asti + 'ITF34': 'base.state_it_av', # Avellino + 'ITF47': 'base.state_it_ba', # Bari + 'ITF48': 'base.state_it_bt', # Barletta-Andria-Trani + 'ITH33': 'base.state_it_bl', # Belluno + 'ITF32': 'base.state_it_bn', # Benevento + 'ITC46': 'base.state_it_bg', # Bergamo + 'ITC13': 'base.state_it_bi', # Biella + 'ITH55': 'base.state_it_bo', # Bologna + 'ITH10': 'base.state_it_bz', # Bolzano + 'ITC47': 'base.state_it_bs', # Brescia + 'ITF44': 'base.state_it_br', # Brindisi + 'ITG27': 'base.state_it_ca', # Cagliari + 'ITG15': 'base.state_it_cl', # Caltanissetta + 'ITF22': 'base.state_it_cb', # Campobasso + 'ITG2C': 'base.state_it_ci', # Carbonia-Iglesias + 'ITF31': 'base.state_it_ce', # Caserta + 'ITG17': 'base.state_it_ct', # Catania + 'ITF63': 'base.state_it_cz', # Catanzaro + 'ITF14': 'base.state_it_ch', # Chieti + 'ITC42': 'base.state_it_co', # Como + 'ITF61': 'base.state_it_cs', # Cosenza + 'ITC4A': 'base.state_it_cr', # Cremona + 'ITF62': 'base.state_it_kr', # Crotone + 'ITC16': 'base.state_it_cn', # Cuneo + 'ITG16': 'base.state_it_en', # Enna + 'ITI35': 'base.state_it_fm', # Fermo + 'ITH56': 'base.state_it_fe', # Ferrara + 'ITI14': 'base.state_it_fi', # Firenze + 'ITF46': 'base.state_it_fg', # Foggia + 'ITH58': 'base.state_it_fc', # Forlì-Cesena + 'ITI45': 'base.state_it_fr', # Frosinone + 'ITC33': 'base.state_it_ge', # Genova + 'ITH43': 'base.state_it_go', # Gorizia + 'ITI1A': 'base.state_it_gr', # Grosseto + 'ITC31': 'base.state_it_im', # Imperia + 'ITF21': 'base.state_it_is', # Isernia + 'ITF11': 'base.state_it_aq', # L'Aquila + 'ITC34': 'base.state_it_sp', # La Spezia + 'ITI44': 'base.state_it_lt', # Latina + 'ITF45': 'base.state_it_le', # Lecce + 'ITC43': 'base.state_it_lc', # Lecco + 'ITI16': 'base.state_it_li', # Livorno + 'ITC49': 'base.state_it_lo', # Lodi + 'ITI12': 'base.state_it_lu', # Lucca + 'ITI33': 'base.state_it_mc', # Macerata + 'ITC4B': 'base.state_it_mn', # Mantova + 'ITI11': 'base.state_it_ms', # Massa-Carrara + 'ITF52': 'base.state_it_mt', # Matera + 'ITG2B': 'base.state_it_vs', # Medio Campidano + 'ITG13': 'base.state_it_me', # Messina + 'ITC4C': 'base.state_it_mi', # Milano + 'ITH54': 'base.state_it_mo', # Modena + 'ITC4D': 'base.state_it_mb', # Monza e Brianza + 'ITF33': 'base.state_it_na', # Napoli + 'ITC15': 'base.state_it_no', # Novara + 'ITG26': 'base.state_it_nu', # Nuoro + 'ITG2A': 'base.state_it_og', # Ogliastra + 'ITG29': 'base.state_it_ot', # Olbia-Tempio + 'ITG28': 'base.state_it_or', # Oristano + 'ITH36': 'base.state_it_pd', # Padova + 'ITG12': 'base.state_it_pa', # Palermo + 'ITH52': 'base.state_it_pr', # Parma + 'ITC48': 'base.state_it_pv', # Pavia + 'ITI21': 'base.state_it_pg', # Perugia + 'ITI31': 'base.state_it_pu', # Pesaro e Urbino + 'ITF13': 'base.state_it_pe', # Pescara + 'ITH51': 'base.state_it_pc', # Piacenza + 'ITI17': 'base.state_it_pi', # Pisa + 'ITI13': 'base.state_it_pt', # Pistoia + 'ITH41': 'base.state_it_pn', # Pordenone + 'ITF51': 'base.state_it_pz', # Potenza + 'ITI15': 'base.state_it_po', # Prato + 'ITG18': 'base.state_it_rg', # Ragusa + 'ITH57': 'base.state_it_ra', # Ravenna + 'ITF65': 'base.state_it_rc', # Reggio Calabria + 'ITH53': 'base.state_it_re', # Reggio Emilia + 'ITI42': 'base.state_it_ri', # Rieti + 'ITH59': 'base.state_it_rn', # Rimini + 'ITI43': 'base.state_it_rm', # Roma + 'ITH37': 'base.state_it_ro', # Rovigo + 'ITF35': 'base.state_it_sa', # Salerno + 'ITG25': 'base.state_it_ss', # Sassari + 'ITC32': 'base.state_it_sv', # Savona + 'ITI19': 'base.state_it_si', # Siena + 'ITG19': 'base.state_it_sr', # Siracusa + 'ITC44': 'base.state_it_so', # Sondrio + 'ITG2H': 'base.state_it_su', # Sud Sardegna + 'ITF43': 'base.state_it_ta', # Taranto + 'ITF12': 'base.state_it_te', # Teramo + 'ITI22': 'base.state_it_tr', # Terni + 'ITC11': 'base.state_it_to', # Torino + 'ITG11': 'base.state_it_tp', # Trapani + 'ITH20': 'base.state_it_tn', # Trento + 'ITH34': 'base.state_it_tv', # Treviso + 'ITH44': 'base.state_it_ts', # Trieste + 'ITH42': 'base.state_it_ud', # Udine + 'ITC41': 'base.state_it_va', # Varese + 'ITH35': 'base.state_it_ve', # Venezia + 'ITC14': 'base.state_it_vb', # Verbano-Cusio-Ossola + 'ITC12': 'base.state_it_vc', # Vercelli + 'ITH31': 'base.state_it_vr', # Verona + 'ITF64': 'base.state_it_vv', # Vibo Valentia + 'ITH32': 'base.state_it_vi', # Vicenza + 'ITI41': 'base.state_it_vt' # Viterbo + } + + @api.model + def state_mapping(self, data, node): + mapping = super(NutsImport, self).state_mapping(data, node) + level = data.get('level', 0) + code = data.get('code', '') + if self.current_country_id.code == 'IT' and level == 4: + external_ref = self._it_state_map.get(code, False) + if external_ref: + state = self.env.ref(external_ref) + if state: + mapping['state_id'] = state.id + return mapping