Skip to content

Commit

Permalink
Merge 75c629d into 5a8eb6d
Browse files Browse the repository at this point in the history
  • Loading branch information
rami-wafaie committed Jun 20, 2018
2 parents 5a8eb6d + 75c629d commit c478966
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 0 deletions.
84 changes: 84 additions & 0 deletions l10n_de_location_nuts/README.rst
@@ -0,0 +1,84 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

========================
NUTS Regions for Germany
========================

This module allows to relate German state NUTS level 2 locations with the
German states defined by localization.

* German states (NUTS level 2) related with Partner State


Installation
============

To install this addon, you need 'requests' python module:

* pip intall requests


Configuration
=============

After installation, you must click at import wizard to populate NUTS items
in Odoo database in:
Sales > Configuration > Address Book > Import NUTS 2013

This wizard will download from Europe RAMON service the metadata to
build NUTS in Odoo. Each localization addon (l10n_es_location_nuts,
l10n_de_location_nuts, ...) will inherit this wizard and
relate each NUTS item with states. So if you install a new localization addon
you must re-build NUTS clicking this wizard again.


Usage
=====

Only Administrator can manage NUTS list (it is not neccesary because
it is an European convention) but any registered user can read them,
in order to allow to assign them to partner object.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/175/11.0



Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/l10n-germany/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.


Credits
=======

Contributors
------------
* Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Rafael Blasco <rafael.blasco@tecnativa.com>
* Jairo Llopis <jairo.llopis@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* Rami Alwafaie <rami.alwafaie@initos.com>


Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
6 changes: 6 additions & 0 deletions l10n_de_location_nuts/__init__.py
@@ -0,0 +1,6 @@
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2015 Tecnativa - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import wizard
from .hooks import post_init_hook
22 changes: 22 additions & 0 deletions l10n_de_location_nuts/__manifest__.py
@@ -0,0 +1,22 @@
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2015 Tecnativa - Jairo Llopis
# Copyright 2015 Tecnativa - David Vidal
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

{
'name': 'NUTS Regions for German',
'summary': 'NUTS specific options for German',
'version': '11.0.1.0.0',
'category': 'Localisation/Europe',
'website': 'http://www.tecnativa.com',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'license': 'AGPL-3',
'application': False,
'depends': [
'base_location_nuts',
'l10n_de_country_states',
],
'post_init_hook': 'post_init_hook',
'installable': True,
}
20 changes: 20 additions & 0 deletions l10n_de_location_nuts/hooks.py
@@ -0,0 +1,20 @@
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2015 Tecnativa - Jairo Llopis
# Copyright 2015 Tecnativa - David Vidal
# 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 German specific configuration in res.country."""
with api.Environment.manage():
env = api.Environment(cr, SUPERUSER_ID, {})
germany = env.ref('base.de')
_logger.info('Setting Germany NUTS configuration')
germany.write({
'state_level': 2,
})
21 changes: 21 additions & 0 deletions l10n_de_location_nuts/i18n/es.po
@@ -0,0 +1,21 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * l10n_de_location_nuts
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-11 16:16+0000\n"
"PO-Revision-Date: 2015-06-11 16:16+0000\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_de_location_nuts
#: model:ir.model,name:l10n_de_location_nuts.model_nuts_import
msgid "Import NUTS items from European RAMON service"
msgstr "Importar regiones NUTS desde el servicio europeo RAMON"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions l10n_de_location_nuts/wizard/__init__.py
@@ -0,0 +1,5 @@
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2015 Tecnativa - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import nuts_import
58 changes: 58 additions & 0 deletions l10n_de_location_nuts/wizard/nuts_import.py
@@ -0,0 +1,58 @@
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2015 Tecnativa - Jairo Llopis
# 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'
_de_state_map = {
# BADEN-WÜRTTEMBERG
'DE1': 'l10n_de_country_states.res_country_state_BW',
# BAYERN
'DE2': 'l10n_de_country_states.res_country_state_BY',
# BERLIN
'DE3': 'l10n_de_country_states.res_country_state_BE',
# BRANDENBURG
'DE4': 'l10n_de_country_states.res_country_state_BB',
# BREMEN
'DE5': 'l10n_de_country_states.res_country_state_HB',
# HAMBURG
'DE6': 'l10n_de_country_states.res_country_state_HH',
# HESSEN
'DE7': 'l10n_de_country_states.res_country_state_HE',
# MECKLENBURG-VORPOMMERN
'DE8': 'l10n_de_country_states.res_country_state_MV',
# NIEDERSACHSEN
'DE9': 'l10n_de_country_states.res_country_state_NI',
# NORDRHEIN-WESTFALEN
'DEA': 'l10n_de_country_states.res_country_state_NW',
# RHEINLAND-PFALZ
'DEB': 'l10n_de_country_states.res_country_state_RP',
# SAARLAND
'DEC': 'l10n_de_country_states.res_country_state_SL',
# SACHSEN
'DED': 'l10n_de_country_states.res_country_state_SN',
# SACHSEN-ANHALT
'DEE': 'l10n_de_country_states.res_country_state_ST',
# SCHLESWIG-HOLSTEIN
'DEF': 'l10n_de_country_states.res_country_state_SH',
# THÜRINGEN
'DEG': 'l10n_de_country_states.res_country_state_TH',
# EXTRA-REGIO NUTS 1
'DEZ': False,
}

@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.code == 'DE' and level == 2:
toponyms = self._de_state_map.get(code, False)
if toponyms:
state = self.env.ref(toponyms)
if state:
mapping['state_id'] = state.id
return mapping

0 comments on commit c478966

Please sign in to comment.