diff --git a/base_vat_optional_vies/__manifest__.py b/base_vat_optional_vies/__manifest__.py index ce19365f..5084bce7 100644 --- a/base_vat_optional_vies/__manifest__.py +++ b/base_vat_optional_vies/__manifest__.py @@ -3,13 +3,17 @@ # Copyright 2017 Tecnativa - David Vidal # Copyright 2019 FactorLibre - Rodrigo Bonilla # Copyright 2022 Moduon - Eduardo de Miguel +# Copyright 2023 Moduon - Emilio Pascual # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). { "name": "Optional validation of VAT via VIES", "category": "Accounting", "version": "16.0.1.0.1", "depends": ["base_vat"], - "data": ["views/res_partner_view.xml"], + "data": [ + "views/res_partner_view.xml", + "views/res_config_settings_view.xml", + ], "author": "Tecnativa," "Odoo Community Association (OCA)", "website": "https://github.com/OCA/account-financial-tools", "license": "AGPL-3", diff --git a/base_vat_optional_vies/i18n/base_vat_optional_vies.pot b/base_vat_optional_vies/i18n/base_vat_optional_vies.pot index 144e0b74..6988e89b 100644 --- a/base_vat_optional_vies/i18n/base_vat_optional_vies.pot +++ b/base_vat_optional_vies/i18n/base_vat_optional_vies.pot @@ -4,8 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 16.0\n" +"Project-Id-Version: Odoo Server 16.0+e\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-09-18 07:12+0000\n" +"PO-Revision-Date: 2023-09-18 07:12+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -13,6 +15,16 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: base_vat_optional_vies +#: model_terms:ir.ui.view,arch_db:base_vat_optional_vies.res_config_settings_view_form +msgid "Compute check vies" +msgstr "" + +#. module: base_vat_optional_vies +#: model:ir.model,name:base_vat_optional_vies.model_res_config_settings +msgid "Config Settings" +msgstr "" + #. module: base_vat_optional_vies #: model:ir.model,name:base_vat_optional_vies.model_res_partner msgid "Contact" @@ -27,8 +39,22 @@ msgid "" "Note: the expected format is %(expected_format)s" msgstr "" +#. module: base_vat_optional_vies +#: model_terms:ir.ui.view,arch_db:base_vat_optional_vies.res_config_settings_view_form +msgid "" +"This process can take a long time. Are you sure you want to start the " +"process?" +msgstr "" + #. module: base_vat_optional_vies #: model:ir.model.fields,field_description:base_vat_optional_vies.field_res_partner__vies_passed #: model:ir.model.fields,field_description:base_vat_optional_vies.field_res_users__vies_passed msgid "VIES validation" msgstr "" + +#. module: base_vat_optional_vies +#. odoo-python +#: code:addons/base_vat_optional_vies/models/res_config_settings.py:0 +#, python-format +msgid "Vies passed calculated in %s partners" +msgstr "" diff --git a/base_vat_optional_vies/i18n/es.po b/base_vat_optional_vies/i18n/es.po index c1874910..c1c74a68 100644 --- a/base_vat_optional_vies/i18n/es.po +++ b/base_vat_optional_vies/i18n/es.po @@ -6,15 +6,26 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2023-04-17 10:18+0000\n" -"Last-Translator: gelo joga Rodríguez \n" +"POT-Creation-Date: 2023-09-18 07:12+0000\n" +"PO-Revision-Date: 2023-09-18 09:17+0200\n" +"Last-Translator: Emilio Pascual \n" "Language-Team: none\n" "Language: es\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: \n" +"Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Generator: Weblate 4.14.1\n" +"X-Generator: Poedit 3.3.1\n" + +#. module: base_vat_optional_vies +#: model_terms:ir.ui.view,arch_db:base_vat_optional_vies.res_config_settings_view_form +msgid "Compute check vies" +msgstr "Calcular comprobación VIES" + +#. module: base_vat_optional_vies +#: model:ir.model,name:base_vat_optional_vies.model_res_config_settings +msgid "Config Settings" +msgstr "Opciones de configuración" #. module: base_vat_optional_vies #: model:ir.model,name:base_vat_optional_vies.model_res_partner @@ -33,8 +44,23 @@ msgstr "" "El NIF [%(wrong_vat)s] para %(record_label)s parece no ser válido. \n" "Nota: El formato esperado es %(expected_format)s" +#. module: base_vat_optional_vies +#: model_terms:ir.ui.view,arch_db:base_vat_optional_vies.res_config_settings_view_form +msgid "" +"This process can take a long time. Are you sure you want to start the " +"process?" +msgstr "" +"Este proceso puede tardar. ¿Está seguro que quiere iniciar el proceso?" + #. module: base_vat_optional_vies #: model:ir.model.fields,field_description:base_vat_optional_vies.field_res_partner__vies_passed #: model:ir.model.fields,field_description:base_vat_optional_vies.field_res_users__vies_passed msgid "VIES validation" msgstr "Validación automática VIES" + +#. module: base_vat_optional_vies +#. odoo-python +#: code:addons/base_vat_optional_vies/models/res_config_settings.py:0 +#, python-format +msgid "Vies passed calculated in %s partners" +msgstr "Validación automática VIES calculada para %s contactos" diff --git a/base_vat_optional_vies/models/__init__.py b/base_vat_optional_vies/models/__init__.py index 91fed54d..0d7a048a 100644 --- a/base_vat_optional_vies/models/__init__.py +++ b/base_vat_optional_vies/models/__init__.py @@ -1 +1,2 @@ from . import res_partner +from . import res_config_settings diff --git a/base_vat_optional_vies/models/res_config_settings.py b/base_vat_optional_vies/models/res_config_settings.py new file mode 100644 index 00000000..757d0bdf --- /dev/null +++ b/base_vat_optional_vies/models/res_config_settings.py @@ -0,0 +1,21 @@ +# Copyright 2022-2023 Moduon Team S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import _, models + + +class ResConfigSettings(models.TransientModel): + _inherit = "res.config.settings" + + def execute_update_check_vies(self): + # Only parent partners, children are synced from parent + count_partners = self.env["res.partner"].search_count([]) + self.env["res.partner"].search([]).check_vat() + return { + "effect": { + "fadeout": "slow", + "message": _("Vies passed calculated in %s partners") % count_partners, + "img_url": "/web/static/img/smile.svg", + "type": "rainbow_man", + } + } diff --git a/base_vat_optional_vies/models/res_partner.py b/base_vat_optional_vies/models/res_partner.py index a629c199..b76b6c5f 100644 --- a/base_vat_optional_vies/models/res_partner.py +++ b/base_vat_optional_vies/models/res_partner.py @@ -2,6 +2,7 @@ # Copyright 2017 Tecnativa - David Vidal # Copyright 2019 FactorLibre - Rodrigo Bonilla # Copyright 2022 Moduon - Eduardo de Miguel +# Copyright 2023 Moduon - Emilio Pascual # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). from odoo import _, api, fields, models diff --git a/base_vat_optional_vies/readme/CONTRIBUTORS.rst b/base_vat_optional_vies/readme/CONTRIBUTORS.rst index d86e534d..c24f5cdc 100644 --- a/base_vat_optional_vies/readme/CONTRIBUTORS.rst +++ b/base_vat_optional_vies/readme/CONTRIBUTORS.rst @@ -6,3 +6,4 @@ * Alexandre Díaz * Harald Panten * Eduardo de Miguel +* Emilio Pascual diff --git a/base_vat_optional_vies/tests/tes_config_settings.py b/base_vat_optional_vies/tests/tes_config_settings.py new file mode 100644 index 00000000..93cd3687 --- /dev/null +++ b/base_vat_optional_vies/tests/tes_config_settings.py @@ -0,0 +1,44 @@ +# Copyright 2022-2023 Moduon Team S.L. +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from unittest import mock + +from odoo.tests import common + + +class TestConfigSettings(common.TransactionCase): + def setUp(self): + super(TestConfigSettings, self).setUp() + self.company = self.env.user.company_id + self.partner1_test = self.env["res.partner"].create( + { + "name": "Test partner", + "is_company": True, + "vat": "ESB87530432", + "country_id": self.env.ref("base.be").id, + } + ) + self.partner2_test = self.env["res.partner"].create( + { + "name": "Test partner2", + "is_company": True, + "vat": "ESB87530432", + } + ) + self.vatnumber_path = "odoo.addons.base_vat.models.res_partner.check_vies" + + def test_execute_update_check_vies_validate(self): + with mock.patch(self.vatnumber_path) as mock_vatnumber: + self.company.vat_check_vies = True + mock_vatnumber.check_vies.return_value = True + self.env["res.config.settings"].execute_update_check_vies() + self.assertTrue(self.partner1_test.vies_passed) + self.assertFalse(self.partner2_test.vies_passed) + + def test_execute_update_check_vies_no_validate(self): + with mock.patch(self.vatnumber_path) as mock_vatnumber: + self.company.vat_check_vies = False + mock_vatnumber.check_vies.return_value = False + self.env["res.config.settings"].execute_update_check_vies() + self.assertFalse(self.partner1_test.vies_passed) + self.assertFalse(self.partner2_test.vies_passed) diff --git a/base_vat_optional_vies/views/res_config_settings_view.xml b/base_vat_optional_vies/views/res_config_settings_view.xml new file mode 100644 index 00000000..bba75d86 --- /dev/null +++ b/base_vat_optional_vies/views/res_config_settings_view.xml @@ -0,0 +1,27 @@ + + + + + res.config.settings.view.form.inherit.account + res.config.settings + + + +