Skip to content

Commit e882ace

Browse files
committed
[MIG] base_location_nuts: Migration to 19.0
1 parent 268f8cc commit e882ace

File tree

8 files changed

+56
-54
lines changed

8 files changed

+56
-54
lines changed

base_location_nuts/README.rst

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ NUTS Regions
2121
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
2222
:alt: License: AGPL-3
2323
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
24-
:target: https://github.com/OCA/partner-contact/tree/18.0/base_location_nuts
24+
:target: https://github.com/OCA/partner-contact/tree/19.0/base_location_nuts
2525
:alt: OCA/partner-contact
2626
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
27-
:target: https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-0-base_location_nuts
27+
:target: https://translation.odoo-community.org/projects/partner-contact-19-0/partner-contact-19-0-base_location_nuts
2828
:alt: Translate me on Weblate
2929
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
30-
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=18.0
30+
:target: https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&target_branch=19.0
3131
:alt: Try me on Runboat
3232

3333
|badge1| |badge2| |badge3| |badge4| |badge5|
@@ -36,10 +36,10 @@ This module allows to import NUTS locations.
3636

3737
Creates four new fields in Partner object, one per NUTS level
3838

39-
- NUTS L1: Country level
40-
- NUTS L2: Normally state or big region level
41-
- NUTS L3: Normally substate or state level
42-
- NUTS L4: Normally small region or province level
39+
- NUTS L1: Country level
40+
- NUTS L2: Normally state or big region level
41+
- NUTS L3: Normally substate or state level
42+
- NUTS L4: Normally small region or province level
4343

4444
This module allows to set the flag *Not updatable* in a NUTS region so
4545
that it gets no more updated nor deleted by the import wizard.
@@ -60,12 +60,12 @@ Installation
6060
We recommend to install another addon (one for each country) in order to
6161
relate NUTS with states defined by each localization addon, for example:
6262

63-
- l10n_es_location_nuts : Spanish Provinces (NUTS level 4) related to
64-
Partner State
65-
- l10n_de_location_nuts : German states (NUTS level 2) related to
66-
Partner State
67-
- l10n_nl_location_nuts : Dutch provinces (NUTS level 3 and 4) related
68-
to Partner State
63+
- l10n_es_location_nuts : Spanish Provinces (NUTS level 4) related to
64+
Partner State
65+
- l10n_de_location_nuts : German states (NUTS level 2) related to
66+
Partner State
67+
- l10n_nl_location_nuts : Dutch provinces (NUTS level 3 and 4) related
68+
to Partner State
6969

7070
Configuration
7171
=============
@@ -96,7 +96,7 @@ Bug Tracker
9696
Bugs are tracked on `GitHub Issues <https://github.com/OCA/partner-contact/issues>`_.
9797
In case of trouble, please check there if your issue has already been reported.
9898
If you spotted it first, help us to smash it by providing a detailed and welcomed
99-
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
99+
`feedback <https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
100100

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

@@ -112,15 +112,15 @@ Authors
112112
Contributors
113113
------------
114114

115-
- Rafael Blasco <rafael.blasco@tecnativa.com>
116-
- Antonio Espinosa <antonio.espinosa@tecnativa.com>
117-
- Jairo Llopis <jairo.llopis@tecnativa.com>
118-
- David Vidal <david.vidal@tecnativa.com>
119-
- Simone Rubino <simone.rubino@agilebg.com>
120-
- Alexandre Díaz <alexandre.diaz@tecnativa.com>
121-
- Andrea Stirpe <a.stirpe@onestein.nl>
122-
- Eduardo López <elp@moduon.team>
123-
- Andrii Kompaniiets <andrii@moduon.team>
115+
- Rafael Blasco <rafael.blasco@tecnativa.com>
116+
- Antonio Espinosa <antonio.espinosa@tecnativa.com>
117+
- Jairo Llopis <jairo.llopis@tecnativa.com>
118+
- David Vidal <david.vidal@tecnativa.com>
119+
- Simone Rubino <simone.rubino@agilebg.com>
120+
- Alexandre Díaz <alexandre.diaz@tecnativa.com>
121+
- Andrea Stirpe <a.stirpe@onestein.nl>
122+
- Eduardo López <elp@moduon.team>
123+
- Andrii Kompaniiets <andrii@moduon.team>
124124

125125
Maintainers
126126
-----------
@@ -149,6 +149,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:
149149

150150
|maintainer-rafaelbn| |maintainer-edlopen| |maintainer-Andrii9090|
151151

152-
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/18.0/base_location_nuts>`_ project on GitHub.
152+
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/19.0/base_location_nuts>`_ project on GitHub.
153153

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

base_location_nuts/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"name": "NUTS Regions",
99
"category": "Localization/Europe",
10-
"version": "18.0.1.2.0",
10+
"version": "19.0.1.0.0",
1111
"depends": ["contacts"],
1212
"data": [
1313
"views/res_country_view.xml",

base_location_nuts/models/res_partner.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
55

66
from odoo import api, fields, models
7-
from odoo.osv.expression import AND, OR
7+
from odoo.fields import Domain
88

99

1010
class ResPartner(models.Model):
@@ -40,35 +40,34 @@ class ResPartner(models.Model):
4040
def _compute_allowed_nuts(self):
4141
Nuts = self.env["res.partner.nuts"]
4242
for partner in self:
43-
domain = []
43+
domain = Domain(Domain.TRUE)
4444
for level in range(1, 4):
45-
nuts = partner["nuts%d_id" % level]
45+
nuts = partner[f"nuts{level}_id"]
4646
if nuts:
4747
if not domain:
48-
domain = OR(
49-
[
50-
[
51-
("parent_id", "=", nuts.id),
52-
("level", "=", level + 1),
53-
],
54-
]
48+
domain = Domain(
49+
[("parent_id", "=", nuts.id), ("level", "=", level + 1)]
5550
)
5651
else:
57-
domain = OR(
52+
domain = Domain.OR(
5853
[
59-
[
60-
("parent_id", "=", nuts.id),
61-
("level", "=", level + 1),
62-
],
54+
Domain(
55+
[
56+
("parent_id", "=", nuts.id),
57+
("level", "=", level + 1),
58+
]
59+
),
6360
domain,
6461
]
6562
)
6663
if partner.country_id:
67-
domain = AND([[("country_id", "=", partner.country_id.id)], domain])
64+
domain = Domain.AND(
65+
[Domain("country_id", "=", partner.country_id.id), domain]
66+
)
6867
partner.allowed_nut_ids = Nuts.search(domain)
6968

7069
def _onchange_nuts(self, level):
71-
field = self["nuts%d_id" % level]
70+
field = self[f"nuts{level}_id"]
7271
country_id = field.country_id
7372
state_id = field.state_id
7473
if country_id and self.country_id != country_id:
@@ -78,7 +77,7 @@ def _onchange_nuts(self, level):
7877
if level > 1:
7978
parent_id = field.parent_id
8079
if parent_id:
81-
nuts_parent_level = "nuts%d_id" % (level - 1)
80+
nuts_parent_level = f"nuts{level - 1}_id"
8281
parent_field = self[nuts_parent_level]
8382
if parent_field != parent_id:
8483
self[nuts_parent_level] = parent_id
@@ -127,7 +126,7 @@ def onchange_state_id_base_location_nuts(self):
127126
limit=1,
128127
)
129128
if nuts_state:
130-
field = "nuts%d_id" % self.country_id.state_level
129+
field = f"nuts{self.country_id.state_level}_id"
131130
self[field] = nuts_state
132131

133132
@api.model

base_location_nuts/static/description/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ <h1>NUTS Regions</h1>
374374
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
375375
!! source digest: sha256:c6e27ffb13e1a827941bf8a8fb29f8b71115cd12f2f6fb02593d91af19803ee8
376376
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
377-
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/partner-contact/tree/18.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 image-reference" href="https://translation.odoo-community.org/projects/partner-contact-18-0/partner-contact-18-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&amp;target_branch=18.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
377+
<p><a class="reference external image-reference" 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 image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/license-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/partner-contact/tree/19.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 image-reference" href="https://translation.odoo-community.org/projects/partner-contact-19-0/partner-contact-19-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 image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/partner-contact&amp;target_branch=19.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
378378
<p>This module allows to import NUTS locations.</p>
379379
<p>Creates four new fields in Partner object, one per NUTS level</p>
380380
<ul class="simple">
@@ -441,7 +441,7 @@ <h2><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h2>
441441
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/partner-contact/issues">GitHub Issues</a>.
442442
In case of trouble, please check there if your issue has already been reported.
443443
If you spotted it first, help us to smash it by providing a detailed and welcomed
444-
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
444+
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
445445
<p>Do not contact contributors directly about support or help with technical issues.</p>
446446
</div>
447447
<div class="section" id="credits">
@@ -478,7 +478,7 @@ <h3><a class="toc-backref" href="#toc-entry-8">Maintainers</a></h3>
478478
promote its widespread use.</p>
479479
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
480480
<p><a class="reference external image-reference" href="https://github.com/rafaelbn"><img alt="rafaelbn" src="https://github.com/rafaelbn.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/edlopen"><img alt="edlopen" src="https://github.com/edlopen.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/Andrii9090"><img alt="Andrii9090" src="https://github.com/Andrii9090.png?size=40px" /></a></p>
481-
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/18.0/base_location_nuts">OCA/partner-contact</a> project on GitHub.</p>
481+
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/19.0/base_location_nuts">OCA/partner-contact</a> project on GitHub.</p>
482482
<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>
483483
</div>
484484
</div>

base_location_nuts/views/res_country_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<field name="model">res.country</field>
66
<field name="inherit_id" ref="base.view_country_form" />
77
<field name="arch" type="xml">
8-
<xpath expr="/form">
8+
<xpath expr="//form/sheet">
99
<group name="nuts" string="NUTS">
1010
<group>
1111
<field name="state_level" />

base_location_nuts/views/res_partner_nuts_view.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
</record>
3535
<record id="res_partner_nuts_action" model="ir.actions.act_window">
3636
<field name="name">NUTS Items</field>
37+
<field name="path">nuts-items</field>
3738
<field name="res_model">res.partner.nuts</field>
3839
<field name="view_mode">list,form</field>
3940
<field name="help">You must click at import wizard to populate NUTS items
@@ -48,7 +49,7 @@
4849
<field name="name" />
4950
<field name="country_id" />
5051
<field name="state_id" />
51-
<group expand="0" string="Group By">
52+
<group>
5253
<filter
5354
name="country"
5455
string="Country"

base_location_nuts/wizard/nuts_import.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
import requests
1010

11-
from odoo import _, api, models
11+
from odoo import api, models
12+
from odoo.fields import Domain
1213

1314
logger = logging.getLogger(__name__)
1415

@@ -159,13 +160,14 @@ def _delete_obsolete_nuts(self, new_nuts_ids):
159160
ntd2 = nuts_to_delete.filtered(lambda nut: nut.level == level) # noqa: B023
160161
ntd2.unlink()
161162
nuts_to_delete -= ntd2
162-
logger.info("%d NUTS entries deleted" % len(nuts_to_delete))
163+
logger.info(f"{len(nuts_to_delete)} NUTS entries deleted")
163164

164165
def _create_partner_nuts(self, nuts_data):
165166
"""Creates or updates NUTS regions from the given GET request."""
166167
nuts_ids = self.env["res.partner.nuts"]
167168
nuts_json = nuts_data.json()
168169
bindings = nuts_json.get("results", {}).get("bindings", [])
170+
# pylint: disable=no-search-all
169171
all_nuts = nuts_ids.search_read([], ["code"])
170172
nuts_map = {nut.get("code"): nut.get("id") for nut in all_nuts}
171173
for binding in bindings:
@@ -225,10 +227,10 @@ def action_partner_nuts(self):
225227
nuts_ids = self.import_update_partner_nuts()
226228
tree_view_id = self.env.ref("base_location_nuts.res_partner_nuts_tree").id
227229
return {
228-
"name": _("Partner NUTS by EU"),
230+
"name": self.env._("Partner NUTS by EU"),
229231
"view_mode": "list",
230232
"res_model": "res.partner.nuts",
231233
"view_id": tree_view_id,
232234
"type": "ir.actions.act_window",
233-
"domain": [("id", "=", nuts_ids.ids)],
235+
"domain": Domain("id", "=", nuts_ids.ids),
234236
}

base_location_nuts/wizard/nuts_import_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
</record>
2929
<record id="nuts_import_action" model="ir.actions.act_window">
3030
<field name="name">Import NUTS 2024 from SHOWVOC</field>
31-
<field name="type">ir.actions.act_window</field>
31+
<field name="path">import-nuts</field>
3232
<field name="res_model">nuts.import</field>
3333
<field name="view_id" ref="nuts_import_form" />
3434
<field name="view_mode">form</field>

0 commit comments

Comments
 (0)