From f04264ae81d35f43d7cd8232a6bf3658033c3cc8 Mon Sep 17 00:00:00 2001 From: Stephan Keller Date: Sun, 17 May 2020 12:58:34 +0200 Subject: [PATCH] [MIG] partner_industry_secondary: Migration to 13.0 --- partner_industry_secondary/README.rst | 15 +++------ partner_industry_secondary/__init__.py | 2 +- partner_industry_secondary/__manifest__.py | 6 ++-- .../post-migration.py | 2 +- partner_industry_secondary/models/__init__.py | 2 +- .../models/res_config_settings.py | 2 +- .../models/res_partner.py | 2 +- .../models/res_partner_industry.py | 21 ++++++++++-- partner_industry_secondary/readme/ROADMAP.rst | 1 - .../static/description/index.html | 33 ++++++++----------- partner_industry_secondary/tests/__init__.py | 2 +- .../tests/test_res_partner_industry.py | 22 ++++++++----- .../views/res_config_settings.xml | 28 +++++++++------- .../views/res_partner_industry_view.xml | 5 ++- 14 files changed, 80 insertions(+), 63 deletions(-) rename partner_industry_secondary/migrations/{12.0.1.0.0 => 13.0.1.0.0}/post-migration.py (74%) delete mode 100644 partner_industry_secondary/readme/ROADMAP.rst diff --git a/partner_industry_secondary/README.rst b/partner_industry_secondary/README.rst index f15fd7855..b82eb698f 100644 --- a/partner_industry_secondary/README.rst +++ b/partner_industry_secondary/README.rst @@ -14,13 +14,13 @@ Partner Industry Secondary :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/12.0/partner_industry_secondary + :target: https://github.com/OCA/partner-contact/tree/13.0/partner_industry_secondary :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-12-0/partner-contact-12-0-partner_industry_secondary + :target: https://translation.odoo-community.org/projects/partner-contact-13-0/partner-contact-13-0-partner_industry_secondary :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/12.0 + :target: https://runbot.odoo-community.org/runbot/134/13.0 :alt: Try me on Runbot |badge1| |badge2| |badge3| |badge4| |badge5| @@ -51,18 +51,13 @@ To use this module, you need to: * Go to any partner's form. -Known issues / Roadmap -====================== - -* Add a unique constraint for name per parent industry. - Bug Tracker =========== Bugs are tracked on `GitHub 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 `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -100,6 +95,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 `_ project on GitHub. +This module is part of the `OCA/partner-contact `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/partner_industry_secondary/__init__.py b/partner_industry_secondary/__init__.py index 83e553ac4..4b76c7b2d 100644 --- a/partner_industry_secondary/__init__.py +++ b/partner_industry_secondary/__init__.py @@ -1,3 +1,3 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import models diff --git a/partner_industry_secondary/__manifest__.py b/partner_industry_secondary/__manifest__.py index d550bff39..55d8d2889 100644 --- a/partner_industry_secondary/__manifest__.py +++ b/partner_industry_secondary/__manifest__.py @@ -1,18 +1,18 @@ # Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta # Copyright 2016-2017 Tecnativa S.L. - Vicent Cubells # Copyright 2019 Tecnativa S.L. - Cristina Martin R. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Partner Industry Secondary", "summary": "Add secondary partner industries", - "version": "12.0.1.0.1", + "version": "13.0.1.0.0", "category": "Sales", "website": "https://github.com/OCA/partner-contact", "author": "Tecnativa, Odoo Community Association (OCA)", "license": "AGPL-3", "installable": True, - "depends": ["base_setup", "contacts",], + "depends": ["base_setup", "contacts"], "data": [ "security/ir.model.access.csv", "security/partner_industry_security.xml", diff --git a/partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py b/partner_industry_secondary/migrations/13.0.1.0.0/post-migration.py similarity index 74% rename from partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py rename to partner_industry_secondary/migrations/13.0.1.0.0/post-migration.py index 3edebb53f..c8a8ceca4 100644 --- a/partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py +++ b/partner_industry_secondary/migrations/13.0.1.0.0/post-migration.py @@ -1,5 +1,5 @@ # Copyright 2019 Tecnativa - Cristina Martin R. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from openupgradelib import openupgrade diff --git a/partner_industry_secondary/models/__init__.py b/partner_industry_secondary/models/__init__.py index 5bceca821..4043a2e33 100644 --- a/partner_industry_secondary/models/__init__.py +++ b/partner_industry_secondary/models/__init__.py @@ -1,4 +1,4 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import res_partner from . import res_partner_industry diff --git a/partner_industry_secondary/models/res_config_settings.py b/partner_industry_secondary/models/res_config_settings.py index ab5d5a6c0..2e0de5f79 100644 --- a/partner_industry_secondary/models/res_config_settings.py +++ b/partner_industry_secondary/models/res_config_settings.py @@ -1,5 +1,5 @@ # Copyright 2018 Eficent Business and IT Consulting Services, S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import fields, models diff --git a/partner_industry_secondary/models/res_partner.py b/partner_industry_secondary/models/res_partner.py index 1996c93ae..ed83a1237 100644 --- a/partner_industry_secondary/models/res_partner.py +++ b/partner_industry_secondary/models/res_partner.py @@ -1,7 +1,7 @@ # Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta # Copyright 2016 Tecnativa S.L. - Vicent Cubells # Copyright 2018 Eficent Business and IT Consulting Services, S.L. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import _, api, exceptions, fields, models diff --git a/partner_industry_secondary/models/res_partner_industry.py b/partner_industry_secondary/models/res_partner_industry.py index f7c2255af..3fb903fbf 100644 --- a/partner_industry_secondary/models/res_partner_industry.py +++ b/partner_industry_secondary/models/res_partner_industry.py @@ -3,7 +3,7 @@ # Copyright 2016 Tecnativa S.L. - Pedro M. Baeza # Copyright 2018 Eficent Business and IT Consulting Services, S.L. # Copyright 2019 Tecnativa - Cristina Martin R. -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import _, api, exceptions, fields, models @@ -23,7 +23,6 @@ class ResPartnerIndustry(models.Model): ) parent_path = fields.Char(index=True) - @api.multi def name_get(self): def get_names(cat): """ Return the list [cat.name, cat.parent_id.name, ...] """ @@ -41,3 +40,21 @@ class ResPartnerIndustry(models.Model): raise exceptions.ValidationError( _("Error! You cannot create recursive industries.") ) + + @api.constrains("name", "parent_id") + def _check_uniq_name(self): + if ( + self.search_count( + [("name", "=", self.name), ("parent_id", "=", self.parent_id.id)] + ) + > 1 + ): + raise exceptions.ValidationError( + _("Error! Industry with same name and parent already exists.") + ) + + def copy(self, default=None): + default = default or {} + if "name" not in default or default["name"] == self.name: + default["name"] = self.name + " 2" + return super(ResPartnerIndustry, self).copy(default=default) diff --git a/partner_industry_secondary/readme/ROADMAP.rst b/partner_industry_secondary/readme/ROADMAP.rst deleted file mode 100644 index 34197c39e..000000000 --- a/partner_industry_secondary/readme/ROADMAP.rst +++ /dev/null @@ -1 +0,0 @@ -* Add a unique constraint for name per parent industry. diff --git a/partner_industry_secondary/static/description/index.html b/partner_industry_secondary/static/description/index.html index 70b70219f..8b544f183 100644 --- a/partner_industry_secondary/static/description/index.html +++ b/partner_industry_secondary/static/description/index.html @@ -367,19 +367,18 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runbot

+

Beta License: AGPL-3 OCA/partner-contact Translate me on Weblate Try me on Runbot

This module adds secondary industries for partners.

Table of contents

-
-

Known issues / Roadmap

-
    -
  • Add a unique constraint for name per parent industry.
  • -
-
-

Bug Tracker

+

Bug Tracker

Bugs are tracked on GitHub 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.

+feedback.

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

-

Credits

+

Credits

-

Authors

+

Authors

  • Tecnativa
-

Contributors

+

Contributors

-

Maintainers

+

Maintainers

This module is maintained by the OCA.

Odoo Community Association

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 project on GitHub.

+

This module is part of the OCA/partner-contact project on GitHub.

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

diff --git a/partner_industry_secondary/tests/__init__.py b/partner_industry_secondary/tests/__init__.py index c6dbb5a41..61b63ba78 100644 --- a/partner_industry_secondary/tests/__init__.py +++ b/partner_industry_secondary/tests/__init__.py @@ -1,3 +1,3 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from . import test_res_partner_industry diff --git a/partner_industry_secondary/tests/test_res_partner_industry.py b/partner_industry_secondary/tests/test_res_partner_industry.py index b07bdc255..c0ad98967 100644 --- a/partner_industry_secondary/tests/test_res_partner_industry.py +++ b/partner_industry_secondary/tests/test_res_partner_industry.py @@ -1,9 +1,9 @@ # Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta # Copyright 2016 Tecnativa S.L. - Vicent Cubells # Copyright 2016 Tecnativa S.L. - Pedro M. Baeza -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). -from odoo.exceptions import ValidationError +from odoo.exceptions import UserError, ValidationError from odoo.tests import common @@ -12,9 +12,9 @@ class TestResPartnerIndustry(common.SavepointCase): def setUpClass(cls): super(TestResPartnerIndustry, cls).setUpClass() cls.industry_model = cls.env["res.partner.industry"] - cls.industry_main = cls.industry_model.create({"name": "Test",}) + cls.industry_main = cls.industry_model.create({"name": "Test"}) cls.industry_child = cls.industry_model.create( - {"name": "Test child", "parent_id": cls.industry_main.id,} + {"name": "Test child", "parent_id": cls.industry_main.id} ) def test_check_industries(self): @@ -27,11 +27,17 @@ class TestResPartnerIndustry(common.SavepointCase): } ) - def test_check_recursion(self): + def test_check_copy(self): + industry_copy = self.industry_child.copy() + self.assertEqual(industry_copy.name, "Test child 2") + + def test_check_uniq_name(self): with self.assertRaises(ValidationError): + self.industry_model.create({"name": "Test"}) + + def test_check_recursion(self): + with self.assertRaises(UserError): self.industry_main.parent_id = self.industry_child.id def test_name(self): - self.assertEqual( - self.industry_child.name_get()[0][1], "Test / Test child", - ) + self.assertEqual(self.industry_child.display_name, "Test / Test child") diff --git a/partner_industry_secondary/views/res_config_settings.xml b/partner_industry_secondary/views/res_config_settings.xml index 101e3d29b..c4a8e901f 100644 --- a/partner_industry_secondary/views/res_config_settings.xml +++ b/partner_industry_secondary/views/res_config_settings.xml @@ -1,27 +1,31 @@ + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). --> - res.config.settings.view.form + res.config.settings.view.form.inherit.partner_partner_industry_secondary res.config.settings - + - -

Partner Industries

-
-
+
+
+
-
+
- +
diff --git a/partner_industry_secondary/views/res_partner_industry_view.xml b/partner_industry_secondary/views/res_partner_industry_view.xml index ffcc81bef..9268c4cc5 100644 --- a/partner_industry_secondary/views/res_partner_industry_view.xml +++ b/partner_industry_secondary/views/res_partner_industry_view.xml @@ -1,7 +1,7 @@ + License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). --> Industry @@ -18,6 +18,9 @@ res.partner.industry + + +