Browse Source

[MIG] base_location_nuts: Migration to 14.0

14.0
Andrii Skrypka 3 years ago
parent
commit
9a74af1288
  1. 10
      base_location_nuts/README.rst
  2. 2
      base_location_nuts/__manifest__.py
  3. 16
      base_location_nuts/models/res_partner.py
  4. 1
      base_location_nuts/security/ir.model.access.csv
  5. 8
      base_location_nuts/static/description/index.html
  6. 2
      base_location_nuts/tests/test_base_location_nuts.py
  7. 9
      base_location_nuts/wizard/nuts_import.py

10
base_location_nuts/README.rst

@ -14,13 +14,13 @@ NUTS Regions
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpartner--contact-lightgray.png?logo=github
:target: https://github.com/OCA/partner-contact/tree/13.0/base_location_nuts
:target: https://github.com/OCA/partner-contact/tree/14.0/base_location_nuts
:alt: OCA/partner-contact
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-base_location_nuts
:target: https://translation.odoo-community.org/projects/partner-contact-14-0/partner-contact-14-0-base_location_nuts
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/134/13.0
:target: https://runbot.odoo-community.org/runbot/134/14.0
:alt: Try me on Runbot
|badge1| |badge2| |badge3| |badge4| |badge5|
@ -80,7 +80,7 @@ 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 <https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2013.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:%2014.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.
@ -117,6 +117,6 @@ 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.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/13.0/base_location_nuts>`_ project on GitHub.
This module is part of the `OCA/partner-contact <https://github.com/OCA/partner-contact/tree/14.0/base_location_nuts>`_ project on GitHub.
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

2
base_location_nuts/__manifest__.py

@ -6,7 +6,7 @@
{
"name": "NUTS Regions",
"category": "Localisation/Europe",
"version": "13.0.1.0.0",
"version": "14.0.1.0.0",
"depends": ["contacts"],
"data": [
"views/res_country_view.xml",

16
base_location_nuts/models/res_partner.py

@ -9,16 +9,24 @@ class ResPartner(models.Model):
_inherit = "res.partner"
nuts1_id = fields.Many2one(
comodel_name="res.partner.nuts", domain=[("level", "=", 1)], string="NUTS L1"
comodel_name="res.partner.nuts",
domain=[("level", "=", 1)],
string="NUTS L1",
)
nuts2_id = fields.Many2one(
comodel_name="res.partner.nuts", domain=[("level", "=", 2)], string="NUTS L2"
comodel_name="res.partner.nuts",
domain=[("level", "=", 2)],
string="NUTS L2",
)
nuts3_id = fields.Many2one(
comodel_name="res.partner.nuts", domain=[("level", "=", 3)], string="NUTS L3"
comodel_name="res.partner.nuts",
domain=[("level", "=", 3)],
string="NUTS L3",
)
nuts4_id = fields.Many2one(
comodel_name="res.partner.nuts", domain=[("level", "=", 4)], string="NUTS L4"
comodel_name="res.partner.nuts",
domain=[("level", "=", 4)],
string="NUTS L4",
)
def _onchange_nuts(self, level):

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

@ -1,3 +1,4 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"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
"access_nuts_import","nuts.import access","model_nuts_import","base.group_partner_manager",1,1,1,1

8
base_location_nuts/static/description/index.html

@ -3,7 +3,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
<title>NUTS Regions</title>
<style type="text/css">
@ -367,7 +367,7 @@ ul.auto-toc {
!! This file is generated by oca-gen-addon-readme !!
!! 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/13.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-13-0/partner-contact-13-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/13.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/14.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-14-0/partner-contact-14-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/14.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>Creates four new fields in Partner object, one per NUTS level</p>
<ul class="simple">
@ -426,7 +426,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>.
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
<a class="reference external" href="https://github.com/OCA/partner-contact/issues/new?body=module:%20base_location_nuts%0Aversion:%2013.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:%2014.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>
</div>
<div class="section" id="credits">
@ -457,7 +457,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
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/partner-contact/tree/13.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/14.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>
</div>
</div>

2
base_location_nuts/tests/test_base_location_nuts.py

@ -9,7 +9,7 @@ class TestBaseLocationNuts(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestBaseLocationNuts, cls).setUpClass()
cls.importer = cls.env["nuts.import"]
cls.importer = cls.env["nuts.import"].create({})
cls.importer.run_import() # loads nuts
cls.country_1 = cls.env["res.country"].search([("code", "=", "ES")])
cls.country_2 = cls.env["res.country"].search([("code", "=", "PT")])

9
base_location_nuts/wizard/nuts_import.py

@ -1,6 +1,7 @@
# Copyright 2015 Antonio Espinosa <antonio.espinosa@tecnativa.com>
# Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
# Copyright 2017 David Vidal <jairo.llopis@tecnativa.com>
# Copyright 2021 Andrii Skrypka <andrijskrypa@ukr.net>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
import logging
@ -10,7 +11,7 @@ from collections import OrderedDict
import requests
from lxml import etree
from odoo import _, api, models
from odoo import _, api, fields, models
from odoo.exceptions import UserError
logger = logging.getLogger(__name__)
@ -61,7 +62,6 @@ class NutsImport(models.TransientModel):
"SE": False,
"GB": False, # UK
}
_current_country = False
_map = OrderedDict(
[
(
@ -86,6 +86,7 @@ class NutsImport(models.TransientModel):
),
]
)
current_country_id = fields.Many2one("res.country")
def _check_node(self, node):
if node.get("id") and node.get("idLevel"):
@ -169,8 +170,8 @@ class NutsImport(models.TransientModel):
level = data.get("level", 0)
code = data.get("code", "")
if level == 1:
self._current_country = self._countries[code]
return {"country_id": self._current_country.id}
self.current_country_id = self._countries[code]
return {"country_id": self.current_country_id.id}
@api.model
def create_or_update_nuts(self, node):

Loading…
Cancel
Save