Skip to content

Commit

Permalink
[IMP] base_location_nuts: required changes
Browse files Browse the repository at this point in the history
  • Loading branch information
agaldona committed Nov 16, 2017
1 parent 77d6cfe commit fc2740d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base_location_nuts/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
],
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'website': 'https://www.tecnativa.com',
'website': 'https://github.com/OCA/partner-contact/',
'license': 'AGPL-3',
'installable': True,
}
8 changes: 4 additions & 4 deletions base_location_nuts/wizard/nuts_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@ def _download_nuts(self, url_base=None, url_path=None, url_params=None):
logger.info('Download successfully %d bytes' %
len(res_request.content))
# Workaround XML: Remove all characters before <?xml
pattern = re.compile(r'^.*<\?xml'.encode('utf-8'), re.DOTALL)
pattern = re.compile(rb'^.*<\?xml', re.DOTALL)
content_fixed = re.sub(pattern, b'<?xml',
res_request.content)
if not re.match(r'<\?xml'.encode('utf-8'), content_fixed):
if not re.match(rb'<\?xml', content_fixed):
raise UserError(_('Downloaded file is not a valid XML file'))
return content_fixed

@api.model
def _load_countries(self):
for k in list(self._countries.keys()):
for k in self._countries.keys():
self._countries[k] = self.env['res.country'].search(
[('code', '=', k)])
# Workaround to translate some country codes:
Expand Down Expand Up @@ -191,7 +191,7 @@ def run_import(self):
# delete if not found above
nuts_to_delete = nuts_model.search(
[('country_id', 'in',
[x.id for x in list(self._countries.values())])])
[x.id for x in self._countries.values()])])
# Download NUTS in english, create or update
logger.info('Importing NUTS 2013 English...')
xmlcontent = self._download_nuts()
Expand Down

0 comments on commit fc2740d

Please sign in to comment.