From 0b8f3fd80471eb15a3243227e817cbbbb661c2e4 Mon Sep 17 00:00:00 2001 From: Manuel Calero Date: Wed, 19 Feb 2020 16:59:37 +0100 Subject: [PATCH] [IMP] partner_vat_unique: black, isort --- partner_vat_unique/__manifest__.py | 3 +-- partner_vat_unique/models/res_partner.py | 27 ++++++++++++--------- partner_vat_unique/tests/test_vat_unique.py | 18 ++++++-------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/partner_vat_unique/__manifest__.py b/partner_vat_unique/__manifest__.py index 48c99bd13..ee7f818a5 100644 --- a/partner_vat_unique/__manifest__.py +++ b/partner_vat_unique/__manifest__.py @@ -2,8 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Partner VAT Unique", - "summary": - "Module to make the VAT number unique for customers and suppliers.", + "summary": "Module to make the VAT number unique for customers and suppliers.", "version": "12.0.1.0.1", "category": "Customer Relationship Management", "website": "https://github.com/OCA/partner-contact", diff --git a/partner_vat_unique/models/res_partner.py b/partner_vat_unique/models/res_partner.py index 428b7bdb7..2b62ad9b7 100644 --- a/partner_vat_unique/models/res_partner.py +++ b/partner_vat_unique/models/res_partner.py @@ -7,25 +7,28 @@ from odoo.tools import config class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" vat = fields.Char(copy=False) - @api.constrains('vat') + @api.constrains("vat") def _check_vat_unique(self): for record in self: if record.parent_id or not record.vat: continue - test_condition = (config['test_enable'] and - not self.env.context.get('test_vat')) + test_condition = config["test_enable"] and not self.env.context.get( + "test_vat" + ) if test_condition: continue - results = self.env['res.partner'].search_count([ - ('parent_id', '=', False), - ('vat', '=', record.vat), - ('id', '!=', record.id) - ]) + results = self.env["res.partner"].search_count( + [ + ("parent_id", "=", False), + ("vat", "=", record.vat), + ("id", "!=", record.id), + ] + ) if results: - raise ValidationError(_( - "The VAT %s already exists in another " - "partner.") % record.vat) + raise ValidationError( + _("The VAT %s already exists in another " "partner.") % record.vat + ) diff --git a/partner_vat_unique/tests/test_vat_unique.py b/partner_vat_unique/tests/test_vat_unique.py index 8eea96176..c5413c754 100644 --- a/partner_vat_unique/tests/test_vat_unique.py +++ b/partner_vat_unique/tests/test_vat_unique.py @@ -1,26 +1,24 @@ # Copyright 2017 Grant Thornton Spain - Ismael Calvo # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). -from odoo.tests.common import SavepointCase from odoo.exceptions import ValidationError +from odoo.tests.common import SavepointCase class TestVatUnique(SavepointCase): @classmethod def setUpClass(cls): super(TestVatUnique, cls).setUpClass() - cls.partner_model = cls.env['res.partner'] - cls.partner = cls.partner_model.create({ - 'name': 'Test partner', - 'vat': 'ESA12345674' - }) + cls.partner_model = cls.env["res.partner"] + cls.partner = cls.partner_model.create( + {"name": "Test partner", "vat": "ESA12345674"} + ) def test_duplicated_vat_creation(self): with self.assertRaises(ValidationError): - self.partner_model.with_context(test_vat=True).create({ - 'name': 'Second partner', - 'vat': 'ESA12345674' - }) + self.partner_model.with_context(test_vat=True).create( + {"name": "Second partner", "vat": "ESA12345674"} + ) def test_duplicate_partner(self): partner_copied = self.partner.copy()