diff --git a/base_vat_optional_vies/__manifest__.py b/base_vat_optional_vies/__manifest__.py index 9f07ff52..13a04e31 100644 --- a/base_vat_optional_vies/__manifest__.py +++ b/base_vat_optional_vies/__manifest__.py @@ -2,23 +2,16 @@ # Copyright 2016 Tecnativa - Sergio Teruel # Copyright 2017 Tecnativa - David Vidal # Copyright 2019 FactorLibre - Rodrigo Bonilla -# 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': "Optional validation of VAT via VIES", - 'category': 'Accounting', - 'version': '12.0.1.0.1', - 'depends': [ - 'base_vat', - ], - 'external_dependencies': { - 'python': ['vatnumber'], - }, - 'data': [ - 'views/res_partner_view.xml', - ], - 'author': 'Tecnativa,' - 'Odoo Community Association (OCA)', - 'website': 'https://github.com/OCA/account-financial-tools', - 'license': 'AGPL-3', - 'installable': True, + "name": "Optional validation of VAT via VIES", + "category": "Accounting", + "version": "13.0.1.0.1", + "depends": ["base_vat"], + "external_dependencies": {"python": ["vatnumber"]}, + "data": ["views/res_partner_view.xml"], + "author": "Tecnativa," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/account-financial-tools", + "license": "AGPL-3", + "installable": True, } diff --git a/base_vat_optional_vies/models/res_partner.py b/base_vat_optional_vies/models/res_partner.py index 7e1800d1..deb39406 100644 --- a/base_vat_optional_vies/models/res_partner.py +++ b/base_vat_optional_vies/models/res_partner.py @@ -1,40 +1,37 @@ # Copyright 2015 Tecnativa - Antonio Espinosa # Copyright 2017 Tecnativa - David Vidal # Copyright 2019 FactorLibre - Rodrigo Bonilla -# 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, fields, models class ResPartner(models.Model): - _inherit = 'res.partner' + _inherit = "res.partner" - vies_passed = fields.Boolean( - string="VIES validation", readonly=True) + vies_passed = fields.Boolean(string="VIES validation", readonly=True) @api.model def simple_vat_check(self, country_code, vat_number): - res = super(ResPartner, self).simple_vat_check( - country_code, vat_number, - ) - partner = self.env.context.get('vat_partner') + res = super(ResPartner, self).simple_vat_check(country_code, vat_number,) + partner = self.env.context.get("vat_partner") if partner and self.vies_passed: # Can not be sure that this VAT is signed up in VIES - partner.update({'vies_passed': False}) + partner.update({"vies_passed": False}) return res @api.model def vies_vat_check(self, country_code, vat_number): - partner = self.env.context.get('vat_partner') + partner = self.env.context.get("vat_partner") if partner: # If there's an exception checking VIES, the upstream method will # call simple_vat_check and thus the flag will be removed - partner.update({'vies_passed': True}) + partner.update({"vies_passed": True}) res = super(ResPartner, self).vies_vat_check(country_code, vat_number) if not res: return self.simple_vat_check(country_code, vat_number) return res - @api.constrains('vat') + @api.constrains("vat") def check_vat(self): for partner in self: partner = partner.with_context(vat_partner=partner) diff --git a/base_vat_optional_vies/tests/test_res_partner.py b/base_vat_optional_vies/tests/test_res_partner.py index 09430faf..65cbb71b 100644 --- a/base_vat_optional_vies/tests/test_res_partner.py +++ b/base_vat_optional_vies/tests/test_res_partner.py @@ -1,8 +1,9 @@ # Copyright 2015 Tecnativa - Antonio Espinosa # Copyright 2016 Tecnativa - Sergio Teruel # Copyright 2017 Tecnativa - David Vidal -# 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). import mock + from odoo.tests import common @@ -11,27 +12,23 @@ class TestResPartner(common.TransactionCase): super(TestResPartner, self).setUp() self.company = self.env.user.company_id self.company.vat_check_vies = True - self.partner = self.env['res.partner'].create({ - 'name': 'Test partner', - }) - self.vatnumber_path = ( - 'odoo.addons.base_vat.models.res_partner.vatnumber' - ) + self.partner = self.env["res.partner"].create({"name": "Test partner"}) + self.vatnumber_path = "odoo.addons.base_vat.models.res_partner.vatnumber" def test_validate_vat_vies(self): with mock.patch(self.vatnumber_path) as mock_vatnumber: mock_vatnumber.check_vies.return_value = True - self.partner.vat = 'ESB87530432' + self.partner.vat = "ESB87530432" self.assertEqual(self.partner.vies_passed, True) def test_exception_vat_vies(self): with mock.patch(self.vatnumber_path) as mock_vatnumber: mock_vatnumber.check_vies.side_effect = Exception() - self.partner.vat = 'ESB87530432' + self.partner.vat = "ESB87530432" self.assertEqual(self.partner.vies_passed, False) def test_no_validate_vat(self): with mock.patch(self.vatnumber_path) as mock_vatnumber: mock_vatnumber.check_vies.return_value = False - self.partner.vat = 'ESB87530432' + self.partner.vat = "ESB87530432" self.assertEqual(self.partner.vies_passed, False) diff --git a/base_vat_optional_vies/views/res_partner_view.xml b/base_vat_optional_vies/views/res_partner_view.xml index e267ec79..8edae786 100644 --- a/base_vat_optional_vies/views/res_partner_view.xml +++ b/base_vat_optional_vies/views/res_partner_view.xml @@ -1,12 +1,12 @@ - + Add VIES passed fields res.partner - + - +