details: https://code.tryton.org/tryton/commit/a9482f843bf5
branch: default
user: Cédric Krier <[email protected]>
date: Sat Jul 04 11:41:01 2026 +0200
description:
Check the validity of the European tax identifiers when posting invoice
Closes #14931
diffstat:
modules/account_invoice/CHANGELOG | 1 +
modules/account_invoice/exceptions.py | 8 ++++++++
modules/account_invoice/invoice.py | 30 +++++++++++++++++++++++++++++-
modules/account_invoice/message.xml | 3 +++
4 files changed, 41 insertions(+), 1 deletions(-)
diffs (97 lines):
diff -r eed02ddd61b3 -r a9482f843bf5 modules/account_invoice/CHANGELOG
--- a/modules/account_invoice/CHANGELOG Sat Jul 04 11:39:19 2026 +0200
+++ b/modules/account_invoice/CHANGELOG Sat Jul 04 11:41:01 2026 +0200
@@ -1,3 +1,4 @@
+* Check the validity of the European tax identifiers when posting invoice
* Add invoice relate from period and fiscal year
Version 8.0.0 - 2026-04-20
diff -r eed02ddd61b3 -r a9482f843bf5 modules/account_invoice/exceptions.py
--- a/modules/account_invoice/exceptions.py Sat Jul 04 11:39:19 2026 +0200
+++ b/modules/account_invoice/exceptions.py Sat Jul 04 11:41:01 2026 +0200
@@ -51,3 +51,11 @@
class CancelInvoiceMoveWarning(UserWarning):
pass
+
+
+class InvoiceTaxIdentifierWarning(UserWarning):
+ pass
+
+
+class InvoiceTaxIdentifierError(ValidationError):
+ pass
diff -r eed02ddd61b3 -r a9482f843bf5 modules/account_invoice/invoice.py
--- a/modules/account_invoice/invoice.py Sat Jul 04 11:39:19 2026 +0200
+++ b/modules/account_invoice/invoice.py Sat Jul 04 11:41:01 2026 +0200
@@ -39,7 +39,8 @@
from .exceptions import (
InvoiceFutureWarning, InvoiceNumberError, InvoicePaymentTermDateWarning,
- InvoiceSimilarWarning, InvoiceTaxesWarning, InvoiceTaxValidationError,
+ InvoiceSimilarWarning, InvoiceTaxesWarning, InvoiceTaxIdentifierError,
+ InvoiceTaxIdentifierWarning, InvoiceTaxValidationError,
InvoiceValidationError, PayInvoiceError)
if config.getboolean('account_invoice', 'filestore', default=False):
@@ -2060,6 +2061,7 @@
transaction = Transaction()
context = transaction.context
cls.set_number(invoices)
+ cls._check_tax_identifiers(invoices)
for company, grouped_invoices in groupby(
invoices, key=lambda i: i.company):
with Transaction().set_context(company=company.id):
@@ -2113,6 +2115,7 @@
cls.set_number(invoices)
cls.set_payment_means(invoices)
+ cls._check_tax_identifiers(invoices)
cls._store_cache(invoices)
moves = []
for invoice in invoices:
@@ -2141,6 +2144,31 @@
cls.__queue__.process(reconciled)
@classmethod
+ def _check_tax_identifiers(cls, invoices):
+ pool = Pool()
+ Warning = pool.get('res.user.warning')
+ for invoice in invoices:
+ for identifier in [
+ invoice.tax_identifier,
+ invoice.party_tax_identifier,
+ ]:
+ if (identifier
+ and identifier.type == 'eu_vat'
+ and not identifier.eu_vat_valid):
+ msg = gettext(
+ 'account_invoice.msg_invoice_tax_identifier_invalid',
+ invoice=invoice.rec_name,
+ identifier=identifier.rec_name)
+ if not identifier.eu_vat_validated_at:
+ key = Warning.format(
+ 'account.invoice eu_vat valid',
+ [identifier])
+ if Warning.check(key):
+ raise InvoiceTaxIdentifierWarning(key, msg)
+ else:
+ raise InvoiceTaxIdentifierError(msg)
+
+ @classmethod
def _check_taxes(cls, invoices):
pool = Pool()
Line = pool.get('account.invoice.line')
diff -r eed02ddd61b3 -r a9482f843bf5 modules/account_invoice/message.xml
--- a/modules/account_invoice/message.xml Sat Jul 04 11:39:19 2026 +0200
+++ b/modules/account_invoice/message.xml Sat Jul 04 11:41:01 2026 +0200
@@ -105,6 +105,9 @@
<record model="ir.message"
id="msg_invoice_currency_exchange_debit_account_missing">
<field name="text">To post invoice "%(invoice)s", you must define
a currency exchange debit account for "%(company)s".</field>
</record>
+ <record model="ir.message" id="msg_invoice_tax_identifier_invalid">
+ <field name="text">The tax identifier "%(identifier)s" on invoice
"%(invoice)s" has not been validated.</field>
+ </record>
</data>
</tryton>