summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorBaptiste Vergote <bve@odoo.com>2020-10-12 08:42:59 +0000
committerBaptiste Vergote <bve@odoo.com>2020-10-12 15:54:07 +0000
commitbd95b7174bdf6c0e6a0dfcd394b69a519fde25be (patch)
treee60210e9bed21ead5229a2ceb110fa5efa433ca1 /addons
parentb55bc6fd497ef07553d7bab22af92c057691b777 (diff)
[FIX] base_vat: wrong example vatnumber for CH
As described here: https://www.estv.admin.ch/estv/fr/home/mehrwertsteuer/fachinformationen/steuerpflicht/unternehmens-identifikationsnummer--uid-.html The "new" (since 2014) vat number has to be displayed as: CHE 9 numeric digits plus TVA/MWST/IVA e.g.: CHE-123.456.788 TVA This commit removes the previous 6 digits vat number check and regex, and provide accurate examples on the error message displayed if the vatnumber given is wrong. opw-2291581 closes odoo/odoo#59789 X-original-commit: 624e086f0c8ac854fd292d3c6dd14a71ed67b9fe Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/base_vat/models/res_partner.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py
index 00014929de8..1cb3a0e5994 100644
--- a/addons/base_vat/models/res_partner.py
+++ b/addons/base_vat/models/res_partner.py
@@ -23,7 +23,7 @@ _ref_vat = {
'au': '83 914 571 673',
'be': 'BE0477472701',
'bg': 'BG1234567892',
- 'ch': 'CHE-123.456.788 TVA or CH TVA 123456', # Swiss by Yannick Vaucher @ Camptocamp
+ 'ch': 'CHE-123.456.788 TVA or CHE-123.456.788 MWST or CHE-123.456.788 IVA', # Swiss by Yannick Vaucher @ Camptocamp
'cl': 'CL76086428-5',
'co': 'CO213123432-1 or CO213.123.432-1',
'cy': 'CY10259033P',
@@ -175,23 +175,16 @@ class ResPartner(models.Model):
format=vat_no
)
- __check_vat_ch_re1 = re.compile(r'(MWST|TVA|IVA)[0-9]{6}$')
- __check_vat_ch_re2 = re.compile(r'E([0-9]{9}|-[0-9]{3}\.[0-9]{3}\.[0-9]{3})(MWST|TVA|IVA)$')
+ __check_vat_ch_re = re.compile(r'E([0-9]{9}|-[0-9]{3}\.[0-9]{3}\.[0-9]{3})(MWST|TVA|IVA)$')
def check_vat_ch(self, vat):
'''
Check Switzerland VAT number.
'''
- # VAT number in Switzerland will change between 2011 and 2013
- # http://www.estv.admin.ch/mwst/themen/00154/00589/01107/index.html?lang=fr
- # Old format is "TVA 123456" we will admit the user has to enter ch before the number
- # Format will becomes such as "CHE-999.999.99C TVA"
- # Both old and new format will be accepted till end of 2013
+ # A new VAT number format in Switzerland has been introduced between 2011 and 2013
+ # https://www.estv.admin.ch/estv/fr/home/mehrwertsteuer/fachinformationen/steuerpflicht/unternehmens-identifikationsnummer--uid-.html
+ # The old format "TVA 123456" is not valid since 2014
# Accepted format are: (spaces are ignored)
- # CH TVA ######
- # CH IVA ######
- # CH MWST #######
- #
# CHE#########MWST
# CHE#########TVA
# CHE#########IVA
@@ -199,11 +192,12 @@ class ResPartner(models.Model):
# CHE-###.###.### TVA
# CHE-###.###.### IVA
#
- if self.__check_vat_ch_re1.match(vat):
- return True
- match = self.__check_vat_ch_re2.match(vat)
+ # /!\ The english abbreviation VAT is not valid /!\
+
+ match = self.__check_vat_ch_re.match(vat)
+
if match:
- # For new TVA numbers, do a mod11 check
+ # For new TVA numbers, the last digit is a MOD11 checksum digit build with weighting pattern: 5,4,3,2,7,6,5,4
num = [s for s in match.group(1) if s.isdigit()] # get the digits only
factor = (5, 4, 3, 2, 7, 6, 5, 4)
csum = sum([int(num[i]) * factor[i] for i in range(8)])