Browse Source

Update base_location_nuts to 8.0.2.0.0.

This makes NUTS labels and levels to be stored in the res.country object.
Now creating l10n submodules is a piece of cake!

Relational fields now follow guidelines on naming. Old name attribute used
for backwards compatibility wherever needed.

Also some methods have been renamed, and refactored to be smarter. Most cases
l10n modules will just need to fill the res.contry table, and regions and
substates domains will work out of the box. In case you still need to
overwrite any method, splitting in smaller methods makes it easier too.

Oh! And no need for recursive dictionary updates.
pull/233/head
Jairo Llopis 9 years ago
parent
commit
b2982896af
  1. 9
      base_location_nuts/README.rst
  2. 3
      base_location_nuts/__openerp__.py
  3. 214
      base_location_nuts/i18n/base_location_nuts.pot
  4. 111
      base_location_nuts/i18n/es.po
  5. 13
      base_location_nuts/models/__init__.py
  6. 29
      base_location_nuts/models/res_country.py
  7. 96
      base_location_nuts/models/res_partner.py
  8. 7
      base_location_nuts/models/res_partner_nuts.py
  9. 33
      base_location_nuts/views/res_country_view.xml
  10. 16
      base_location_nuts/views/res_partner_view.xml

9
base_location_nuts/README.rst

@ -44,6 +44,13 @@ l10n_de_location_nuts, ...) will inherit this wizard and
relate each NUTS item with states. So if you install a new localization addon relate each NUTS item with states. So if you install a new localization addon
you must re-build NUTS clicking this wizard again. you must re-build NUTS clicking this wizard again.
To configure lables and levels per country, you should install a l10n module,
but if you want to do it manually, you need to:
* Have *Sales / Responsible permissions*.
* Go to *Sales > Configuration > Address Book > Localization > Countries*.
* Choose one.
* Use the fields under the *NUTS* section.
Usage Usage
===== =====
@ -56,7 +63,6 @@ in order to allow to assign them to partner object.
:alt: Try me on Runbot :alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/134/{branch} :target: https://runbot.odoo-community.org/runbot/134/{branch}
Bug Tracker Bug Tracker
=========== ===========
@ -74,6 +80,7 @@ Contributors
* Rafael Blasco <rafabn@antiun.com> * Rafael Blasco <rafabn@antiun.com>
* Antonio Espinosa <antonioea@antiun.com> * Antonio Espinosa <antonioea@antiun.com>
* Jairo Llopis <yajo.sk8@gmail.com>
Maintainer Maintainer
---------- ----------

3
base_location_nuts/__openerp__.py

@ -24,11 +24,12 @@
{ {
'name': 'NUTS Regions', 'name': 'NUTS Regions',
'category': 'Localisation/Europe', 'category': 'Localisation/Europe',
'version': '8.0.1.0.0',
'version': '8.0.2.0.0',
'depends': [ 'depends': [
'base', 'base',
], ],
'data': [ 'data': [
'views/res_country_view.xml',
'views/res_partner_nuts_view.xml', 'views/res_partner_nuts_view.xml',
'views/res_partner_view.xml', 'views/res_partner_view.xml',
'wizard/nuts_import_view.xml', 'wizard/nuts_import_view.xml',

214
base_location_nuts/i18n/base_location_nuts.pot

@ -1,214 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_location_nuts
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-11 15:26+0000\n"
"PO-Revision-Date: 2015-06-11 15:26+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: base_location_nuts
#: view:nuts.import:base_location_nuts.nuts_import_form
msgid "Cancel"
msgstr ""
#. module: base_location_nuts
#: field:res.partner.nuts,children:0
msgid "Children"
msgstr ""
#. module: base_location_nuts
#: field:res.partner.nuts,code:0
msgid "Code"
msgstr ""
#. module: base_location_nuts
#: view:res.partner.nuts:base_location_nuts.view_res_partner_nuts_filter
#: field:res.partner.nuts,country_id:0
msgid "Country"
msgstr ""
#. module: base_location_nuts
#: field:nuts.import,create_uid:0
#: field:res.partner.nuts,create_uid:0
msgid "Created by"
msgstr ""
#. module: base_location_nuts
#: field:nuts.import,create_date:0
#: field:res.partner.nuts,create_date:0
msgid "Created on"
msgstr ""
#. module: base_location_nuts
#: code:addons/base_location_nuts/wizard/nuts_import.py:149
#, python-format
msgid "Downloaded file is not a valid XML file"
msgstr ""
#. module: base_location_nuts
#: code:addons/base_location_nuts/wizard/nuts_import.py:141
#, python-format
msgid "Got an error %d when trying to download the file %s."
msgstr ""
#. module: base_location_nuts
#: code:addons/base_location_nuts/wizard/nuts_import.py:137
#, python-format
msgid "Got an error when trying to download the file: %s."
msgstr ""
#. module: base_location_nuts
#: view:res.partner.nuts:base_location_nuts.view_res_partner_nuts_filter
msgid "Group By"
msgstr ""
#. module: base_location_nuts
#: field:nuts.import,id:0
#: field:res.partner.nuts,id:0
msgid "ID"
msgstr ""
#. module: base_location_nuts
#: view:nuts.import:base_location_nuts.nuts_import_form
msgid "Import"
msgstr ""
#. module: base_location_nuts
#: model:ir.ui.menu,name:base_location_nuts.nuts_import_menu
msgid "Import NUTS 2013"
msgstr ""
#. module: base_location_nuts
#: model:ir.actions.act_window,name:base_location_nuts.nuts_import_action
#: view:nuts.import:base_location_nuts.nuts_import_form
msgid "Import NUTS 2013 from RAMON"
msgstr ""
#. module: base_location_nuts
#: model:ir.model,name:base_location_nuts.model_nuts_import
msgid "Import NUTS items from European RAMON service"
msgstr ""
#. module: base_location_nuts
#: field:nuts.import,write_uid:0
#: field:res.partner.nuts,write_uid:0
msgid "Last Updated by"
msgstr ""
#. module: base_location_nuts
#: field:nuts.import,write_date:0
#: field:res.partner.nuts,write_date:0
msgid "Last Updated on"
msgstr ""
#. module: base_location_nuts
#: view:res.partner.nuts:base_location_nuts.view_res_partner_nuts_filter
#: field:res.partner.nuts,level:0
msgid "Level"
msgstr ""
#. module: base_location_nuts
#: model:ir.model,name:base_location_nuts.model_res_partner_nuts
#: view:res.partner.nuts:base_location_nuts.res_partner_nuts_form
msgid "NUTS Item"
msgstr ""
#. module: base_location_nuts
#: model:ir.actions.act_window,name:base_location_nuts.res_partner_nuts_action
#: model:ir.ui.menu,name:base_location_nuts.res_partner_nuts_menu
#: view:res.partner.nuts:base_location_nuts.res_partner_nuts_tree
msgid "NUTS Items"
msgstr ""
#. module: base_location_nuts
#: field:res.partner.nuts,name:0
msgid "Name"
msgstr ""
#. module: base_location_nuts
#: field:res.partner.nuts,parent_left:0
msgid "Parent Left"
msgstr ""
#. module: base_location_nuts
#: field:res.partner.nuts,parent_right:0
msgid "Parent Right"
msgstr ""
#. module: base_location_nuts
#: field:res.partner.nuts,parent_id:0
msgid "Parent id"
msgstr ""
#. module: base_location_nuts
#: model:ir.model,name:base_location_nuts.model_res_partner
msgid "Partner"
msgstr ""
#. module: base_location_nuts
#: code:addons/base_location_nuts/models/res_partner.py:53
#: view:res.partner:base_location_nuts.view_res_partner_filter_nuts
#: field:res.partner,region:0
#, python-format
msgid "Region"
msgstr ""
#. module: base_location_nuts
#: view:res.partner:base_location_nuts.view_res_partner_filter_nuts
msgid "Salesperson"
msgstr ""
#. module: base_location_nuts
#: view:res.partner.nuts:base_location_nuts.view_res_partner_nuts_filter
msgid "Search NUTS"
msgstr ""
#. module: base_location_nuts
#: field:res.partner.nuts,state_id:0
msgid "State"
msgstr ""
#. module: base_location_nuts
#: code:addons/base_location_nuts/models/res_partner.py:54
#: view:res.partner:base_location_nuts.view_res_partner_filter_nuts
#: field:res.partner,substate:0
#, python-format
msgid "Substate"
msgstr ""
#. module: base_location_nuts
#: view:nuts.import:base_location_nuts.nuts_import_form
msgid "This wizard will download the lastest version of\n"
" NUTS 2013 from Europe RAMON metadata service.\n"
" Updating or creating new NUTS entries if not\n"
" found already in the system, and DELETING MISSING\n"
" ENTRIES from new downloaded file."
msgstr ""
#. module: base_location_nuts
#: code:addons/base_location_nuts/wizard/nuts_import.py:116
#, python-format
msgid "Value not found for mandatory field %s"
msgstr ""
#. module: base_location_nuts
#: model:ir.actions.todo,note:base_location_nuts.config_wizard_nuts
msgid "You can import NUTS from RAMON european service."
msgstr ""
#. module: base_location_nuts
#: model:ir.actions.act_window,help:base_location_nuts.res_partner_nuts_action
msgid "You must click at import wizard to populate NUTS items\n"
" in Odoo database in:\n"
" Sales > Configuration > Address Book > Localization > Import NUTS 2013"
msgstr ""

111
base_location_nuts/i18n/es.po

@ -7,15 +7,17 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: partner-contact (8.0)\n" "Project-Id-Version: partner-contact (8.0)\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-10-09 15:48+0000\n"
"PO-Revision-Date: 2015-10-06 13:57+0000\n"
"POT-Creation-Date: 2015-12-30 17:07+0100\n"
"PO-Revision-Date: 2015-12-30 17:11+0100\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n" "Last-Translator: OCA Transbot <transbot@odoo-community.org>\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-partner-contact-8-0/language/es/)\n"
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-partner-contact-8-0/"
"language/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 1.8.5\n"
#. module: base_location_nuts #. module: base_location_nuts
#: view:nuts.import:base_location_nuts.nuts_import_form #: view:nuts.import:base_location_nuts.nuts_import_form
@ -23,7 +25,7 @@ msgid "Cancel"
msgstr "Cancelar" msgstr "Cancelar"
#. module: base_location_nuts #. module: base_location_nuts
#: field:res.partner.nuts,children:0
#: field:res.partner.nuts,child_ids:0
msgid "Children" msgid "Children"
msgstr "Hijos" msgstr "Hijos"
@ -33,6 +35,7 @@ msgid "Code"
msgstr "Código" msgstr "Código"
#. module: base_location_nuts #. module: base_location_nuts
#: model:ir.model,name:base_location_nuts.model_res_country
#: view:res.partner.nuts:base_location_nuts.view_res_partner_nuts_filter #: view:res.partner.nuts:base_location_nuts.view_res_partner_nuts_filter
#: field:res.partner.nuts,country_id:0 #: field:res.partner.nuts,country_id:0
msgid "Country" msgid "Country"
@ -97,6 +100,21 @@ msgstr "Importar NUTS 2013 desde RAMON"
msgid "Import NUTS items from European RAMON service" msgid "Import NUTS items from European RAMON service"
msgstr "Importar regiones NUTS desde el servicio europeo RAMON" msgstr "Importar regiones NUTS desde el servicio europeo RAMON"
#. module: base_location_nuts
#: help:res.country,region_label:0
msgid "Label for the region NUTS category."
msgstr "Etiqueta para la categoría región NUTS."
#. module: base_location_nuts
#: help:res.country,state_label:0
msgid "Label for the state NUTS category."
msgstr "Etiqueta para la categoría estado NUTS."
#. module: base_location_nuts
#: help:res.country,substate_label:0
msgid "Label for the substate NUTS category."
msgstr "Etiqueta para la categoría subestado NUTS."
#. module: base_location_nuts #. module: base_location_nuts
#: field:nuts.import,write_uid:0 field:res.partner.nuts,write_uid:0 #: field:nuts.import,write_uid:0 field:res.partner.nuts,write_uid:0
msgid "Last Updated by" msgid "Last Updated by"
@ -113,18 +131,38 @@ msgstr "Última actualización en"
msgid "Level" msgid "Level"
msgstr "Nivel" msgstr "Nivel"
#. module: base_location_nuts
#: help:res.country,region_level:0
msgid "Level for the region NUTS category."
msgstr "Nivel para la categoría región NUTS."
#. module: base_location_nuts
#: help:res.country,state_level:0
msgid "Level for the state NUTS category."
msgstr "Nivel para la categoría estado NUTS."
#. module: base_location_nuts
#: help:res.country,substate_level:0
msgid "Level for the substate NUTS category."
msgstr "Nivel para la categoría subestado NUTS."
#. module: base_location_nuts
#: view:res.country:base_location_nuts.view_country_form
msgid "NUTS"
msgstr "NUTS"
#. module: base_location_nuts #. module: base_location_nuts
#: model:ir.model,name:base_location_nuts.model_res_partner_nuts #: model:ir.model,name:base_location_nuts.model_res_partner_nuts
#: view:res.partner.nuts:base_location_nuts.res_partner_nuts_form #: view:res.partner.nuts:base_location_nuts.res_partner_nuts_form
msgid "NUTS Item" msgid "NUTS Item"
msgstr "Región NUTS"
msgstr "Objeto NUTS"
#. module: base_location_nuts #. module: base_location_nuts
#: model:ir.actions.act_window,name:base_location_nuts.res_partner_nuts_action #: model:ir.actions.act_window,name:base_location_nuts.res_partner_nuts_action
#: model:ir.ui.menu,name:base_location_nuts.res_partner_nuts_menu #: model:ir.ui.menu,name:base_location_nuts.res_partner_nuts_menu
#: view:res.partner.nuts:base_location_nuts.res_partner_nuts_tree #: view:res.partner.nuts:base_location_nuts.res_partner_nuts_tree
msgid "NUTS Items" msgid "NUTS Items"
msgstr "Regiones NUTS"
msgstr "Objetos NUTS"
#. module: base_location_nuts #. module: base_location_nuts
#: field:res.partner.nuts,name:0 #: field:res.partner.nuts,name:0
@ -152,13 +190,24 @@ msgid "Partner"
msgstr "Empresa" msgstr "Empresa"
#. module: base_location_nuts #. module: base_location_nuts
#: code:addons/base_location_nuts/models/res_partner.py:34
#: code:addons/base_location_nuts/models/res_partner.py:22
#: code:addons/base_location_nuts/models/res_partner.py:32
#: view:res.partner:base_location_nuts.view_res_partner_filter_nuts #: view:res.partner:base_location_nuts.view_res_partner_filter_nuts
#: field:res.partner,region:0
#: field:res.partner,region_id:0
#, python-format #, python-format
msgid "Region" msgid "Region"
msgstr "Región" msgstr "Región"
#. module: base_location_nuts
#: field:res.country,region_label:0
msgid "Region label"
msgstr "Etiqueta de región"
#. module: base_location_nuts
#: field:res.country,region_level:0
msgid "Region level"
msgstr "Nivel de región"
#. module: base_location_nuts #. module: base_location_nuts
#: view:res.partner:base_location_nuts.view_res_partner_filter_nuts #: view:res.partner:base_location_nuts.view_res_partner_filter_nuts
msgid "Salesperson" msgid "Salesperson"
@ -175,13 +224,34 @@ msgid "State"
msgstr "Provincia" msgstr "Provincia"
#. module: base_location_nuts #. module: base_location_nuts
#: code:addons/base_location_nuts/models/res_partner.py:35
#: field:res.country,state_label:0
msgid "State label"
msgstr "Etiqueta de estado"
#. module: base_location_nuts
#: field:res.country,state_level:0
msgid "State level"
msgstr "Nivel de estado"
#. module: base_location_nuts
#: code:addons/base_location_nuts/models/res_partner.py:25
#: code:addons/base_location_nuts/models/res_partner.py:33
#: view:res.partner:base_location_nuts.view_res_partner_filter_nuts #: view:res.partner:base_location_nuts.view_res_partner_filter_nuts
#: field:res.partner,substate:0
#: field:res.partner,substate_id:0
#, python-format #, python-format
msgid "Substate" msgid "Substate"
msgstr "Estado" msgstr "Estado"
#. module: base_location_nuts
#: field:res.country,substate_label:0
msgid "Substate label"
msgstr "Etiqueta de subestado"
#. module: base_location_nuts
#: field:res.country,substate_level:0
msgid "Substate level"
msgstr "Nivel de subestado"
#. module: base_location_nuts #. module: base_location_nuts
#: view:nuts.import:base_location_nuts.nuts_import_form #: view:nuts.import:base_location_nuts.nuts_import_form
msgid "" msgid ""
@ -190,7 +260,13 @@ msgid ""
" Updating or creating new NUTS entries if not\n" " Updating or creating new NUTS entries if not\n"
" found already in the system, and DELETING MISSING\n" " found already in the system, and DELETING MISSING\n"
" ENTRIES from new downloaded file." " ENTRIES from new downloaded file."
msgstr "Este asistente descargará la última version de\n NUTS 2013 desde el servicio de matadatos europeo RAMON.\n Actualizando o creando nuevas regiones NUTS si no\n las encuentra en el sistemma, y BORRANDO LAS QUE NO ENCUENTRE\n en el nuevo fichero descargado."
msgstr ""
"Este asistente descargará la última version de\n"
" NUTS 2013 desde el servicio de matadatos europeo RAMON.\n"
" Actualizando o creando nuevas regiones NUTS si no\n"
" las encuentra en el sistemma, y BORRANDO LAS QUE NO "
"ENCUENTRE\n"
" en el nuevo fichero descargado."
#. module: base_location_nuts #. module: base_location_nuts
#: code:addons/base_location_nuts/wizard/nuts_import.py:97 #: code:addons/base_location_nuts/wizard/nuts_import.py:97
@ -208,5 +284,10 @@ msgstr "Usted puede importar NUTS desde el servicion europeo RAMON."
msgid "" msgid ""
"You must click at import wizard to populate NUTS items\n" "You must click at import wizard to populate NUTS items\n"
" in Odoo database in:\n" " in Odoo database in:\n"
" Sales > Configuration > Address Book > Localization > Import NUTS 2013"
msgstr "Debes clicar en el asistente de importación para crear las\n las regiones NUTS en la base de datos de Odoo, en el menú:\n Ventas > Configuración > Libreta de direcciones > Localización > Importar NUTS 2013"
" Sales > Configuration > Address Book > Localization > Import NUTS "
"2013"
msgstr ""
"Debes clicar en el asistente de importación para crear las\n"
" las regiones NUTS en la base de datos de Odoo, en el menú:\n"
" Ventas > Configuración > Libreta de direcciones > Localización > "
"Importar NUTS 2013"

13
base_location_nuts/models/__init__.py

@ -1,7 +1,10 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
##############################################################################
# For copyright and license notices, see __openerp__.py file in root directory
##############################################################################
# © 2015 Antiun Ingeniería S.L. - Antonio Espinosa
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from . import res_partner_nuts
from . import res_partner
from . import (
res_country,
res_partner_nuts,
res_partner,
)

29
base_location_nuts/models/res_country.py

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# © 2015 Antiun Ingeniería S.L. - Jairo Llopis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import models, fields
class ResCountry(models.Model):
"""Add labels corresponding to each country.
These stay empty in this base module, and should be filled by l10n ones.
"""
_inherit = "res.country"
state_label = fields.Char(
translate=True,
help="Label for the state NUTS category.")
substate_label = fields.Char(
translate=True,
help="Label for the substate NUTS category.")
region_label = fields.Char(
translate=True,
help="Label for the region NUTS category.")
state_level = fields.Integer(
help="Level for the state NUTS category.")
substate_level = fields.Integer(
help="Level for the substate NUTS category.")
region_level = fields.Integer(
help="Level for the region NUTS category.")

96
base_location_nuts/models/res_partner.py

@ -5,57 +5,67 @@
from openerp import models, fields, api from openerp import models, fields, api
from openerp.tools.translate import _ from openerp.tools.translate import _
import collections
def dict_recursive_update(d, u):
for k, v in u.iteritems():
if isinstance(v, collections.Mapping):
r = dict_recursive_update(d.get(k, {}), v)
d[k] = r
else:
d[k] = u[k]
return d
class ResPartner(models.Model): class ResPartner(models.Model):
_inherit = 'res.partner' _inherit = 'res.partner'
region = fields.Many2one(comodel_name='res.partner.nuts',
string="Region")
substate = fields.Many2one(comodel_name='res.partner.nuts',
string="Substate")
lbl_region = fields.Char(compute='_labels_get')
lbl_substate = fields.Char(compute='_labels_get')
region_id = fields.Many2one(
'res.partner.nuts',
"Region",
oldname="region")
substate_id = fields.Many2one(
'res.partner.nuts',
"Substate",
oldname="substate")
lbl_region = fields.Char(
default=_("Region"),
compute='_labels_get')
lbl_substate = fields.Char(
default=_("Substate"),
compute='_labels_get')
@api.one
@api.multi
@api.depends('country_id') @api.depends('country_id')
def _labels_get(self): def _labels_get(self):
self.lbl_region = _('Region')
self.lbl_substate = _('Substate')
for s in self:
s.lbl_region = s.country_id.region_label or _('Region')
s.lbl_substate = s.country_id.substate_label or _('Substate')
@api.multi @api.multi
def onchange_state(self, state_id):
result = super(ResPartner, self).onchange_state(state_id)
if not state_id:
changes = {
'domain': {
'substate': [],
'region': [],
},
'value': {
'substate': False,
'region': False,
}
@api.onchange("substate_id")
def _onchange_substate_id(self):
for s in self:
if s.substate_id.country_id:
s.country_id = s.substate_id.country_id
@api.multi
@api.onchange("region_id")
def _onchange_region_id(self):
for s in self:
if s.region_id.country_id:
s.country_id = s.region_id.country_id
@api.multi
@api.onchange("country_id")
def _onchange_country_id(self):
"""Sensible values and domains for related fields."""
fields = {"state_id", "region_id", "substate_id"}
country_domain = ([("country_id", "=", self.country_id.id)]
if self.country_id else [])
domain = dict()
for field in fields:
if self.country_id and self[field].country_id != self.country_id:
self[field] = False
domain[field] = list(country_domain) # Using list() to copy
fields.remove("state_id")
for field in fields:
level = self.country_id["%s_level" % field]
if level:
domain[field].append(("level", "=", level))
return {
"domain": domain,
} }
dict_recursive_update(result, changes)
return result
@api.onchange('substate', 'region')
def onchange_substate_or_region(self):
result = {'domain': {}}
if not self.substate:
result['domain']['substate'] = []
if not self.region:
result['domain']['region'] = []
return result

7
base_location_nuts/models/res_partner_nuts.py

@ -24,7 +24,10 @@ class ResPartnerNuts(models.Model):
# Parent hierarchy # Parent hierarchy
parent_id = fields.Many2one(comodel_name='res.partner.nuts', parent_id = fields.Many2one(comodel_name='res.partner.nuts',
ondelete='restrict') ondelete='restrict')
children = fields.One2many(comodel_name='res.partner.nuts',
inverse_name='parent_id')
child_ids = fields.One2many(
'res.partner.nuts',
'parent_id',
"Children",
oldname="children")
parent_left = fields.Integer('Parent Left', select=True) parent_left = fields.Integer('Parent Left', select=True)
parent_right = fields.Integer('Parent Right', select=True) parent_right = fields.Integer('Parent Right', select=True)

33
base_location_nuts/views/res_country_view.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- © 2015 Antiun Ingeniería S.L. - Jairo Llopis
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -->
<openerp>
<data>
<record id="view_country_form" model="ir.ui.view">
<field name="name">NUTS fields</field>
<field name="model">res.country</field>
<field name="inherit_id" ref="base.view_country_form"/>
<field name="arch" type="xml">
<xpath expr="/form">
<group name="nuts" string="NUTS">
<group>
<field name="state_label"/>
<field name="state_level"/>
</group>
<group>
<field name="substate_label"/>
<field name="substate_level"/>
</group>
<group>
<field name="region_label"/>
<field name="region_level"/>
</group>
</group>
</xpath>
</field>
</record>
</data>
</openerp>

16
base_location_nuts/views/res_partner_view.xml

@ -13,7 +13,7 @@
<field name="lbl_substate" class="oe_inline"/> <field name="lbl_substate" class="oe_inline"/>
</div> </div>
<div attrs="{'invisible': [('use_parent_address','=',True)]}"> <div attrs="{'invisible': [('use_parent_address','=',True)]}">
<field name="substate"
<field name="substate_id"
class="oe_no_button" class="oe_no_button"
options="{'no_open': True, 'no_create': True}" options="{'no_open': True, 'no_create': True}"
attrs="{'readonly': [('use_parent_address','=',True)]}"/> attrs="{'readonly': [('use_parent_address','=',True)]}"/>
@ -23,7 +23,7 @@
<field name="lbl_region" class="oe_inline"/> <field name="lbl_region" class="oe_inline"/>
</div> </div>
<div attrs="{'invisible': [('use_parent_address','=',True)]}"> <div attrs="{'invisible': [('use_parent_address','=',True)]}">
<field name="region"
<field name="region_id"
class="oe_no_button" class="oe_no_button"
options="{'no_open': True, 'no_create': True}" options="{'no_open': True, 'no_create': True}"
attrs="{'readonly': [('use_parent_address','=',True)]}"/> attrs="{'readonly': [('use_parent_address','=',True)]}"/>
@ -35,7 +35,7 @@
<field name="lbl_substate" class="oe_inline"/> <field name="lbl_substate" class="oe_inline"/>
</div> </div>
<div attrs="{'invisible': [('use_parent_address','=',True)]}"> <div attrs="{'invisible': [('use_parent_address','=',True)]}">
<field name="substate"
<field name="substate_id"
class="oe_no_button" class="oe_no_button"
options="{'no_open': True, 'no_create': True}" options="{'no_open': True, 'no_create': True}"
attrs="{'readonly': [('use_parent_address','=',True)]}"/> attrs="{'readonly': [('use_parent_address','=',True)]}"/>
@ -45,7 +45,7 @@
<field name="lbl_region" class="oe_inline"/> <field name="lbl_region" class="oe_inline"/>
</div> </div>
<div attrs="{'invisible': [('use_parent_address','=',True)]}"> <div attrs="{'invisible': [('use_parent_address','=',True)]}">
<field name="region"
<field name="region_id"
class="oe_no_button" class="oe_no_button"
options="{'no_open': True, 'no_create': True}" options="{'no_open': True, 'no_create': True}"
attrs="{'readonly': [('use_parent_address','=',True)]}"/> attrs="{'readonly': [('use_parent_address','=',True)]}"/>
@ -60,16 +60,16 @@
<field name="inherit_id" ref="base.view_res_partner_filter"/> <field name="inherit_id" ref="base.view_res_partner_filter"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="category_id" position="after"> <field name="category_id" position="after">
<field name="region"/>
<field name="substate"/>
<field name="region_id"/>
<field name="substate_id"/>
</field> </field>
<filter string="Salesperson" position="after"> <filter string="Salesperson" position="after">
<filter string="Region" <filter string="Region"
domain="[]" domain="[]"
context="{'group_by': 'region'}"/>
context="{'group_by': 'region_id'}"/>
<filter string="Substate" <filter string="Substate"
domain="[]" domain="[]"
context="{'group_by': 'substate'}"/>
context="{'group_by': 'substate_id'}"/>
</filter> </filter>
</field> </field>
</record> </record>

Loading…
Cancel
Save