details:   https://code.tryton.org/tryton/commit/c5df209174f2
branch:    default
user:      Cédric Krier <[email protected]>
date:      Sun Jan 11 11:42:04 2026 +0100
description:
        Remove custom ogm_vcs to only use python-stdnum implementation
diffstat:

 modules/account_be/account.py |   6 +----
 modules/account_be/ogm_vcs.py |  45 -------------------------------------------
 modules/account_be/setup.py   |   2 +-
 3 files changed, 2 insertions(+), 51 deletions(-)

diffs (77 lines):

diff -r ab41e8714d35 -r c5df209174f2 modules/account_be/account.py
--- a/modules/account_be/account.py     Thu Dec 11 15:20:11 2025 +0100
+++ b/modules/account_be/account.py     Sun Jan 11 11:42:04 2026 +0100
@@ -2,11 +2,7 @@
 # this repository contains the full copyright notices and license terms.
 import stdnum.exceptions
 from sql.aggregate import Min, Sum
-
-try:
-    from stdnum.be import ogm_vcs
-except ImportError:
-    from . import ogm_vcs
+from stdnum.be import ogm_vcs
 
 from trytond.model import ModelSQL, ModelView, fields
 from trytond.modules.account.exceptions import FiscalYearNotFoundError
diff -r ab41e8714d35 -r c5df209174f2 modules/account_be/ogm_vcs.py
--- a/modules/account_be/ogm_vcs.py     Thu Dec 11 15:20:11 2025 +0100
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-# This file is part of Tryton.  The COPYRIGHT file at the top level of
-# this repository contains the full copyright notices and license terms.
-
-from stdnum.exceptions import (
-    InvalidChecksum, InvalidFormat, InvalidLength, ValidationError)
-from stdnum.util import clean, isdigits
-
-
-def compact(number: str) -> str:
-    """Convert the number to the minimal representation. This strips the number
-    of any invalid separators and removes surrounding whitespace."""
-    return clean(number, ' +/').strip()
-
-
-def calc_check_digits(number: str) -> str:
-    """Calculate the check digit that should be added."""
-    number = compact(number)
-    return '%02d' % ((int(number[:10]) % 97) or 97)
-
-
-def validate(number: str) -> str:
-    """Check if the number is a valid OGM-VCS."""
-    number = compact(number)
-    if not isdigits(number) or int(number) <= 0:
-        raise InvalidFormat()
-    if len(number) != 12:
-        raise InvalidLength()
-    if calc_check_digits(number) != number[-2:]:
-        raise InvalidChecksum()
-    return number
-
-
-def is_valid(number: str) -> bool:
-    """Check if the number is a valid VAT number."""
-    try:
-        return bool(validate(number))
-    except ValidationError:
-        return False
-
-
-def format(number: str) -> str:
-    """Format the number provided for output."""
-    number = compact(number)
-    number = number.rjust(12, '0')
-    return f'{number[:3]}/{number[3:7]}/{number[7:]}'
diff -r ab41e8714d35 -r c5df209174f2 modules/account_be/setup.py
--- a/modules/account_be/setup.py       Thu Dec 11 15:20:11 2025 +0100
+++ b/modules/account_be/setup.py       Sun Jan 11 11:42:04 2026 +0100
@@ -44,7 +44,7 @@
     download_url = 'http://downloads.tryton.org/%s.%s/' % (
         major_version, minor_version)
 
-requires = ['python-stdnum']
+requires = ['python-stdnum >= 2.2']
 for dep in info.get('depends', []):
     if not re.match(r'(ir|res)(\W|$)', dep):
         requires.append(get_require_version('trytond_%s' % dep))

Reply via email to