Skip to content

Commit 281f159

Browse files
Vincenzo9191FrancescoCosma
authored andcommitted
[MIG] base_location_nuts: Migration to 16.0
1 parent c4721ee commit 281f159

File tree

7 files changed

+24
-13
lines changed

7 files changed

+24
-13
lines changed

base_location_nuts/__manifest__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"name": "NUTS Regions",
88
"category": "Localisation/Europe",
9-
"version": "14.0.1.0.1",
9+
"version": "16.0.1.0.0",
1010
"depends": ["contacts"],
1111
"data": [
1212
"views/res_country_view.xml",

base_location_nuts/models/res_partner_nuts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ResPartnerNuts(models.Model):
2121
not_updatable = fields.Boolean()
2222
# Parent hierarchy
2323
parent_id = fields.Many2one(comodel_name="res.partner.nuts", ondelete="restrict")
24-
parent_path = fields.Char(index=True)
24+
parent_path = fields.Char(index=True, unaccent=False)
2525
child_ids = fields.One2many(
2626
comodel_name="res.partner.nuts", inverse_name="parent_id", string="Children"
2727
)

base_location_nuts/tests/test_base_location_nuts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from odoo.tests import common
66

77

8-
class TestBaseLocationNuts(common.SavepointCase):
8+
class TestBaseLocationNuts(common.TransactionCase):
99
@classmethod
1010
def setUpClass(cls):
1111
super(TestBaseLocationNuts, cls).setUpClass()

base_location_nuts/views/res_partner_nuts_view.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<field name="name">NUTS Items tree</field>
55
<field name="model">res.partner.nuts</field>
66
<field name="arch" type="xml">
7-
<tree string="NUTS Items">
7+
<tree>
88
<field name="level" />
99
<field name="code" />
1010
<field name="name" />

base_location_nuts/wizard/nuts_import.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import re
99
from collections import OrderedDict
1010

11-
import requests
11+
import urllib3
1212
from lxml import etree
1313

1414
from odoo import _, api, fields, models
@@ -121,7 +121,7 @@ def _mapping(self, node):
121121
else:
122122
logger.debug("xpath = '%s', not found" % field_xpath)
123123
if field_required and not value:
124-
raise UserError(_("Value not found for mandatory field %s" % k))
124+
raise UserError(_("Value not found for mandatory field %s") % k)
125125
item[k] = value
126126
return item
127127

@@ -136,20 +136,24 @@ def _download_nuts(self, url_base=None, url_path=None, url_params=None):
136136
url += "&".join([k + "=" + v for k, v in url_params.items()])
137137
logger.info("Starting to download %s" % url)
138138
try:
139-
res_request = requests.get(url)
139+
http = urllib3.PoolManager()
140+
res_request = http.request("GET", url)
140141
except Exception as e:
141142
raise UserError(
142143
_("Got an error when trying to download the file: %s.") % str(e)
143-
)
144-
if res_request.status_code != requests.codes.ok:
144+
) from e
145+
if res_request.status != 200:
145146
raise UserError(
146-
_("Got an error %d when trying to download the file %s.")
147-
% (res_request.status_code, url)
147+
_(
148+
"Got an error %(d)s when trying to download the file %(s)s.",
149+
d=res_request.status,
150+
s=url,
151+
)
148152
)
149-
logger.info("Download successfully %d bytes" % len(res_request.content))
153+
logger.info("Download successfully %d bytes" % len(res_request.data))
150154
# Workaround XML: Remove all characters before <?xml
151155
pattern = re.compile(rb"^.*<\?xml", re.DOTALL)
152-
content_fixed = re.sub(pattern, b"<?xml", res_request.content)
156+
content_fixed = re.sub(pattern, b"<?xml", res_request.data)
153157
if not re.match(rb"<\?xml", content_fixed):
154158
raise UserError(_("Downloaded file is not a valid XML file"))
155159
return content_fixed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../base_location_nuts

setup/base_location_nuts/setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import setuptools
2+
3+
setuptools.setup(
4+
setup_requires=['setuptools-odoo'],
5+
odoo_addon=True,
6+
)

0 commit comments

Comments
 (0)