[ADD] l10n_fr_siret - let users enter partner's company id numbers for France: SIREN, NIC and SIRET

(/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5898)
This commit is contained in:
unknown
2011-12-08 15:10:34 +01:00
parent 244016bc79
commit e004ecff12
6 changed files with 297 additions and 0 deletions

25
l10n_fr_siret/__init__.py Normal file
View File

@@ -0,0 +1,25 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import partner
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -0,0 +1,45 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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.
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': ['base'],
'init_xml': [],
'update_xml': ['partner_view.xml', ],
'installable': True,
'active': False,
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

57
l10n_fr_siret/i18n/fr.po Normal file
View File

@@ -0,0 +1,57 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_fr_siret
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1beta\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-12-08 14:04+0000\n"
"PO-Revision-Date: 2011-12-08 14:04+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: l10n_fr_siret
#: field:res.partner,siren:0
msgid "SIREN"
msgstr "SIREN"
#. module: l10n_fr_siret
#: field:res.partner,nic:0
msgid "NIC"
msgstr "NIC"
#. module: l10n_fr_siret
#: constraint:res.partner:0
msgid "The SIREN or NIC number is incorrect."
msgstr "Le numéro SIREN ou NIC est incorrect."
#. module: l10n_fr_siret
#: help:res.partner,siret:0
msgid "The SIRET number is the official identity number of this company's office in France. It is composed of the 9 digits of the SIREN number and the 5 digits of the NIC number, ie. 14 digits."
msgstr "Le numéro SIRET est l'identifiant officiel de l'établissement en France. Il est composé des 9 chiffres du numéro SIREN et des 5 chiffres du numéro NIC, soit 14 chiffres."
#. 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."
#. 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."
#. module: l10n_fr_siret
#: field:res.partner,siret:0
msgid "SIRET"
msgstr "SIRET"
#. module: l10n_fr_siret
#: model:ir.model,name:l10n_fr_siret.model_res_partner
msgid "Partner"
msgstr "Partenaire"

View File

@@ -0,0 +1,57 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * l10n_fr_siret
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 6.1beta\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-12-08 14:03+0000\n"
"PO-Revision-Date: 2011-12-08 14:03+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: l10n_fr_siret
#: field:res.partner,siren:0
msgid "SIREN"
msgstr ""
#. module: l10n_fr_siret
#: field:res.partner,nic:0
msgid "NIC"
msgstr ""
#. module: l10n_fr_siret
#: constraint:res.partner:0
msgid "The SIREN or NIC number is incorrect."
msgstr ""
#. module: l10n_fr_siret
#: help:res.partner,siret:0
msgid "The SIRET number is the official identity number of this company's office in France. It is composed of the 9 digits of the SIREN number and the 5 digits of the NIC number, ie. 14 digits."
msgstr ""
#. 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 ""
#. 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 ""
#. module: l10n_fr_siret
#: field:res.partner,siret:0
msgid "SIRET"
msgstr ""
#. module: l10n_fr_siret
#: model:ir.model,name:l10n_fr_siret.model_res_partner
msgid "Partner"
msgstr ""

95
l10n_fr_siret/partner.py Normal file
View File

@@ -0,0 +1,95 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2011 Numérigraphe SARL.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from osv import fields, osv
from tools.translate import _
# 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):
"""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 = {}
for partner in self.browse(cr, uid, ids, context=context):
if partner.siren and partner.nic:
sirets[partner.id] = '%s%s' % (partner.siren, partner.nic)
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):
if partner.nic:
# Check the NIC type
if not partner.nic.isdecimal():
return False
if partner.siren:
# Check the SIREN type and key
if (not partner.siren.isdecimal()
or not _check_luhn(partner.siren) ):
return False
# Check the NIC key (you need both SIREN and NIC to check it)
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 "
"number of the company in France. It makes "
"the first 9 digits of the SIRET number."),
'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."),
'siret': fields.function(_get_siret, type="char", string='SIRET',
method=True, size=14,
store = {
'res.partner': [lambda self, cr, uid, ids, context=None: ids,
['siren', 'nic'],
10]},
help="The SIRET number is the official identity number of this "
"company's office in France. It is composed of the 9 digits "
"of the SIREN number and the 5 digits of the NIC number, ie. "
"14 digits."),
}
_constraints = [
(_check_siret,
"The SIREN or NIC number is incorrect.",
["siren", "nic"]),
]
Partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Add the SIREN, NIC and SIRET numbers -->
<record model="ir.ui.view" id="view_partner_add">
<field name="name">res.partner.form.siret</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<field name="title" position="after">
<field name="siren" />
<field name="nic" />
<field name="siret" />
</field>
</field>
</record>
</data>
</openerp>