Merge lp:~camptocamp/account-financial-tools/7.0-add_l10n_fr_siret into lp:~account-core-editors/account-financial-tools/7.0

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Approved by: Alexandre Fayolle - camptocamp
Approved revision: 113
Merged at revision: 108
Proposed branch: lp:~camptocamp/account-financial-tools/7.0-add_l10n_fr_siret
Merge into: lp:~account-core-editors/account-financial-tools/7.0
Diff against target: 339 lines (+308/-0)
6 files modified
l10n_fr_siret/__init__.py (+25/-0)
l10n_fr_siret/__openerp__.py (+45/-0)
l10n_fr_siret/i18n/fr.po (+57/-0)
l10n_fr_siret/i18n/l10n_fr_siret.po (+57/-0)
l10n_fr_siret/partner.py (+99/-0)
l10n_fr_siret/partner_view.xml (+25/-0)
To merge this branch: bzr merge lp:~camptocamp/account-financial-tools/7.0-add_l10n_fr_siret
Reviewer Review Type Date Requested Status
Numérigraphe (community) Approve
Account Core Editors Pending
Review via email: mp+147126@code.launchpad.net

This proposal supersedes a proposal from 2013-02-05.

Description of the change

Add l10n_fr_siret module, which adds a SIRET number to res.partner (whereas the current l10n_fr module only does so on res.company)

This module was proposed as part of a solution to lp:10402324 back in august and never merged in 7.0 due to a wrong timing.

Adding this module here was suggested by Frederic Clementi. If someone has a better idea, I'll be happy to propose a merge in another branch.

To post a comment you must log in.
Revision history for this message
Numérigraphe (numerigraphe) wrote : Posted in a previous version of this proposal

I suggest you add a dependency on 'base' to make sure you can access view etc, as stated in http://doc.openerp.com/v6.1/developer/03_modules_1.html#openerp-module-descriptor-file-openerp-py.
Other than that I think it's OK.
Lionel

review: Needs Fixing
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Added the missing dependency.

Revision history for this message
Numérigraphe (numerigraphe) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'l10n_fr_siret'
2=== added file 'l10n_fr_siret/__init__.py'
3--- l10n_fr_siret/__init__.py 1970-01-01 00:00:00 +0000
4+++ l10n_fr_siret/__init__.py 2013-02-07 14:31:39 +0000
5@@ -0,0 +1,25 @@
6+# -*- encoding: utf-8 -*-
7+##############################################################################
8+#
9+# OpenERP, Open Source Management Solution
10+# Copyright (C) 2011 Numérigraphe SARL.
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+import partner
28+
29+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
30+
31
32=== added file 'l10n_fr_siret/__openerp__.py'
33--- l10n_fr_siret/__openerp__.py 1970-01-01 00:00:00 +0000
34+++ l10n_fr_siret/__openerp__.py 2013-02-07 14:31:39 +0000
35@@ -0,0 +1,45 @@
36+# -*- encoding: utf-8 -*-
37+##############################################################################
38+#
39+# OpenERP, Open Source Management Solution
40+# Copyright (C) 2011 Numérigraphe SARL.
41+#
42+# This program is free software: you can redistribute it and/or modify
43+# it under the terms of the GNU Affero General Public License as
44+# published by the Free Software Foundation, either version 3 of the
45+# License, or (at your option) any later version.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Affero General Public License for more details.
51+#
52+# You should have received a copy of the GNU Affero General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+#
55+##############################################################################
56+
57+{
58+ 'name': 'French company identity numbers SIRET/SIREN/NIC',
59+ 'version': '1.0',
60+ "category": 'Accounting',
61+ 'description': """
62+This module lets users keep track of the companies' unique
63+identification numbers from the official SIRENE registry in France:
64+SIRET, SIREN and NIC. These numbers identify each company and their
65+subsidiaries, and are often required for administrative tasks.
66+
67+At the top of the Partner form, users will be able to enter the SIREN
68+and NIC numbers, and the SIRET number will be calculated
69+automatically. The last digits of the SIREN and NIC are control keys:
70+OpenERP will check their validity when partners are recorded.
71+""",
72+ 'author' : u'Numérigraphe SARL',
73+ 'depends': ['base'],
74+ 'data': ['partner_view.xml',
75+ ],
76+ 'installable': True,
77+ 'active': False,
78+}
79+
80+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
81
82=== added directory 'l10n_fr_siret/i18n'
83=== added file 'l10n_fr_siret/i18n/fr.po'
84--- l10n_fr_siret/i18n/fr.po 1970-01-01 00:00:00 +0000
85+++ l10n_fr_siret/i18n/fr.po 2013-02-07 14:31:39 +0000
86@@ -0,0 +1,57 @@
87+# Translation of OpenERP Server.
88+# This file contains the translation of the following modules:
89+# * l10n_fr_siret
90+#
91+msgid ""
92+msgstr ""
93+"Project-Id-Version: OpenERP Server 6.1beta\n"
94+"Report-Msgid-Bugs-To: \n"
95+"POT-Creation-Date: 2011-12-08 14:04+0000\n"
96+"PO-Revision-Date: 2011-12-08 14:04+0000\n"
97+"Last-Translator: <>\n"
98+"Language-Team: \n"
99+"MIME-Version: 1.0\n"
100+"Content-Type: text/plain; charset=UTF-8\n"
101+"Content-Transfer-Encoding: \n"
102+"Plural-Forms: \n"
103+
104+#. module: l10n_fr_siret
105+#: field:res.partner,siren:0
106+msgid "SIREN"
107+msgstr "SIREN"
108+
109+#. module: l10n_fr_siret
110+#: field:res.partner,nic:0
111+msgid "NIC"
112+msgstr "NIC"
113+
114+#. module: l10n_fr_siret
115+#: constraint:res.partner:0
116+msgid "The SIREN or NIC number is incorrect."
117+msgstr "Le numéro SIREN ou NIC est incorrect."
118+
119+#. module: l10n_fr_siret
120+#: help:res.partner,siret:0
121+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."
122+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."
123+
124+#. module: l10n_fr_siret
125+#: help:res.partner,siren:0
126+msgid "The SIREN number is the official identity number of the company in France. It makes the first 9 digits of the SIRET number."
127+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."
128+
129+#. module: l10n_fr_siret
130+#: help:res.partner,nic:0
131+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."
132+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."
133+
134+#. module: l10n_fr_siret
135+#: field:res.partner,siret:0
136+msgid "SIRET"
137+msgstr "SIRET"
138+
139+#. module: l10n_fr_siret
140+#: model:ir.model,name:l10n_fr_siret.model_res_partner
141+msgid "Partner"
142+msgstr "Partenaire"
143+
144
145=== added file 'l10n_fr_siret/i18n/l10n_fr_siret.po'
146--- l10n_fr_siret/i18n/l10n_fr_siret.po 1970-01-01 00:00:00 +0000
147+++ l10n_fr_siret/i18n/l10n_fr_siret.po 2013-02-07 14:31:39 +0000
148@@ -0,0 +1,57 @@
149+# Translation of OpenERP Server.
150+# This file contains the translation of the following modules:
151+# * l10n_fr_siret
152+#
153+msgid ""
154+msgstr ""
155+"Project-Id-Version: OpenERP Server 6.1beta\n"
156+"Report-Msgid-Bugs-To: \n"
157+"POT-Creation-Date: 2011-12-08 14:03+0000\n"
158+"PO-Revision-Date: 2011-12-08 14:03+0000\n"
159+"Last-Translator: <>\n"
160+"Language-Team: \n"
161+"MIME-Version: 1.0\n"
162+"Content-Type: text/plain; charset=UTF-8\n"
163+"Content-Transfer-Encoding: \n"
164+"Plural-Forms: \n"
165+
166+#. module: l10n_fr_siret
167+#: field:res.partner,siren:0
168+msgid "SIREN"
169+msgstr ""
170+
171+#. module: l10n_fr_siret
172+#: field:res.partner,nic:0
173+msgid "NIC"
174+msgstr ""
175+
176+#. module: l10n_fr_siret
177+#: constraint:res.partner:0
178+msgid "The SIREN or NIC number is incorrect."
179+msgstr ""
180+
181+#. module: l10n_fr_siret
182+#: help:res.partner,siret:0
183+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."
184+msgstr ""
185+
186+#. module: l10n_fr_siret
187+#: help:res.partner,siren:0
188+msgid "The SIREN number is the official identity number of the company in France. It makes the first 9 digits of the SIRET number."
189+msgstr ""
190+
191+#. module: l10n_fr_siret
192+#: help:res.partner,nic:0
193+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."
194+msgstr ""
195+
196+#. module: l10n_fr_siret
197+#: field:res.partner,siret:0
198+msgid "SIRET"
199+msgstr ""
200+
201+#. module: l10n_fr_siret
202+#: model:ir.model,name:l10n_fr_siret.model_res_partner
203+msgid "Partner"
204+msgstr ""
205+
206
207=== added file 'l10n_fr_siret/partner.py'
208--- l10n_fr_siret/partner.py 1970-01-01 00:00:00 +0000
209+++ l10n_fr_siret/partner.py 2013-02-07 14:31:39 +0000
210@@ -0,0 +1,99 @@
211+# -*- encoding: utf-8 -*-
212+##############################################################################
213+#
214+# OpenERP, Open Source Management Solution
215+# Copyright (C) 2011 Numérigraphe SARL.
216+#
217+# This program is free software: you can redistribute it and/or modify
218+# it under the terms of the GNU Affero General Public License as
219+# published by the Free Software Foundation, either version 3 of the
220+# License, or (at your option) any later version.
221+#
222+# This program is distributed in the hope that it will be useful,
223+# but WITHOUT ANY WARRANTY; without even the implied warranty of
224+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
225+# GNU Affero General Public License for more details.
226+#
227+# You should have received a copy of the GNU Affero General Public License
228+# along with this program. If not, see <http://www.gnu.org/licenses/>.
229+#
230+##############################################################################
231+
232+from openerp.osv import fields, orm
233+
234+
235+# XXX: this is used for checking various codes such as credit card
236+# numbers: should it be moved to tools.py?
237+def _check_luhn(string):
238+ """Luhn test to check control keys
239+
240+ Credits: http://rosettacode.org/wiki/Luhn_test_of_credit_card_numbers#Python
241+ """
242+ r = [int(ch) for ch in string][::-1]
243+ return (sum(r[0::2]) + sum(sum(divmod(d*2,10)) for d in r[1::2])) % 10 == 0
244+
245+class Partner(orm.Model):
246+ """Add the French official company identity numbers SIREN, NIC and SIRET"""
247+ _inherit = 'res.partner'
248+
249+ def _get_siret(self, cr, uid, ids, field_name, arg, context=None):
250+ """Concatenate the SIREN and NIC to form the SIRET"""
251+ sirets = {}
252+ for partner in self.browse(cr, uid, ids, context=context):
253+ if partner.siren and partner.nic:
254+ sirets[partner.id] = '%s%s' % (partner.siren, partner.nic)
255+ else:
256+ sirets[partner.id] = ''
257+ return sirets
258+
259+ def _check_siret(self, cr, uid, ids):
260+ """Check the SIREN's and NIC's keys (last digits)"""
261+ for partner in self.browse(cr, uid, ids, context=None):
262+ if partner.nic:
263+ # Check the NIC type and length
264+ if not partner.nic.isdecimal() or len(partner.nic)!=5:
265+ return False
266+ if partner.siren:
267+ # Check the SIREN type, length and key
268+ if (not partner.siren.isdecimal()
269+ or len(partner.siren)!=9
270+ or not _check_luhn(partner.siren) ):
271+ return False
272+ # Check the NIC key (you need both SIREN and NIC to check it)
273+ if partner.nic and not _check_luhn(partner.siren + partner.nic):
274+ return False
275+ return True
276+
277+ _columns = {
278+ 'siren': fields.char('SIREN', size=9,
279+ help="The SIREN number is the official identity "
280+ "number of the company in France. It makes "
281+ "the first 9 digits of the SIRET number."),
282+ 'nic': fields.char('NIC', size=5,
283+ help="The NIC number is the official rank number "
284+ "of this office in the company in France. It "
285+ "makes the last 5 digits of the SIRET "
286+ "number."),
287+ 'siret': fields.function(_get_siret, type="char", string='SIRET',
288+ method=True, size=14,
289+ store = {
290+ 'res.partner': [lambda self, cr, uid, ids, context=None: ids,
291+ ['siren', 'nic'],
292+ 10]},
293+ help="The SIRET number is the official identity number of this "
294+ "company's office in France. It is composed of the 9 digits "
295+ "of the SIREN number and the 5 digits of the NIC number, ie. "
296+ "14 digits."),
297+ 'company_registry': fields.char('Company Registry', size=64,
298+ help="The name of official registry where this "
299+ "company was declared."),
300+ }
301+
302+ _constraints = [
303+ (_check_siret,
304+ "The SIREN or NIC number is incorrect.",
305+ ["siren", "nic"]),
306+ ]
307+
308+
309+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
310
311=== added file 'l10n_fr_siret/partner_view.xml'
312--- l10n_fr_siret/partner_view.xml 1970-01-01 00:00:00 +0000
313+++ l10n_fr_siret/partner_view.xml 2013-02-07 14:31:39 +0000
314@@ -0,0 +1,25 @@
315+<?xml version="1.0" encoding="utf-8"?>
316+<openerp>
317+ <data>
318+ <!-- Add the SIREN, NIC and SIRET numbers -->
319+ <record model="ir.ui.view" id="view_partner_add">
320+ <field name="name">res.partner.form.siret</field>
321+ <field name="model">res.partner</field>
322+ <field name="inherit_id" ref="account.view_partner_property_form" />
323+ <field name="arch" type="xml">
324+ <page string="Accounting" position="inside">
325+ <group>
326+ <group>
327+ <field name="siren" />
328+ <field name="nic" />
329+ <field name="siret" />
330+ </group>
331+ <group>
332+ <field name="company_registry" />
333+ </group>
334+ </group>
335+ </page>
336+ </field>
337+ </record>
338+ </data>
339+</openerp>

Subscribers

People subscribed via source and target branches