Skip to content

Commit 2f90af1

Browse files
committed
[FIX] base_vat: support for 2020 Albanian Tax ID
__Description of the issue this PR addresses:__ The first character of a Tax ID from Albania is a letter representing the decade in which it has been issued. The letter M represents the current decade. (This pdf explains in details how it is formated: https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Albania-TIN.pdf). Currently the way Albanian Tax IDs are validated is through the python library [`python-stdnum`](https://pypi.org/project/python-stdnum/). However, the regex that is used to validate them has not been updated since 2017. (I made a PR in its repo arthurdejong/python-stdnum#402 to fix that). The code from this commit is inspired by the one from that library, but the regex includes the letter M. __Current behavior before PR:__ (`base_vat` must be installed) By going to Settings > Users & Companies > [A company]: - Set the country to Albania - Set VAT/Tax ID to “M12345678T”. => Error message X-original-commit: f0b6e4c
1 parent f8fb082 commit 2f90af1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

addons/base_vat/models/res_partner.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ def _build_vat_error_message(self, country_code, wrong_vat, record_label):
246246
expected_format=expected_format,
247247
)
248248

249+
__check_vat_al_re = re.compile(r'^[JKLM][0-9]{8}[A-Z]$')
250+
251+
def check_vat_al(self, vat):
252+
"""Check Albania VAT number"""
253+
number = stdnum.util.get_cc_module('al', 'vat').compact(vat)
254+
255+
if len(number) == 10 and self.__check_vat_al_re.match(number):
256+
return True
257+
return False
258+
249259
__check_vat_ch_re = re.compile(r'E([0-9]{9}|-[0-9]{3}\.[0-9]{3}\.[0-9]{3})(MWST|TVA|IVA)$')
250260

251261
def check_vat_ch(self, vat):

0 commit comments

Comments
 (0)