From e004ecff12d51172ad824eed9f8e73d0c696e46b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Dec 2011 15:10:34 +0100 Subject: [PATCH 1/9] [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) --- l10n_fr_siret/__init__.py | 25 ++++++++ l10n_fr_siret/__openerp__.py | 45 ++++++++++++++ l10n_fr_siret/i18n/fr.po | 57 +++++++++++++++++ l10n_fr_siret/i18n/l10n_fr_siret.po | 57 +++++++++++++++++ l10n_fr_siret/partner.py | 95 +++++++++++++++++++++++++++++ l10n_fr_siret/partner_view.xml | 18 ++++++ 6 files changed, 297 insertions(+) create mode 100644 l10n_fr_siret/__init__.py create mode 100644 l10n_fr_siret/__openerp__.py create mode 100644 l10n_fr_siret/i18n/fr.po create mode 100644 l10n_fr_siret/i18n/l10n_fr_siret.po create mode 100644 l10n_fr_siret/partner.py create mode 100644 l10n_fr_siret/partner_view.xml diff --git a/l10n_fr_siret/__init__.py b/l10n_fr_siret/__init__.py new file mode 100644 index 000000000..f9ccadcb7 --- /dev/null +++ b/l10n_fr_siret/__init__.py @@ -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 . +# +############################################################################## + +import partner + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/l10n_fr_siret/__openerp__.py b/l10n_fr_siret/__openerp__.py new file mode 100644 index 000000000..02bf613a6 --- /dev/null +++ b/l10n_fr_siret/__openerp__.py @@ -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 . +# +############################################################################## + +{ + '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: diff --git a/l10n_fr_siret/i18n/fr.po b/l10n_fr_siret/i18n/fr.po new file mode 100644 index 000000000..271033290 --- /dev/null +++ b/l10n_fr_siret/i18n/fr.po @@ -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" + diff --git a/l10n_fr_siret/i18n/l10n_fr_siret.po b/l10n_fr_siret/i18n/l10n_fr_siret.po new file mode 100644 index 000000000..4bf92e696 --- /dev/null +++ b/l10n_fr_siret/i18n/l10n_fr_siret.po @@ -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 "" + diff --git a/l10n_fr_siret/partner.py b/l10n_fr_siret/partner.py new file mode 100644 index 000000000..5ebeb846f --- /dev/null +++ b/l10n_fr_siret/partner.py @@ -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 . +# +############################################################################## + +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: diff --git a/l10n_fr_siret/partner_view.xml b/l10n_fr_siret/partner_view.xml new file mode 100644 index 000000000..02d3b8d9c --- /dev/null +++ b/l10n_fr_siret/partner_view.xml @@ -0,0 +1,18 @@ + + + + + + res.partner.form.siret + res.partner + + + + + + + + + + + From 28d3869a42f0190d49738c4061ef4336a959583f Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Wed, 4 Jan 2012 16:29:00 +0100 Subject: [PATCH 2/9] [IMP] l10n_fr_siret: check the length of SIREN and NAF (/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5899) --- l10n_fr_siret/i18n/fr.po | 6 +++--- l10n_fr_siret/i18n/l10n_fr_siret.po | 2 +- l10n_fr_siret/partner.py | 11 ++++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/l10n_fr_siret/i18n/fr.po b/l10n_fr_siret/i18n/fr.po index 271033290..4828aaaa0 100644 --- a/l10n_fr_siret/i18n/fr.po +++ b/l10n_fr_siret/i18n/fr.po @@ -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 diff --git a/l10n_fr_siret/i18n/l10n_fr_siret.po b/l10n_fr_siret/i18n/l10n_fr_siret.po index 4bf92e696..9b41df1ff 100644 --- a/l10n_fr_siret/i18n/l10n_fr_siret.po +++ b/l10n_fr_siret/i18n/l10n_fr_siret.po @@ -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 diff --git a/l10n_fr_siret/partner.py b/l10n_fr_siret/partner.py index 5ebeb846f..26a6a678f 100644 --- a/l10n_fr_siret/partner.py +++ b/l10n_fr_siret/partner.py @@ -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 = { From f4147d5b1a32520d231eb0e5b8bfcb175b638a6d Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 27 Aug 2012 17:41:10 +0200 Subject: [PATCH 3/9] [IMP] adapt the view to the improvements in v7 (/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5904) --- l10n_fr_siret/partner_view.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/l10n_fr_siret/partner_view.xml b/l10n_fr_siret/partner_view.xml index 02d3b8d9c..9de818952 100644 --- a/l10n_fr_siret/partner_view.xml +++ b/l10n_fr_siret/partner_view.xml @@ -1,16 +1,18 @@ - + res.partner.form.siret res.partner - + - - - - + + + + + + From 040edf9d880c01a4a19db5bfab59bd0728124d03 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 27 Aug 2012 17:48:28 +0200 Subject: [PATCH 4/9] [IMP] Add the RCS to the partner (/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5905) --- l10n_fr_siret/partner.py | 3 +++ l10n_fr_siret/partner_view.xml | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/l10n_fr_siret/partner.py b/l10n_fr_siret/partner.py index 26a6a678f..d49e8510e 100644 --- a/l10n_fr_siret/partner.py +++ b/l10n_fr_siret/partner.py @@ -84,6 +84,9 @@ class Partner(osv.osv): "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."), + 'rcs': fields.char('RCS', size=64, + help="The name of the city where the chamber of " + "commerce that registered this company is."), } _constraints = [ diff --git a/l10n_fr_siret/partner_view.xml b/l10n_fr_siret/partner_view.xml index 9de818952..414844410 100644 --- a/l10n_fr_siret/partner_view.xml +++ b/l10n_fr_siret/partner_view.xml @@ -8,10 +8,11 @@ - + + From dfe5b1cf4e16a4dd8bd2c1e5db80e4b691fc1272 Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 27 Aug 2012 18:04:37 +0200 Subject: [PATCH 5/9] [IMP] improved view for SIRET/RCS (/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5906) --- l10n_fr_siret/partner_view.xml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/l10n_fr_siret/partner_view.xml b/l10n_fr_siret/partner_view.xml index 414844410..9fcd481eb 100644 --- a/l10n_fr_siret/partner_view.xml +++ b/l10n_fr_siret/partner_view.xml @@ -7,14 +7,18 @@ res.partner - - - - - - + + + + + + + + + + - + From 37b31f397b2663836c4b2e3f5d22b55430ff6cfa Mon Sep 17 00:00:00 2001 From: Numerigraphe - Lionel Sausin Date: Mon, 27 Aug 2012 18:40:53 +0200 Subject: [PATCH 6/9] [IMP] rename RCS to company_registry to make it consistent with improvements in the trunk server (/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5907) --- l10n_fr_siret/partner.py | 6 +++--- l10n_fr_siret/partner_view.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/l10n_fr_siret/partner.py b/l10n_fr_siret/partner.py index d49e8510e..194f3b3c7 100644 --- a/l10n_fr_siret/partner.py +++ b/l10n_fr_siret/partner.py @@ -84,9 +84,9 @@ class Partner(osv.osv): "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."), - 'rcs': fields.char('RCS', size=64, - help="The name of the city where the chamber of " - "commerce that registered this company is."), + 'company_registry': fields.char('Company Registry', size=64, + help="The name of official registry where this " + "company was declared."), } _constraints = [ diff --git a/l10n_fr_siret/partner_view.xml b/l10n_fr_siret/partner_view.xml index 9fcd481eb..a53deeeba 100644 --- a/l10n_fr_siret/partner_view.xml +++ b/l10n_fr_siret/partner_view.xml @@ -15,7 +15,7 @@ - + From 9ce5e7b66393a42d429a0176eed99272f534516b Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Wed, 23 Jan 2013 16:18:46 +0100 Subject: [PATCH 7/9] [FIX] reversed dependencies between l10n_fr and (l10n_fr_rib and l10n_fr_siret) (/home/afayolle/work/oerp/addons/trunk-l10n-fr-siret rev 5908) --- l10n_fr_siret/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_fr_siret/__openerp__.py b/l10n_fr_siret/__openerp__.py index 02bf613a6..85e8856cd 100644 --- a/l10n_fr_siret/__openerp__.py +++ b/l10n_fr_siret/__openerp__.py @@ -35,7 +35,7 @@ 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'], + 'depends': ['l10n_fr'], 'init_xml': [], 'update_xml': ['partner_view.xml', ], 'installable': True, From d916284b22bf3cce079180c0c55b46e51a44d5cf Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Tue, 5 Feb 2013 17:03:32 +0100 Subject: [PATCH 8/9] [REF] bring l10n_fr_siret module on par with 7.0 modules --- l10n_fr_siret/__openerp__.py | 28 ++++++++++++++-------------- l10n_fr_siret/partner.py | 22 +++++++++++----------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/l10n_fr_siret/__openerp__.py b/l10n_fr_siret/__openerp__.py index 85e8856cd..38504d6a4 100644 --- a/l10n_fr_siret/__openerp__.py +++ b/l10n_fr_siret/__openerp__.py @@ -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, } diff --git a/l10n_fr_siret/partner.py b/l10n_fr_siret/partner.py index 194f3b3c7..4291c0665 100644 --- a/l10n_fr_siret/partner.py +++ b/l10n_fr_siret/partner.py @@ -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: From b4b5a07f54e6dc50aa53c731f8ca7cb334080735 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Thu, 7 Feb 2013 15:29:51 +0100 Subject: [PATCH 9/9] [FIX] add missing dependency on base module --- l10n_fr_siret/__openerp__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n_fr_siret/__openerp__.py b/l10n_fr_siret/__openerp__.py index 38504d6a4..16bc7b0d2 100644 --- a/l10n_fr_siret/__openerp__.py +++ b/l10n_fr_siret/__openerp__.py @@ -35,7 +35,7 @@ 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': [], + 'depends': ['base'], 'data': ['partner_view.xml', ], 'installable': True,