Browse Source
Add Local Adminitrative Units support (#270)
Add Local Adminitrative Units support (#270)
[ADD] base_location_lau: Add Local Adminitrative Units supportpull/276/head
Daniel Reis
9 years ago
committed by
Pedro M. Baeza
9 changed files with 242 additions and 0 deletions
-
91base_location_lau/README.rst
-
2base_location_lau/__init__.py
-
19base_location_lau/__openerp__.py
-
6base_location_lau/models/__init__.py
-
25base_location_lau/models/res_partner.py
-
24base_location_lau/models/res_partner_lau.py
-
2base_location_lau/security/ir.model.access.csv
-
BINbase_location_lau/static/description/icon.png
-
73base_location_lau/views/res_partner_lau_view.xml
@ -0,0 +1,91 @@ |
|||
.. 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 |
|||
|
|||
========================== |
|||
Local Administrative Units |
|||
========================== |
|||
|
|||
Add support to local administrative areas, such as municipalities. |
|||
Two new fields are added to the Partners model: LAU1 and LAU2. |
|||
|
|||
It is compatible with the Eurostat NUTS\LAU structure. |
|||
* The upper LAU level (LAU level 1, formerly NUTS level 4) is defined for most, |
|||
but not all of the countries. |
|||
* The lower LAU level (LAU level 2, formerly NUTS level 5) consists of |
|||
municipalities or equivalent units in the 28 EU Member States. |
|||
|
|||
Se also: http://ec.europa.eu/eurostat/web/nuts/local-administrative-units |
|||
|
|||
|
|||
Installation |
|||
============ |
|||
|
|||
No data is provided by this module. |
|||
Country specific data should be provided by localization modules. |
|||
|
|||
|
|||
Configuration |
|||
============= |
|||
|
|||
The Local Administrative Units table setup can be done under |
|||
Sales > Configuration > Address Book |
|||
|
|||
|
|||
Usage |
|||
===== |
|||
|
|||
|
|||
Only Administrator can manage LAUs, but any registered user can read them, |
|||
in order to allow to assign them to Partners. |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/134/8.0 |
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/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 |
|||
`here <https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_lau%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|||
|
|||
|
|||
Roadmap / Known Issues |
|||
====================== |
|||
|
|||
* The LAU fields are not added to the Partner form. |
|||
* LAU fields could also be added to Employees, to allow meeting |
|||
local reporting requirements. |
|||
|
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
|
|||
* Daniel Reis <dreis.pt(at)hotmail.com> |
|||
|
|||
Based on the base_location_nuts module contributed by: |
|||
|
|||
* Rafael Blasco <rafabn@antiun.com> |
|||
* Antonio Espinosa <antonioea@antiun.com> |
|||
* Jairo Llopis <yajo.sk8@gmail.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 http://odoo-community.org. |
@ -0,0 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
from . import models |
@ -0,0 +1,19 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Daniel Reis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
{ |
|||
'name': 'Local Administrative Units', |
|||
'category': 'Localisation/Europe', |
|||
'version': '8.0.1.0.0', |
|||
'depends': [ |
|||
'base', |
|||
], |
|||
'data': [ |
|||
'views/res_partner_lau_view.xml', |
|||
'security/ir.model.access.csv', |
|||
], |
|||
'author': 'Daniel Reis, ' |
|||
'Odoo Community Association (OCA)', |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
} |
@ -0,0 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Daniel Reis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import res_partner_lau |
|||
from . import res_partner |
@ -0,0 +1,25 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Daniel Reis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import models, fields, api |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
_inherit = 'res.partner' |
|||
|
|||
lau1_id = fields.Many2one( |
|||
'res.partner.lau', |
|||
'Local Admin. Unit 1', |
|||
domain=[('level', '=', 1)]) |
|||
lau2_id = fields.Many2one( |
|||
'res.partner.lau', |
|||
'Local Admin. Unit 2', |
|||
domain=[('level', '=', 2)]) |
|||
|
|||
@api.multi |
|||
@api.onchange('lau1_id') |
|||
def _onchange_lau1(self): |
|||
for p in self: |
|||
if p.lau2_id and p.lau2_id.parent_id != p.lau1_id: |
|||
p.lau2_id = None |
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Daniel Reis |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import models, fields |
|||
|
|||
|
|||
class ResPartnerLAU(models.Model): |
|||
_name = 'res.partner.lau' |
|||
_order = "code" |
|||
_parent_order = "name" |
|||
_parent_store = True |
|||
_description = "LAU Item" |
|||
|
|||
level = fields.Integer(required=True, index=True) |
|||
code = fields.Char(required=True) |
|||
name = fields.Char(required=True, translate=True) |
|||
country_id = fields.Many2one('res.country', 'Country', required=True) |
|||
state_id = fields.Many2one('res.country.state', 'State') |
|||
# Parent hierarchy |
|||
parent_id = fields.Many2one('res.partner.lau', ondelete='restrict') |
|||
child_ids = fields.One2many('res.partner.lau', 'parent_id', 'Children') |
|||
parent_left = fields.Integer('Parent Left', index=True) |
|||
parent_right = fields.Integer('Parent Right', index=True) |
@ -0,0 +1,2 @@ |
|||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
|||
"access_res_partner_lau_user","res_partner_lau group_user","model_res_partner_lau","base.group_user",1,0,0,0 |
After Width: 128 | Height: 128 | Size: 11 KiB |
@ -0,0 +1,73 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="res_partner_lau_tree" model="ir.ui.view"> |
|||
<field name="name">LAU Items tree</field> |
|||
<field name="model">res.partner.lau</field> |
|||
<field name="arch" type="xml"> |
|||
<tree string="LAU Items"> |
|||
<field name="level"/> |
|||
<field name="code"/> |
|||
<field name="name"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="res_partner_lau_form" model="ir.ui.view"> |
|||
<field name="name">LAU Items form</field> |
|||
<field name="model">res.partner.lau</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="LAU Item"> |
|||
<group> |
|||
<group> |
|||
<field name="level"/> |
|||
<field name="code"/> |
|||
<field name="parent_id"/> |
|||
<field name="name"/> |
|||
</group> |
|||
<group> |
|||
<field name="country_id"/> |
|||
<field name="state_id"/> |
|||
</group> |
|||
</group> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
|
|||
<record id="res_partner_lau_action" model="ir.actions.act_window"> |
|||
<field name="name">LAU Items</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="res_model">res.partner.lau</field> |
|||
<field name="view_type">form</field> |
|||
<field name="view_mode">tree,form</field> |
|||
</record> |
|||
|
|||
<record model="ir.ui.view" id="view_res_partner_lau_filter"> |
|||
<field name="name">LAU search filters</field> |
|||
<field name="model">res.partner.lau</field> |
|||
<field name="arch" type="xml"> |
|||
<search string="Search LAU"> |
|||
<field name="name"/> |
|||
<field name="country_id"/> |
|||
<field name="state_id"/> |
|||
<group expand="0" string="Group By"> |
|||
<filter string="Country" |
|||
domain="[]" |
|||
context="{'group_by': 'country_id'}"/> |
|||
<filter string="Level" |
|||
domain="[]" |
|||
context="{'group_by': 'level'}"/> |
|||
</group> |
|||
</search> |
|||
</field> |
|||
</record> |
|||
|
|||
<menuitem action="res_partner_lau_action" |
|||
id="res_partner_lau_menu" |
|||
name="LAU Items" |
|||
parent="base.menu_localisation" |
|||
sequence="45"/> |
|||
|
|||
</data> |
|||
</openerp> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue