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][MIG] base vat optional vies: Migration to 16.0 #1572

Merged
merged 43 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6ba2b16
[ADD] base_vat_optional_vies
antespi Oct 6, 2015
36106a4
[FIX] Some fixes:
sergio-teruel Dec 13, 2016
324aa9e
[MIG] base_vat_optional_vies: Migration to 10.0
chienandalu Jun 23, 2017
0be0d2d
Translated using Weblate (German)
psc Nov 20, 2018
522476d
[MIG] base_vat_optional_vies: Migration to 11.0
RodrigoBM Jan 10, 2019
252a7bb
[MIG] base_vat_optional_vies: Migration to 12.0
Tardo Jun 4, 2019
db02176
[UPD] Update base_vat_optional_vies.pot
oca-travis Jul 19, 2019
4c40f09
[UPD] README.rst
OCA-git-bot Jul 29, 2019
9450bbd
[FIX] base_vat_optional_vies: Remove contraints on dotted names
Tardo Jul 29, 2019
81c2094
base_vat_optional_vies 12.0.1.0.1
OCA-git-bot Jul 29, 2019
b171071
Added translation using Weblate (Spanish)
Galoperd Nov 10, 2019
242f96b
Translated using Weblate (Spanish)
Galoperd Nov 10, 2019
cfdfa02
Added translation using Weblate (Croatian)
badbole Nov 12, 2019
b7e69d6
Translated using Weblate (Croatian)
badbole Nov 12, 2019
bfdb0b1
Added translation using Weblate (Portuguese)
alvarorib Feb 27, 2020
d855360
Translated using Weblate (Portuguese)
alvarorib Feb 27, 2020
a2c0fc4
[IMP] base_vat_optional_vies: black, isort, prettier
HaraldPanten May 9, 2020
8d7894e
[MIG]base_vat_optional_vies: Migration to 13.0
HaraldPanten May 9, 2020
ed38c6c
[UPD] Update base_vat_optional_vies.pot
oca-travis Jul 17, 2020
c9fc831
[UPD] README.rst
OCA-git-bot Jul 17, 2020
58a2a68
[MIG] base_vat_optional_vies: Migration to 14.0
Jul 3, 2021
4f60a0a
[UPD] Update base_vat_optional_vies.pot
oca-travis Jul 23, 2021
7129349
[UPD] README.rst
OCA-git-bot Jul 23, 2021
48c67c7
Update translation files
oca-transbot Jul 23, 2021
a7f8467
[FIX] base_vat_optional_vies: greenify test
MiquelRForgeFlow Dec 16, 2021
736a338
base_vat_optional_vies 14.0.1.0.1
OCA-git-bot Dec 16, 2021
13d8ad4
[15.0][MIG]base_vat_optional_vies: migration fron 14.0 to 15.0
AlvaroTForgeFlow Jan 3, 2022
0dc3b1e
[15.0][FIX] base_vat_optional_vies: ensure vies check do not block co…
AaronHForgeFlow Jan 5, 2022
871bef5
[UPD] Update base_vat_optional_vies.pot
Jan 19, 2022
82a7359
[UPD] README.rst
OCA-git-bot Jan 19, 2022
201cc04
[FIX] base_vat_optional_vies: remove unneeded vatnumber
yajo Mar 28, 2022
d488e6d
base_vat_optional_vies 15.0.1.0.1
OCA-git-bot Mar 31, 2022
bdc3bf6
[FIX] Simple VAT error message, always clean vies_passed field
Shide Jun 6, 2022
dd4f995
[UPD] Update base_vat_optional_vies.pot
Jun 9, 2022
f1339d4
[UPD] README.rst
OCA-git-bot Jun 9, 2022
15a18cb
base_vat_optional_vies 15.0.1.0.2
OCA-git-bot Jun 9, 2022
adc3f5b
Update translation files
oca-transbot Jun 9, 2022
b5e81d3
[FIX] Set country id with ref, one line exercise test_validate_wrong_…
Shide Jun 10, 2022
d460406
base_vat_optional_vies 15.0.1.0.3
OCA-git-bot Jun 12, 2022
b1a6608
Translated using Weblate (Portuguese)
pedrocs-exo Jul 29, 2022
8042d2b
[IMP] base_vat_optional_vies: pre-commit stuff
RodrigoBM Jan 26, 2023
46303c4
[MIG] base_vat_optional_vies: Migration to 16.0
RodrigoBM Jan 26, 2023
604871b
[REF] base_vat_optional_vies: refactor the code to make it valid for …
RodrigoBM Jan 31, 2023
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
112 changes: 112 additions & 0 deletions base_vat_optional_vies/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
===================================
Optional validation of VAT via VIES
===================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--financial--tools-lightgray.png?logo=github
:target: https://github.com/OCA/account-financial-tools/tree/15.0/base_vat_optional_vies
:alt: OCA/account-financial-tools
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-financial-tools-15-0/account-financial-tools-15-0-base_vat_optional_vies
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/92/15.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends base_vat module features allowing to know if VIES
validation was passed or not.

Then you can use "VIES validation passed" field in order to show VAT ID with
or without country preffix in invoices, for instance.

*NOTE*: Although VIES validation is set in your company, this validation
will not block VAT ID write (main difference to Odoo standard behavior) if this
VAT ID is valid in its country.

**Table of contents**

.. contents::
:local:

Configuration
=============

In order to activate VIES validation, you must set this option in Settings:
Settings > Account > Verify VAT Numbers

Usage
=====

When VIES VAT Check is activated:

* Odoo will try to validate VAT against VIES online service
* If passed, then "VIES validation passed" field will be True
* If not passed, then try to validate using country validation method
* If validated, then "VIES validation passed" field will be False
* If not validated, then a ValidationError will be shown to user

When VIES VAT Check is not activated:

* "VIES validation passed" field will be always False

You must prefix VAT with country code (ISO 3166-1 alpha-2) and if you want to
bypass country validation you can use "EU" code

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-financial-tools/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/account-financial-tools/issues/new?body=module:%20base_vat_optional_vies%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* Tecnativa

Contributors
~~~~~~~~~~~~

* Rafael Blasco <rblasco@moduon.team>
* Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* Rodrigo Bonilla <rodrigo.bonilla@factorlibre.com>
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
* Harald Panten <harald.panten@sygel.es>
* Eduardo de Miguel <edu@moduon.team>

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/account-financial-tools <https://github.com/OCA/account-financial-tools/tree/15.0/base_vat_optional_vies>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions base_vat_optional_vies/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions base_vat_optional_vies/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2016 Tecnativa - Sergio Teruel
# Copyright 2017 Tecnativa - David Vidal
# Copyright 2019 FactorLibre - Rodrigo Bonilla
# Copyright 2022 Moduon - Eduardo de Miguel
# 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.0",
"depends": ["base_vat"],
"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,
}
Empty file.
33 changes: 33 additions & 0 deletions base_vat_optional_vies/i18n/base_vat_optional_vies.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_vat_optional_vies
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \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:ir.model,name:base_vat_optional_vies.model_res_partner
msgid "Contact"
msgstr ""

#. module: base_vat_optional_vies
#: code:addons/base_vat_optional_vies/models/res_partner.py:0
#, python-format
msgid ""
"The VAT number [%(wrong_vat)s] for %(record_label)s does not seem to be valid. \n"
"Note: the expected format is %(expected_format)s"
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 ""
37 changes: 37 additions & 0 deletions base_vat_optional_vies/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_vat_optional_vies
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-11-10 17:34+0000\n"
"Last-Translator: Galoperd <jvcsan@gmail.com>\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"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.8\n"

#. module: base_vat_optional_vies
#: model:ir.model,name:base_vat_optional_vies.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: base_vat_optional_vies
#: code:addons/base_vat_optional_vies/models/res_partner.py:0
#, python-format
msgid ""
"The VAT number [%(wrong_vat)s] for %(record_label)s does not seem to be "
"valid. \n"
"Note: the expected format is %(expected_format)s"
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 "Validación automática VIES"
38 changes: 38 additions & 0 deletions base_vat_optional_vies/i18n/hr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_vat_optional_vies
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2019-11-12 15:34+0000\n"
"Last-Translator: Bole <bole@dajmi5.com>\n"
"Language-Team: none\n"
"Language: hr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
"X-Generator: Weblate 3.8\n"

#. module: base_vat_optional_vies
#: model:ir.model,name:base_vat_optional_vies.model_res_partner
msgid "Contact"
msgstr "Kontakt"

#. module: base_vat_optional_vies
#: code:addons/base_vat_optional_vies/models/res_partner.py:0
#, python-format
msgid ""
"The VAT number [%(wrong_vat)s] for %(record_label)s does not seem to be "
"valid. \n"
"Note: the expected format is %(expected_format)s"
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 "VIES Provjera"
39 changes: 39 additions & 0 deletions base_vat_optional_vies/i18n/pt.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_vat_optional_vies
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2022-07-29 12:06+0000\n"
"Last-Translator: Pedro Castro Silva <pedrocs@exo.pt>\n"
"Language-Team: none\n"
"Language: pt\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 4.3.2\n"

#. module: base_vat_optional_vies
#: model:ir.model,name:base_vat_optional_vies.model_res_partner
msgid "Contact"
msgstr "Contacto"

#. module: base_vat_optional_vies
#: code:addons/base_vat_optional_vies/models/res_partner.py:0
#, python-format
msgid ""
"The VAT number [%(wrong_vat)s] for %(record_label)s does not seem to be "
"valid. \n"
"Note: the expected format is %(expected_format)s"
msgstr ""
"O NIF [%(wrong_vat)s] para %(record_label)s não parece válido. \n"
"Nota: o formato esperado é %(expected_format)s"

#. 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 "Validação do VIES"
1 change: 1 addition & 0 deletions base_vat_optional_vies/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import res_partner
74 changes: 74 additions & 0 deletions base_vat_optional_vies/models/res_partner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2015 Tecnativa - Antonio Espinosa
# Copyright 2017 Tecnativa - David Vidal
# Copyright 2019 FactorLibre - Rodrigo Bonilla
# Copyright 2022 Moduon - Eduardo de Miguel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models

from odoo.addons.base_vat.models.res_partner import _ref_vat


class ResPartner(models.Model):
_inherit = "res.partner"

vies_passed = fields.Boolean(string="VIES validation", readonly=True)

@api.model
def simple_vat_check(self, country_code, vat_number):
res = super().simple_vat_check(country_code, vat_number)
partner = self._context.get("vat_partner")
if res is False and partner:
partner.update({"vies_passed": False})
elif partner:
if self.env.context.get("company_id"):
company = self.env["res.company"].browse(self.env.context["company_id"])
else:
company = self.env.company
if company.vat_check_vies:
self.vies_vat_check(country_code, vat_number)
return res

@api.model
def vies_vat_check(self, country_code, vat_number):
partner = self._context.get("vat_partner")
res = super().vies_vat_check(country_code, vat_number)
if res is False and partner:
partner.update({"vies_passed": False})
elif partner:
partner.update({"vies_passed": True})
return res

@api.constrains("vat", "country_id")
def check_vat(self):
self.update({"vies_passed": False})
for partner in self.sorted(lambda p: bool(p.commercial_partner_id)):
partner = partner.with_context(vat_partner=partner)
if (
partner.commercial_partner_id
and partner.commercial_partner_id != partner
):
partner.update(
{"vies_passed": partner.commercial_partner_id.vies_passed}
)
else:
super(ResPartner, partner).check_vat()
return True

@api.onchange("vat", "country_id")
def _onchange_check_vies(self):
self.update({"vies_passed": False})
return super(
ResPartner, self.with_context(vat_partner=self)
)._onchange_check_vies()

@api.model
def _build_vat_error_message(self, country_code, wrong_vat, record_label):
return "\n" + _(
"The VAT number [%(wrong_vat)s] for %(record_label)s does not seem to be valid. "
"\nNote: the expected format is %(expected_format)s",
wrong_vat=wrong_vat,
record_label=record_label,
expected_format=_ref_vat.get(
country_code, "'CC##' (CC=Country Code, ##=VAT Number)"
),
)
2 changes: 2 additions & 0 deletions base_vat_optional_vies/readme/CONFIGURE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In order to activate VIES validation, you must set this option in Settings:
Settings > Account > Verify VAT Numbers
8 changes: 8 additions & 0 deletions base_vat_optional_vies/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* Rafael Blasco <rblasco@moduon.team>
* Antonio Espinosa <antonio.espinosa@tecnativa.com>
* Sergio Teruel <sergio.teruel@tecnativa.com>
* David Vidal <david.vidal@tecnativa.com>
* Rodrigo Bonilla <rodrigo.bonilla@factorlibre.com>
* Alexandre Díaz <alexandre.diaz@tecnativa.com>
* Harald Panten <harald.panten@sygel.es>
* Eduardo de Miguel <edu@moduon.team>
9 changes: 9 additions & 0 deletions base_vat_optional_vies/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This module extends base_vat module features allowing to know if VIES
validation was passed or not.

Then you can use "VIES validation passed" field in order to show VAT ID with
or without country preffix in invoices, for instance.

*NOTE*: Although VIES validation is set in your company, this validation
will not block VAT ID write (main difference to Odoo standard behavior) if this
VAT ID is valid in its country.
14 changes: 14 additions & 0 deletions base_vat_optional_vies/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
When VIES VAT Check is activated:

* Odoo will try to validate VAT against VIES online service
* If passed, then "VIES validation passed" field will be True
* If not passed, then try to validate using country validation method
* If validated, then "VIES validation passed" field will be False
* If not validated, then a ValidationError will be shown to user

When VIES VAT Check is not activated:

* "VIES validation passed" field will be always False

You must prefix VAT with country code (ISO 3166-1 alpha-2) and if you want to
bypass country validation you can use "EU" code
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading