Add length check for SIREN and SIRET

issue2342
review333001
(transplanted from 9e2eb48f66375d71717e6ca769bb7710c41aaaa5)
This commit is contained in:
Nicolas Trésegnie committed 2012-04-19 19:40:39 +02:00
1 parent 56575ac68d
commit dcd49ddb4c
2 files changed
+7 -4

No files matched your search

+3 -2
View File
@@ -36,8 +36,9 @@ class Address(Model):
Check validity of SIRET
'''
for address in self.browse(ids):
if address.siret and not luhn.validate(address.siret):
return False
if address.siret:
if len(address.siret) != 14 or not luhn.validate(address.siret):
return False
return True
Address()
+4 -2
View File
@@ -26,8 +26,10 @@ class Party(Model):
Check validity of SIREN
'''
for party in self.browse(ids):
if party.siren and not luhn.validate(party.siren):
return False
if party.siren:
if len(party.siren) != 9 or not luhn.validate(party.siren):
return False
print party.addresses
return True
Party()