Skip to content

Commit

Permalink
[FIX] base_vat: Indonesian 16-digits Tax ID validation
Browse files Browse the repository at this point in the history
Recently, Indonesia introduced a new tax ID format featuring 16 digits,
replacing the previous 15-digit system. We have implemented support for
this 16-digit tax ID. However, we are currently applying the 15-digit
validation method (Luhn algorithm) to the 16-digit IDs, which doesn't
work.

opw-3727058

closes odoo#153612

Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
  • Loading branch information
ushyme committed May 2, 2024
1 parent 0e0c0de commit 38aefaf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions addons/base_vat/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,12 @@ def check_vat_id(self, vat):
if len(vat) not in (15, 16) or not vat[0:15].isdecimal() or not vat[-1].isdecimal():
return False

# VAT is only digits and of the right length, check the Luhn checksum.
try:
luhn.validate(vat[0:9])
except (InvalidFormat, InvalidChecksum):
return False
if len(vat) == 15:
# VAT is only digits and of the right length, check the Luhn checksum.
try:
luhn.validate(vat[0:9])
except (InvalidFormat, InvalidChecksum):
return False

return True

Expand Down

0 comments on commit 38aefaf

Please sign in to comment.