mirror of
https://github.com/OCA/account-financial-tools.git
synced 2025-02-02 12:47:26 +02:00
[REF] bring l10n_fr_siret module on par with 7.0 modules
This commit is contained in:
@@ -22,22 +22,22 @@
|
||||
{
|
||||
'name': 'French company identity numbers SIRET/SIREN/NIC',
|
||||
'version': '1.0',
|
||||
"category": 'Hidden',
|
||||
'description': '''
|
||||
This module lets users keep track of the companies' unique identification \
|
||||
numbers from the official SIRENE registry in France: SIRET, SIREN and NIC.
|
||||
These numbers identify each company and their subsidiaries, and are \
|
||||
often required for administrative tasks.
|
||||
"category": 'Accounting',
|
||||
'description': """
|
||||
This module lets users keep track of the companies' unique
|
||||
identification numbers from the official SIRENE registry in France:
|
||||
SIRET, SIREN and NIC. These numbers identify each company and their
|
||||
subsidiaries, and are often required for administrative tasks.
|
||||
|
||||
At the top of the Partner form, users will be able to enter the SIREN \
|
||||
and NIC numbers, and the SIRET number will be calculated automatically.
|
||||
The last digits of the SIREN and NIC are control keys: OpenERP will check their \
|
||||
validity when partners are recorded.
|
||||
''',
|
||||
At the top of the Partner form, users will be able to enter the SIREN
|
||||
and NIC numbers, and the SIRET number will be calculated
|
||||
automatically. The last digits of the SIREN and NIC are control keys:
|
||||
OpenERP will check their validity when partners are recorded.
|
||||
""",
|
||||
'author' : u'Numérigraphe SARL',
|
||||
'depends': ['l10n_fr'],
|
||||
'init_xml': [],
|
||||
'update_xml': ['partner_view.xml', ],
|
||||
'depends': [],
|
||||
'data': ['partner_view.xml',
|
||||
],
|
||||
'installable': True,
|
||||
'active': False,
|
||||
}
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
from osv import fields, osv
|
||||
from tools.translate import _
|
||||
from openerp.osv import fields, orm
|
||||
|
||||
|
||||
# XXX: this is used for checking various codes such as credit card numbers: should it be moved to tools.py?
|
||||
|
||||
# XXX: this is used for checking various codes such as credit card
|
||||
# numbers: should it be moved to tools.py?
|
||||
def _check_luhn(string):
|
||||
"""Luhn test to check control keys
|
||||
|
||||
|
||||
Credits: http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Python
|
||||
"""
|
||||
r = [int(ch) for ch in string][::-1]
|
||||
return (sum(r[0::2]) + sum(sum(divmod(d*2,10)) for d in r[1::2])) % 10 == 0
|
||||
|
||||
class Partner(osv.osv):
|
||||
class Partner(orm.Model):
|
||||
"""Add the French official company identity numbers SIREN, NIC and SIRET"""
|
||||
_inherit = 'res.partner'
|
||||
|
||||
|
||||
def _get_siret(self, cr, uid, ids, field_name, arg, context=None):
|
||||
"""Concatenate the SIREN and NIC to form the SIRET"""
|
||||
sirets = {}
|
||||
@@ -45,7 +45,7 @@ class Partner(osv.osv):
|
||||
else:
|
||||
sirets[partner.id] = ''
|
||||
return sirets
|
||||
|
||||
|
||||
def _check_siret(self, cr, uid, ids):
|
||||
"""Check the SIREN's and NIC's keys (last digits)"""
|
||||
for partner in self.browse(cr, uid, ids, context=None):
|
||||
@@ -63,7 +63,7 @@ class Partner(osv.osv):
|
||||
if partner.nic and not _check_luhn(partner.siren + partner.nic):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
_columns = {
|
||||
'siren': fields.char('SIREN', size=9,
|
||||
help="The SIREN number is the official identity "
|
||||
@@ -88,12 +88,12 @@ class Partner(osv.osv):
|
||||
help="The name of official registry where this "
|
||||
"company was declared."),
|
||||
}
|
||||
|
||||
|
||||
_constraints = [
|
||||
(_check_siret,
|
||||
"The SIREN or NIC number is incorrect.",
|
||||
["siren", "nic"]),
|
||||
]
|
||||
Partner()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
Reference in New Issue
Block a user