Browse Source

[MIG] base_location_nuts: Migration to v12.0

pull/739/head
Alexandre Díaz 5 years ago
parent
commit
a781217e09
  1. 11
      base_location_nuts/README.rst
  2. 2
      base_location_nuts/__manifest__.py
  3. 6
      base_location_nuts/migrations/12.0.1.0.0/post-migration.py
  4. 2
      base_location_nuts/models/res_partner.py
  5. 5
      base_location_nuts/models/res_partner_nuts.py
  6. 1
      base_location_nuts/readme/CONTRIBUTORS.rst
  7. 3
      base_location_nuts/security/ir.model.access.csv
  8. 7
      base_location_nuts/static/description/index.html
  9. 4
      base_location_nuts/tests/test_base_location_nuts.py
  10. 8
      base_location_nuts/views/res_partner_nuts_view.xml
  11. 13
      base_location_nuts/views/res_partner_view.xml

11
base_location_nuts/README.rst

@ -14,13 +14,13 @@ NUTS Regions
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3 :alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/11.0/base_location_nuts
:target: https://github.com/OCA/partner-contact/tree/12.0/base_location_nuts
:alt: OCA/partner-contact :alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-11-0/partner-contact-11-0-base_location_nuts
:target: https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-base_location_nuts
:alt: Translate me on Weblate :alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png .. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/134/11.0
:target: https://runbot.odoo-community.org/runbot/134/12.0
:alt: Try me on Runbot :alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5| |badge1| |badge2| |badge3| |badge4| |badge5|
@ -79,7 +79,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_. 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. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
Do not contact contributors directly about support or help with technical issues. Do not contact contributors directly about support or help with technical issues.
@ -100,6 +100,7 @@ Contributors
* Jairo Llopis <jairo.llopis@tecnativa.com> * Jairo Llopis <jairo.llopis@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com> * David Vidal <david.vidal@tecnativa.com>
* Simone Rubino <simone.rubino@agilebg.com> * Simone Rubino <simone.rubino@agilebg.com>
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
Maintainers Maintainers
~~~~~~~~~~~ ~~~~~~~~~~~
@ -114,6 +115,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/11.0/base_location_nuts>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/12.0/base_location_nuts>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
base_location_nuts/__manifest__.py

@ -7,7 +7,7 @@
{ {
'name': 'NUTS Regions', 'name': 'NUTS Regions',
'category': 'Localisation/Europe', 'category': 'Localisation/Europe',
'version': '11.0.1.1.0',
'version': '12.0.1.0.0',
'depends': [ 'depends': [
'contacts', 'contacts',
], ],

6
base_location_nuts/migrations/12.0.1.0.0/post-migration.py

@ -0,0 +1,6 @@
from openupgradelib import openupgrade
@openupgrade.migrate()
def migrate(env, version):
env['res.partner.nuts']._parent_store_compute()

2
base_location_nuts/models/res_partner.py

@ -67,7 +67,7 @@ class ResPartner(models.Model):
return self._onchange_nuts(1) return self._onchange_nuts(1)
@api.onchange('country_id') @api.onchange('country_id')
def _onchange_country_id(self):
def _onchange_country_id_base_location_nuts(self):
"""Sensible values and domains for related fields.""" """Sensible values and domains for related fields."""
fields = ['state_id', 'nuts1_id', 'nuts2_id', 'nuts3_id', 'nuts4_id'] fields = ['state_id', 'nuts1_id', 'nuts2_id', 'nuts3_id', 'nuts4_id']
country_domain = ([('country_id', '=', self.country_id.id)] country_domain = ([('country_id', '=', self.country_id.id)]

5
base_location_nuts/models/res_partner_nuts.py

@ -7,7 +7,7 @@ from odoo import fields, models
class ResPartnerNuts(models.Model): class ResPartnerNuts(models.Model):
_name = 'res.partner.nuts' _name = 'res.partner.nuts'
_order = 'parent_left'
_order = 'parent_path'
_parent_order = 'name' _parent_order = 'name'
_parent_store = True _parent_store = True
_description = 'NUTS Item' _description = 'NUTS Item'
@ -24,8 +24,7 @@ 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')
parent_path = fields.Char(index=True)
child_ids = fields.One2many(comodel_name='res.partner.nuts', child_ids = fields.One2many(comodel_name='res.partner.nuts',
inverse_name='parent_id', string='Children', inverse_name='parent_id', string='Children',
oldname='children') oldname='children')
parent_left = fields.Integer('Parent Left', index=True)
parent_right = fields.Integer('Parent Right', index=True)

1
base_location_nuts/readme/CONTRIBUTORS.rst

@ -3,3 +3,4 @@
* Jairo Llopis <jairo.llopis@tecnativa.com> * Jairo Llopis <jairo.llopis@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com> * David Vidal <david.vidal@tecnativa.com>
* Simone Rubino <simone.rubino@agilebg.com> * Simone Rubino <simone.rubino@agilebg.com>
* Alexandre Díaz <alexandre.diaz@tecnativa.com>

3
base_location_nuts/security/ir.model.access.csv

@ -1,2 +1,3 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" "id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_res_partner_nuts_user","res_partner_nuts group_user","model_res_partner_nuts","base.group_user",1,0,0,0
"access_res_partner_nuts_user_all","res_partner_nuts group_partner_manager_all","model_res_partner_nuts","",1,0,0,0
"access_res_partner_nuts_user","res_partner_nuts group_partner_manager","model_res_partner_nuts","base.group_partner_manager",1,1,1,1

7
base_location_nuts/static/description/index.html

@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !! !! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !! !! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/partner-contact/tree/11.0/base_location_nuts"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-11-0/partner-contact-11-0-base_location_nuts"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/134/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/partner-contact/tree/12.0/base_location_nuts"><img alt="OCA/partner-contact" src="https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/partner-contact-12-0/partner-contact-12-0-base_location_nuts"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/134/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
<p>This module allows to import NUTS locations.</p> <p>This module allows to import NUTS locations.</p>
<p>Creates four new fields in Partner object, one per NUTS level</p> <p>Creates four new fields in Partner object, one per NUTS level</p>
<ul class="simple"> <ul class="simple">
@ -425,7 +425,7 @@ in order to allow to assign them to partner object.</p>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>. <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported. 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 If you spotted it first, help us smashing it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p> <p>Do not contact contributors directly about support or help with technical issues.</p>
</div> </div>
<div class="section" id="credits"> <div class="section" id="credits">
@ -445,6 +445,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Jairo Llopis &lt;<a class="reference external" href="mailto:jairo.llopis&#64;tecnativa.com">jairo.llopis&#64;tecnativa.com</a>&gt;</li> <li>Jairo Llopis &lt;<a class="reference external" href="mailto:jairo.llopis&#64;tecnativa.com">jairo.llopis&#64;tecnativa.com</a>&gt;</li>
<li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li> <li>David Vidal &lt;<a class="reference external" href="mailto:david.vidal&#64;tecnativa.com">david.vidal&#64;tecnativa.com</a>&gt;</li>
<li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;agilebg.com">simone.rubino&#64;agilebg.com</a>&gt;</li> <li>Simone Rubino &lt;<a class="reference external" href="mailto:simone.rubino&#64;agilebg.com">simone.rubino&#64;agilebg.com</a>&gt;</li>
<li>Alexandre Díaz &lt;<a class="reference external" href="mailto:alexandre.diaz&#64;tecnativa.com">alexandre.diaz&#64;tecnativa.com</a>&gt;</li>
</ul> </ul>
</div> </div>
<div class="section" id="maintainers"> <div class="section" id="maintainers">
@ -454,7 +455,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose <p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use.</p> promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/11.0/base_location_nuts">OCA/partner-contact</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/12.0/base_location_nuts">OCA/partner-contact</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div> </div>
</div> </div>

4
base_location_nuts/tests/test_base_location_nuts.py

@ -44,7 +44,7 @@ class TestBaseLocationNuts(common.SavepointCase):
def test_onchange_nuts(self): def test_onchange_nuts(self):
self.partner.country_id = self.country_2 self.partner.country_id = self.country_2
self.partner._onchange_country_id()
self.partner._onchange_country_id_base_location_nuts()
self.assertEqual(self.partner.nuts1_id.country_id, self.assertEqual(self.partner.nuts1_id.country_id,
self.partner.country_id) self.partner.country_id)
self.partner.nuts4_id = self.nuts4_1 self.partner.nuts4_id = self.nuts4_1
@ -57,7 +57,7 @@ class TestBaseLocationNuts(common.SavepointCase):
self.partner._onchange_nuts2_id() self.partner._onchange_nuts2_id()
self.assertEqual(self.partner.nuts1_id.country_id, self.country_1) self.assertEqual(self.partner.nuts1_id.country_id, self.country_1)
self.partner.country_id = self.country_2 self.partner.country_id = self.country_2
self.partner._onchange_country_id()
self.partner._onchange_country_id_base_location_nuts()
self.assertEqual(self.partner.country_id, self.nuts1_2.country_id) self.assertEqual(self.partner.country_id, self.nuts1_2.country_id)
self.assertFalse(self.partner.nuts2_id) self.assertFalse(self.partner.nuts2_id)
self.assertFalse(self.partner.nuts3_id) self.assertFalse(self.partner.nuts3_id)

8
base_location_nuts/views/res_partner_nuts_view.xml

@ -37,7 +37,6 @@
<record id="res_partner_nuts_action" model="ir.actions.act_window"> <record id="res_partner_nuts_action" model="ir.actions.act_window">
<field name="name">NUTS Items</field> <field name="name">NUTS Items</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">res.partner.nuts</field> <field name="res_model">res.partner.nuts</field>
<field name="view_type">form</field> <field name="view_type">form</field>
<field name="view_mode">tree,form</field> <field name="view_mode">tree,form</field>
@ -55,10 +54,12 @@
<field name="country_id"/> <field name="country_id"/>
<field name="state_id"/> <field name="state_id"/>
<group expand="0" string="Group By"> <group expand="0" string="Group By">
<filter string="Country"
<filter name="country"
string="Country"
domain="[]" domain="[]"
context="{'group_by': 'country_id'}"/> context="{'group_by': 'country_id'}"/>
<filter string="Level"
<filter name="level"
string="Level"
domain="[]" domain="[]"
context="{'group_by': 'level'}"/> context="{'group_by': 'level'}"/>
</group> </group>
@ -68,6 +69,7 @@
<menuitem action="res_partner_nuts_action" <menuitem action="res_partner_nuts_action"
id="res_partner_nuts_menu" id="res_partner_nuts_menu"
groups="base.group_partner_manager"
name="NUTS Items" name="NUTS Items"
parent="contacts.menu_localisation" parent="contacts.menu_localisation"
sequence="40"/> sequence="40"/>

13
base_location_nuts/views/res_partner_view.xml

@ -33,20 +33,25 @@
<field name="nuts4_id"/> <field name="nuts4_id"/>
</field> </field>
<filter name="salesperson" position="after"> <filter name="salesperson" position="after">
<filter string="NUTS L1"
<filter name="nuts_l1"
string="NUTS L1"
domain="[]" domain="[]"
context="{'group_by': 'nuts1_id'}"/> context="{'group_by': 'nuts1_id'}"/>
<filter string="NUTS L2"
<filter name="nuts_l2"
string="NUTS L2"
domain="[]" domain="[]"
context="{'group_by': 'nuts2_id'}"/> context="{'group_by': 'nuts2_id'}"/>
<filter string="NUTS L3"
<filter name="nuts_l3"
string="NUTS L3"
domain="[]" domain="[]"
context="{'group_by': 'nuts3_id'}"/> context="{'group_by': 'nuts3_id'}"/>
<filter string="NUTS L4"
<filter name="nuts_l4"
string="NUTS L4"
domain="[]" domain="[]"
context="{'group_by': 'nuts4_id'}"/> context="{'group_by': 'nuts4_id'}"/>
</filter> </filter>
</field> </field>
</record> </record>
</odoo> </odoo>
Loading…
Cancel
Save