From acb33d19d43e9e5e2dc36754afae3fa0c96b675b Mon Sep 17 00:00:00 2001 From: Stephan Keller Date: Sun, 17 May 2020 07:00:29 +0200 Subject: [PATCH] [IMP] partner_industry_secondary: black, isort, prettier --- partner_industry_secondary/__manifest__.py | 7 +- .../migrations/12.0.1.0.0/post-migration.py | 2 +- .../models/res_config_settings.py | 12 +- .../models/res_partner.py | 21 +-- .../models/res_partner_industry.py | 20 +-- .../security/partner_industry_security.xml | 4 +- .../tests/test_res_partner_industry.py | 30 ++-- .../views/res_config_settings.xml | 60 ++++---- .../views/res_partner_industry_view.xml | 13 +- .../views/res_partner_view.xml | 132 ++++++++++++------ 10 files changed, 176 insertions(+), 125 deletions(-) diff --git a/partner_industry_secondary/__manifest__.py b/partner_industry_secondary/__manifest__.py index 133f7cf56..d550bff39 100644 --- a/partner_industry_secondary/__manifest__.py +++ b/partner_industry_secondary/__manifest__.py @@ -12,15 +12,12 @@ "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", "views/res_partner_industry_view.xml", "views/res_partner_view.xml", "views/res_config_settings.xml", - ] + ], } diff --git a/partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py b/partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py index 54ad449fa..3edebb53f 100644 --- a/partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py +++ b/partner_industry_secondary/migrations/12.0.1.0.0/post-migration.py @@ -6,4 +6,4 @@ from openupgradelib import openupgrade @openupgrade.migrate(use_env=True) def migrate(env, version): - env['res.partner.industry']._parent_store_compute() + env["res.partner.industry"]._parent_store_compute() diff --git a/partner_industry_secondary/models/res_config_settings.py b/partner_industry_secondary/models/res_config_settings.py index 40694b961..ab5d5a6c0 100644 --- a/partner_industry_secondary/models/res_config_settings.py +++ b/partner_industry_secondary/models/res_config_settings.py @@ -5,11 +5,11 @@ from odoo import fields, models class ResConfigSettings(models.TransientModel): - _inherit = 'res.config.settings' + _inherit = "res.config.settings" group_use_partner_industry_for_person = fields.Boolean( - 'Use industry for individuals', - help="Set if you want to be able to use industries for " - "individuals also.", - implied_group='partner_industry_secondary.' - 'group_use_partner_industry_for_person') + "Use industry for individuals", + help="Set if you want to be able to use industries for " "individuals also.", + implied_group="partner_industry_secondary." + "group_use_partner_industry_for_person", + ) diff --git a/partner_industry_secondary/models/res_partner.py b/partner_industry_secondary/models/res_partner.py index 9bf96a0a2..1996c93ae 100644 --- a/partner_industry_secondary/models/res_partner.py +++ b/partner_industry_secondary/models/res_partner.py @@ -3,22 +3,27 @@ # Copyright 2018 Eficent Business and IT Consulting Services, S.L. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, exceptions, fields, models, _ +from odoo import _, api, exceptions, fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" - industry_id = fields.Many2one(string='Main Industry') + industry_id = fields.Many2one(string="Main Industry") secondary_industry_ids = fields.Many2many( - comodel_name='res.partner.industry', string="Secondary Industries", - domain="[('id', '!=', industry_id)]") + comodel_name="res.partner.industry", + string="Secondary Industries", + domain="[('id', '!=', industry_id)]", + ) - @api.constrains('industry_id', 'secondary_industry_ids') + @api.constrains("industry_id", "secondary_industry_ids") def _check_industries(self): for partner in self: if partner.industry_id in partner.secondary_industry_ids: raise exceptions.ValidationError( - _('The main industry must be different ' - 'from the secondary industries.')) + _( + "The main industry must be different " + "from the secondary industries." + ) + ) diff --git a/partner_industry_secondary/models/res_partner_industry.py b/partner_industry_secondary/models/res_partner_industry.py index 5e63aa964..f7c2255af 100644 --- a/partner_industry_secondary/models/res_partner_industry.py +++ b/partner_industry_secondary/models/res_partner_industry.py @@ -5,21 +5,22 @@ # Copyright 2019 Tecnativa - Cristina Martin R. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo import api, exceptions, fields, models, _ +from odoo import _, api, exceptions, fields, models class ResPartnerIndustry(models.Model): - _inherit = 'res.partner.industry' + _inherit = "res.partner.industry" _order = "parent_path" _parent_order = "name" _parent_store = True name = fields.Char(required=True) - parent_id = fields.Many2one(comodel_name='res.partner.industry', - ondelete='restrict') - child_ids = fields.One2many(comodel_name='res.partner.industry', - inverse_name='parent_id', - string="Children") + parent_id = fields.Many2one( + comodel_name="res.partner.industry", ondelete="restrict" + ) + child_ids = fields.One2many( + comodel_name="res.partner.industry", inverse_name="parent_id", string="Children" + ) parent_path = fields.Char(index=True) @api.multi @@ -34,8 +35,9 @@ class ResPartnerIndustry(models.Model): return [(cat.id, " / ".join(get_names(cat))) for cat in self] - @api.constrains('parent_id') + @api.constrains("parent_id") def _check_parent_id(self): if not self._check_recursion(): raise exceptions.ValidationError( - _('Error! You cannot create recursive industries.')) + _("Error! You cannot create recursive industries.") + ) diff --git a/partner_industry_secondary/security/partner_industry_security.xml b/partner_industry_secondary/security/partner_industry_security.xml index 2797ea1e3..818a336da 100644 --- a/partner_industry_secondary/security/partner_industry_security.xml +++ b/partner_industry_secondary/security/partner_industry_security.xml @@ -1,7 +1,7 @@ - + Use industry for individuals - + diff --git a/partner_industry_secondary/tests/test_res_partner_industry.py b/partner_industry_secondary/tests/test_res_partner_industry.py index d4e078760..b07bdc255 100644 --- a/partner_industry_secondary/tests/test_res_partner_industry.py +++ b/partner_industry_secondary/tests/test_res_partner_industry.py @@ -3,30 +3,29 @@ # Copyright 2016 Tecnativa S.L. - Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests import common from odoo.exceptions import ValidationError +from odoo.tests import common class TestResPartnerIndustry(common.SavepointCase): @classmethod 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_child = cls.industry_model.create({ - 'name': 'Test child', - 'parent_id': cls.industry_main.id, - }) + cls.industry_model = cls.env["res.partner.industry"] + 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,} + ) def test_check_industries(self): with self.assertRaises(ValidationError): - self.env['res.partner'].create({ - 'name': 'Test', - 'industry_id': self.industry_main.id, - 'secondary_industry_ids': [(4, self.industry_main.id)], - }) + self.env["res.partner"].create( + { + "name": "Test", + "industry_id": self.industry_main.id, + "secondary_industry_ids": [(4, self.industry_main.id)], + } + ) def test_check_recursion(self): with self.assertRaises(ValidationError): @@ -34,6 +33,5 @@ class TestResPartnerIndustry(common.SavepointCase): def test_name(self): self.assertEqual( - self.industry_child.name_get()[0][1], - "Test / Test child", + self.industry_child.name_get()[0][1], "Test / Test child", ) diff --git a/partner_industry_secondary/views/res_config_settings.xml b/partner_industry_secondary/views/res_config_settings.xml index 7dd67890b..101e3d29b 100644 --- a/partner_industry_secondary/views/res_config_settings.xml +++ b/partner_industry_secondary/views/res_config_settings.xml @@ -1,35 +1,45 @@ - + - - - res.config.settings.view.form - res.config.settings - - - -

Partner Industries

-
-
-
- -
-
-