Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][IMP] base_vat_optional_vies: wizard to calculate_vies passed in all partners #1722

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion base_vat_optional_vies/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 27 additions & 1 deletion base_vat_optional_vies/i18n/base_vat_optional_vies.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@
#
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"
"Content-Type: text/plain; charset=UTF-8\n"
"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"
Expand All @@ -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 ""
34 changes: 30 additions & 4 deletions base_vat_optional_vies/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>\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 <[email protected]>\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
Expand All @@ -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"
1 change: 1 addition & 0 deletions base_vat_optional_vies/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from . import res_partner
from . import res_config_settings
21 changes: 21 additions & 0 deletions base_vat_optional_vies/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2022-2023 Moduon Team S.L. <[email protected]>
# 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 {

Check warning on line 14 in base_vat_optional_vies/models/res_config_settings.py

View check run for this annotation

Codecov / codecov/patch

base_vat_optional_vies/models/res_config_settings.py#L12-L14

Added lines #L12 - L14 were not covered by tests
"effect": {
"fadeout": "slow",
"message": _("Vies passed calculated in %s partners") % count_partners,
"img_url": "/web/static/img/smile.svg",
"type": "rainbow_man",
}
}
1 change: 1 addition & 0 deletions base_vat_optional_vies/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions base_vat_optional_vies/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
* Alexandre Díaz <[email protected]>
* Harald Panten <[email protected]>
* Eduardo de Miguel <[email protected]>
* Emilio Pascual <[email protected]>
44 changes: 44 additions & 0 deletions base_vat_optional_vies/tests/tes_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2022-2023 Moduon Team S.L. <[email protected]>
# 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)
27 changes: 27 additions & 0 deletions base_vat_optional_vies/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Moduon Team S.L.
License Other proprietary
-->
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.account</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="base_vat.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath
expr="//div[@id='vies_service_setting']/div[hasclass('o_setting_right_pane')]"
position="inside"
>
<button
type="object"
name="execute_update_check_vies"
string="Compute check vies"
class="oe_link"
icon="fa-arrow-right"
confirm="This process can take a long time. Are you sure you want to start the process?"
attrs="{'invisible': [('vat_check_vies', '=', False)]}"
/>
</xpath>
</field>
</record>
</odoo>
Loading