[IMP] l10n_fr_siret: check the length of SIREN and NAF

(/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5899)
This commit is contained in:
Numerigraphe - Lionel Sausin
2012-01-04 16:29:00 +01:00
parent e004ecff12
commit 28d3869a42
3 changed files with 10 additions and 9 deletions

View File

@@ -38,12 +38,12 @@ msgstr "Le numéro SIRET est l'identifiant officiel de l'établissement en Franc
#. module: l10n_fr_siret
#: help:res.partner,siren:0
msgid "The SIREN number is the official identity number of the company in France. It makes the first 9 digits of the SIRET number."
msgstr "Le numéro SIREN est l'identifiant officiel de la société en France. il compose les 9 premiers chiffres du numéro SIRET."
msgstr "Le numéro SIREN est l'identifiant officiel de la société en France. Il compose les 9 premiers chiffres du numéro SIRET."
#. module: l10n_fr_siret
#: help:res.partner,nic:0
msgid "The NIC number is the official rank number of this office in the company in France. It is composed of the last 5 digits of the SIRET number."
msgstr "The NIC number is the official rank number of this office in the company in France. It is composed of the last 5 digits of the SIRET number."
msgid "The NIC number is the official rank number of this office in the company in France. It makes the last 5 digits of the SIRET number."
msgstr "Le numéro NIC est le numéro de rang officiel de cet établissement dans sa société en France. Il compose les 5 derniers chiffres du numéro SIRET."
#. module: l10n_fr_siret
#: field:res.partner,siret:0

View File

@@ -42,7 +42,7 @@ msgstr ""
#. module: l10n_fr_siret
#: help:res.partner,nic:0
msgid "The NIC number is the official rank number of this office in the company in France. It is composed of the last 5 digits of the SIRET number."
msgid "The NIC number is the official rank number of this office in the company in France. It makes the last 5 digits of the SIRET number."
msgstr ""
#. module: l10n_fr_siret

View File

@@ -50,12 +50,13 @@ class Partner(osv.osv):
"""Check the SIREN's and NIC's keys (last digits)"""
for partner in self.browse(cr, uid, ids, context=None):
if partner.nic:
# Check the NIC type
if not partner.nic.isdecimal():
# Check the NIC type and length
if not partner.nic.isdecimal() or len(partner.nic)!=5:
return False
if partner.siren:
# Check the SIREN type and key
# Check the SIREN type, length and key
if (not partner.siren.isdecimal()
or len(partner.siren)!=9
or not _check_luhn(partner.siren) ):
return False
# Check the NIC key (you need both SIREN and NIC to check it)
@@ -71,8 +72,8 @@ class Partner(osv.osv):
'nic': fields.char('NIC', size=5,
help="The NIC number is the official rank number "
"of this office in the company in France. It "
"is composed of the last 5 digits of the "
"SIRET number."),
"makes the last 5 digits of the SIRET "
"number."),
'siret': fields.function(_get_siret, type="char", string='SIRET',
method=True, size=14,
store = {