Merge lp:~lepistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-lep into lp:~openobject-italia-core-devs/openobject-italia/italian-addons-6.1

Proposed by Leonardo Pistone
Status: Merged
Merged at revision: 232
Proposed branch: lp:~lepistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-lep
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons-6.1
Diff against target: 733 lines (+447/-144)
8 files modified
l10n_it_account/AUTHORS.txt (+1/-1)
l10n_it_account/__init__.py (+2/-0)
l10n_it_account/__openerp__.py (+4/-1)
l10n_it_account/i18n/it.po (+126/-76)
l10n_it_account/i18n/l10n_it_account.pot (+122/-66)
l10n_it_account/wizard/__init__.py (+22/-0)
l10n_it_account/wizard/fiscalcode_to_data.py (+138/-0)
l10n_it_account/wizard/fiscalcode_to_data_view.xml (+32/-0)
To merge this branch: bzr merge lp:~lepistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-lep
Reviewer Review Type Date Requested Status
Lorenzo Battistini Approve
Leonardo Pistone (community) Approve
Review via email: mp+162763@code.launchpad.net
To post a comment you must log in.
232. By Leonardo Pistone

[fix] fiscal code to data: sanity checks

233. By Leonardo Pistone

[imp] fiscalcode to data: allow to ignore sanity checks

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Non mi sembra dannosa perché non aggiunge campi ma solo un wizard.

review: Approve
234. By Leonardo Pistone

[merge] upstream

235. By Leonardo Pistone

[imp] l10n_it_account: translations

Revision history for this message
Lorenzo Battistini (elbati) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_it_account/AUTHORS.txt'
2--- l10n_it_account/AUTHORS.txt 2012-10-19 16:06:38 +0000
3+++ l10n_it_account/AUTHORS.txt 2013-05-07 13:44:26 +0000
4@@ -6,4 +6,4 @@
5 Giovanni Barzan <giovanni.barzan@gmail.com>
6 Lorenzo Battistini <lorenzo.battistini@albatos.com>
7 Roberto Onnis <onnis.roberto@gmail.com>
8-
9+Leonardo Pistone <leonardo.pistone@agilebg.com>
10
11=== modified file 'l10n_it_account/__init__.py'
12--- l10n_it_account/__init__.py 2013-01-04 14:02:10 +0000
13+++ l10n_it_account/__init__.py 2013-05-07 13:44:26 +0000
14@@ -20,5 +20,7 @@
15 ##############################################################################
16
17 import account
18+import wizard
19+
20 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
21
22
23=== modified file 'l10n_it_account/__openerp__.py'
24--- l10n_it_account/__openerp__.py 2013-01-04 14:02:10 +0000
25+++ l10n_it_account/__openerp__.py 2013-05-07 13:44:26 +0000
26@@ -34,7 +34,10 @@
27 'website': 'http://www.openerp-italia.org',
28 'license': 'AGPL-3',
29 "depends" : ['account','base_vat','account_chart','base_iban', 'l10n_it_base'],
30- "init_xml" : ['account/partner_view.xml'],
31+ "init_xml": [
32+ 'account/partner_view.xml',
33+ 'wizard/fiscalcode_to_data_view.xml',
34+ ],
35 "update_xml" : [],
36 "demo_xml" : [],
37 "active": False,
38
39=== modified file 'l10n_it_account/i18n/it.po'
40--- l10n_it_account/i18n/it.po 2011-05-05 16:46:44 +0000
41+++ l10n_it_account/i18n/it.po 2013-05-07 13:44:26 +0000
42@@ -4,10 +4,10 @@
43 #
44 msgid ""
45 msgstr ""
46-"Project-Id-Version: OpenERP Server 6.0.2\n"
47-"Report-Msgid-Bugs-To: support@openerp.com\n"
48-"POT-Creation-Date: 2011-05-05 16:45+0000\n"
49-"PO-Revision-Date: 2011-05-05 16:45+0000\n"
50+"Project-Id-Version: OpenERP Server 6.1\n"
51+"Report-Msgid-Bugs-To: \n"
52+"POT-Creation-Date: 2013-05-07 13:39+0000\n"
53+"PO-Revision-Date: 2013-05-07 13:39+0000\n"
54 "Last-Translator: <>\n"
55 "Language-Team: \n"
56 "MIME-Version: 1.0\n"
57@@ -16,25 +16,83 @@
58 "Plural-Forms: \n"
59
60 #. module: l10n_it_account
61+#: field:res.partner,birth_date:0
62+msgid "Date of birth"
63+msgstr "Data di nascita"
64+
65+#. module: l10n_it_account
66+#: view:res.partner:0
67+#: field:res.partner,fiscalcode:0
68+msgid "Fiscal Code"
69+msgstr "Codice fiscale"
70+
71+#. module: l10n_it_account
72+#: view:res.partner:0
73+msgid "Compute Fiscal Code"
74+msgstr "Calcola Codice Fiscale"
75+
76+#. module: l10n_it_account
77+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:101
78+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:128
79+#, python-format
80+msgid "Invalid Fiscal code: %s"
81+msgstr "Codice Fiscale invalido: %s"
82+
83+#. module: l10n_it_account
84+#: field:res.partner,fiscalcode_firstname:0
85+msgid "First name"
86+msgstr "Nome"
87+
88+#. module: l10n_it_account
89+#: field:wizard.fiscalcode.to.data,relax_fc:0
90+msgid "Ignore invalid Fiscal Code"
91+msgstr "Ignora Codice Fiscale non valido"
92+
93+#. module: l10n_it_account
94+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:86
95+#, python-format
96+msgid "More than one city with cadaster code %s"
97+msgstr "Più di una città ha codice catastale %s"
98+
99+#. module: l10n_it_account
100+#: field:res.partner,birth_city:0
101+msgid "City of birth"
102+msgstr "Città di nascita"
103+
104+#. module: l10n_it_account
105 #: code:addons/l10n_it_account/account/invoice.py:45
106 #, python-format
107 msgid "Cannot create invoice! Post the invoice with a greater date"
108 msgstr "Impossibile registrare la fattura in contabilità! Esistono fatture registrate con data successiva alla fattura corrente; inserisci una data superiore per il documento"
109
110 #. module: l10n_it_account
111+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:77
112+#, python-format
113+msgid "City with cadaster code %s not found"
114+msgstr "Città con codice catastale %s non trovata"
115+
116+#. module: l10n_it_account
117 #: view:res.partner:0
118+#: view:wizard.fiscalcode.to.data:0
119 msgid "Compute"
120 msgstr "Calcola"
121
122 #. module: l10n_it_account
123-#: model:ir.model,name:l10n_it_account.model_account_invoice
124-msgid "Invoice"
125-msgstr "Fattura"
126-
127-#. module: l10n_it_account
128-#: field:res.partner,birth_date:0
129-msgid "Date of birth"
130-msgstr "Data di nascita"
131+#: selection:res.partner,sex:0
132+msgid "Female"
133+msgstr "Femmina"
134+
135+#. module: l10n_it_account
136+#: model:ir.actions.act_window,name:l10n_it_account.action_fiscalcode_to_data
137+#: model:ir.model,name:l10n_it_account.model_wizard_fiscalcode_to_data
138+#: view:wizard.fiscalcode.to.data:0
139+msgid "Compute missing data from Fiscal Code"
140+msgstr "Recupera i dati mancanti dal Codice Fiscale"
141+
142+#. module: l10n_it_account
143+#: field:wizard.fiscalcode.to.data,update_birth_city:0
144+msgid "Update city of birth"
145+msgstr "Aggiorna città di nascita"
146
147 #. module: l10n_it_account
148 #: view:res.partner:0
149@@ -42,22 +100,51 @@
150 msgstr "Note"
151
152 #. module: l10n_it_account
153-#: model:ir.module.module,description:l10n_it_account.module_meta_information
154-msgid "This module customizes OpenERP in order to fit italian laws and mores - Account version\n"
155-"\n"
156-"Functionalities:\n"
157-"\n"
158-"- Fiscal code computation for partner\n"
159-"- Check invoice date consistency\n"
160-"\n"
161-""
162-msgstr "Questo modulo personalizza OpenERP al fine di rispettare le leggi e le usanze italiane - Versione contabilità\n"
163-"Funzionalità:\n"
164-"\n"
165-"- Calcolo del codice fiscale sul partner\n"
166-"- Controllo della consistenza delle date delle fatture\n"
167-"\n"
168-""
169+#: field:wizard.fiscalcode.to.data,update_sex:0
170+msgid "Update sex"
171+msgstr "Aggiorna sesso"
172+
173+#. module: l10n_it_account
174+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:76
175+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:85
176+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:100
177+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:111
178+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:127
179+#, python-format
180+msgid "Error"
181+msgstr "Errore"
182+
183+#. module: l10n_it_account
184+#: selection:res.partner,sex:0
185+msgid "Male"
186+msgstr "Maschio"
187+
188+#. module: l10n_it_account
189+#: code:addons/l10n_it_account/account/invoice.py:44
190+#, python-format
191+msgid "Date Inconsistency"
192+msgstr "Inconsistenza nelle date"
193+
194+#. module: l10n_it_account
195+#: sql_constraint:account.invoice:0
196+msgid "Invoice Number must be unique per Company!"
197+msgstr "Nell'azienda il numero fattura dev'essere univoco!"
198+
199+#. module: l10n_it_account
200+#: field:res.partner,fiscalcode_surname:0
201+msgid "Surname"
202+msgstr "Cognome"
203+
204+#. module: l10n_it_account
205+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:112
206+#, python-format
207+msgid "Fiscal code %s: Invalid month code %s"
208+msgstr "Codice fiscale %s: Codice mese invalido %s"
209+
210+#. module: l10n_it_account
211+#: field:res.partner,sex:0
212+msgid "Sex"
213+msgstr "Sesso"
214
215 #. module: l10n_it_account
216 #: help:res.partner,fiscalcode:0
217@@ -65,35 +152,14 @@
218 msgstr "Codice Fiscale Italiano"
219
220 #. module: l10n_it_account
221-#: field:res.partner,sex:0
222-msgid "Sex"
223-msgstr "Sesso"
224-
225-#. module: l10n_it_account
226-#: field:res.partner,fiscalcode_surname:0
227-msgid "Surname"
228-msgstr "Cognome"
229-
230-#. module: l10n_it_account
231-#: field:res.partner,fiscalcode_firstname:0
232-msgid "First name"
233-msgstr "Nome"
234-
235-#. module: l10n_it_account
236-#: view:res.partner:0
237-#: field:res.partner,fiscalcode:0
238-msgid "Fiscal Code"
239-msgstr "Codice fiscale"
240-
241-#. module: l10n_it_account
242-#: model:ir.module.module,shortdesc:l10n_it_account.module_meta_information
243-msgid "Italian Localisation - Account"
244-msgstr "Localizzazione Italiana - Contabilità"
245-
246-#. module: l10n_it_account
247-#: selection:res.partner,sex:0
248-msgid "Female"
249-msgstr "Femmina"
250+#: model:ir.model,name:l10n_it_account.model_account_invoice
251+msgid "Invoice"
252+msgstr "Fattura"
253+
254+#. module: l10n_it_account
255+#: view:wizard.fiscalcode.to.data:0
256+msgid "Cancel"
257+msgstr "Annulla"
258
259 #. module: l10n_it_account
260 #: model:ir.model,name:l10n_it_account.model_res_partner
261@@ -101,23 +167,7 @@
262 msgstr "Partner"
263
264 #. module: l10n_it_account
265-#: view:res.partner:0
266-msgid "Compute Fiscal Code"
267-msgstr "Calcola codice fiscale"
268-
269-#. module: l10n_it_account
270-#: selection:res.partner,sex:0
271-msgid "Male"
272-msgstr "Maschio"
273-
274-#. module: l10n_it_account
275-#: code:addons/l10n_it_account/account/invoice.py:44
276-#, python-format
277-msgid "Date Inconsistency"
278-msgstr "Inconsistenza nelle date"
279-
280-#. module: l10n_it_account
281-#: field:res.partner,birth_city:0
282-msgid "City of birth"
283-msgstr "Città natale"
284+#: field:wizard.fiscalcode.to.data,update_birth_date:0
285+msgid "Update date of birth"
286+msgstr "Aggiorna data di nascita"
287
288
289=== modified file 'l10n_it_account/i18n/l10n_it_account.pot'
290--- l10n_it_account/i18n/l10n_it_account.pot 2011-05-05 16:46:44 +0000
291+++ l10n_it_account/i18n/l10n_it_account.pot 2013-05-07 13:44:26 +0000
292@@ -4,10 +4,10 @@
293 #
294 msgid ""
295 msgstr ""
296-"Project-Id-Version: OpenERP Server 6.0.2\n"
297-"Report-Msgid-Bugs-To: support@openerp.com\n"
298-"POT-Creation-Date: 2011-05-05 16:44+0000\n"
299-"PO-Revision-Date: 2011-05-05 16:44+0000\n"
300+"Project-Id-Version: OpenERP Server 6.1\n"
301+"Report-Msgid-Bugs-To: \n"
302+"POT-Creation-Date: 2013-05-07 13:38+0000\n"
303+"PO-Revision-Date: 2013-05-07 13:38+0000\n"
304 "Last-Translator: <>\n"
305 "Language-Team: \n"
306 "MIME-Version: 1.0\n"
307@@ -16,24 +16,82 @@
308 "Plural-Forms: \n"
309
310 #. module: l10n_it_account
311+#: field:res.partner,birth_date:0
312+msgid "Date of birth"
313+msgstr ""
314+
315+#. module: l10n_it_account
316+#: view:res.partner:0
317+#: field:res.partner,fiscalcode:0
318+msgid "Fiscal Code"
319+msgstr ""
320+
321+#. module: l10n_it_account
322+#: view:res.partner:0
323+msgid "Compute Fiscal Code"
324+msgstr ""
325+
326+#. module: l10n_it_account
327+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:101
328+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:128
329+#, python-format
330+msgid "Invalid Fiscal code: %s"
331+msgstr ""
332+
333+#. module: l10n_it_account
334+#: field:res.partner,fiscalcode_firstname:0
335+msgid "First name"
336+msgstr ""
337+
338+#. module: l10n_it_account
339+#: field:wizard.fiscalcode.to.data,relax_fc:0
340+msgid "Ignore invalid Fiscal Code"
341+msgstr ""
342+
343+#. module: l10n_it_account
344+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:86
345+#, python-format
346+msgid "More than one city with cadaster code %s"
347+msgstr ""
348+
349+#. module: l10n_it_account
350+#: field:res.partner,birth_city:0
351+msgid "City of birth"
352+msgstr ""
353+
354+#. module: l10n_it_account
355 #: code:addons/l10n_it_account/account/invoice.py:45
356 #, python-format
357 msgid "Cannot create invoice! Post the invoice with a greater date"
358 msgstr ""
359
360 #. module: l10n_it_account
361+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:77
362+#, python-format
363+msgid "City with cadaster code %s not found"
364+msgstr ""
365+
366+#. module: l10n_it_account
367 #: view:res.partner:0
368+#: view:wizard.fiscalcode.to.data:0
369 msgid "Compute"
370 msgstr ""
371
372 #. module: l10n_it_account
373-#: model:ir.model,name:l10n_it_account.model_account_invoice
374-msgid "Invoice"
375-msgstr ""
376-
377-#. module: l10n_it_account
378-#: field:res.partner,birth_date:0
379-msgid "Date of birth"
380+#: selection:res.partner,sex:0
381+msgid "Female"
382+msgstr ""
383+
384+#. module: l10n_it_account
385+#: model:ir.actions.act_window,name:l10n_it_account.action_fiscalcode_to_data
386+#: model:ir.model,name:l10n_it_account.model_wizard_fiscalcode_to_data
387+#: view:wizard.fiscalcode.to.data:0
388+msgid "Compute missing data from Fiscal Code"
389+msgstr ""
390+
391+#. module: l10n_it_account
392+#: field:wizard.fiscalcode.to.data,update_birth_city:0
393+msgid "Update city of birth"
394 msgstr ""
395
396 #. module: l10n_it_account
397@@ -42,15 +100,50 @@
398 msgstr ""
399
400 #. module: l10n_it_account
401-#: model:ir.module.module,description:l10n_it_account.module_meta_information
402-msgid "This module customizes OpenERP in order to fit italian laws and mores - Account version\n"
403-"\n"
404-"Functionalities:\n"
405-"\n"
406-"- Fiscal code computation for partner\n"
407-"- Check invoice date consistency\n"
408-"\n"
409-""
410+#: field:wizard.fiscalcode.to.data,update_sex:0
411+msgid "Update sex"
412+msgstr ""
413+
414+#. module: l10n_it_account
415+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:76
416+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:85
417+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:100
418+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:111
419+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:127
420+#, python-format
421+msgid "Error"
422+msgstr ""
423+
424+#. module: l10n_it_account
425+#: selection:res.partner,sex:0
426+msgid "Male"
427+msgstr ""
428+
429+#. module: l10n_it_account
430+#: code:addons/l10n_it_account/account/invoice.py:44
431+#, python-format
432+msgid "Date Inconsistency"
433+msgstr ""
434+
435+#. module: l10n_it_account
436+#: sql_constraint:account.invoice:0
437+msgid "Invoice Number must be unique per Company!"
438+msgstr ""
439+
440+#. module: l10n_it_account
441+#: field:res.partner,fiscalcode_surname:0
442+msgid "Surname"
443+msgstr ""
444+
445+#. module: l10n_it_account
446+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:112
447+#, python-format
448+msgid "Fiscal code %s: Invalid month code %s"
449+msgstr ""
450+
451+#. module: l10n_it_account
452+#: field:res.partner,sex:0
453+msgid "Sex"
454 msgstr ""
455
456 #. module: l10n_it_account
457@@ -59,34 +152,13 @@
458 msgstr ""
459
460 #. module: l10n_it_account
461-#: field:res.partner,sex:0
462-msgid "Sex"
463-msgstr ""
464-
465-#. module: l10n_it_account
466-#: field:res.partner,fiscalcode_surname:0
467-msgid "Surname"
468-msgstr ""
469-
470-#. module: l10n_it_account
471-#: field:res.partner,fiscalcode_firstname:0
472-msgid "First name"
473-msgstr ""
474-
475-#. module: l10n_it_account
476-#: view:res.partner:0
477-#: field:res.partner,fiscalcode:0
478-msgid "Fiscal Code"
479-msgstr ""
480-
481-#. module: l10n_it_account
482-#: model:ir.module.module,shortdesc:l10n_it_account.module_meta_information
483-msgid "Italian Localisation - Account"
484-msgstr ""
485-
486-#. module: l10n_it_account
487-#: selection:res.partner,sex:0
488-msgid "Female"
489+#: model:ir.model,name:l10n_it_account.model_account_invoice
490+msgid "Invoice"
491+msgstr ""
492+
493+#. module: l10n_it_account
494+#: view:wizard.fiscalcode.to.data:0
495+msgid "Cancel"
496 msgstr ""
497
498 #. module: l10n_it_account
499@@ -95,23 +167,7 @@
500 msgstr ""
501
502 #. module: l10n_it_account
503-#: view:res.partner:0
504-msgid "Compute Fiscal Code"
505-msgstr ""
506-
507-#. module: l10n_it_account
508-#: selection:res.partner,sex:0
509-msgid "Male"
510-msgstr ""
511-
512-#. module: l10n_it_account
513-#: code:addons/l10n_it_account/account/invoice.py:44
514-#, python-format
515-msgid "Date Inconsistency"
516-msgstr ""
517-
518-#. module: l10n_it_account
519-#: field:res.partner,birth_city:0
520-msgid "City of birth"
521+#: field:wizard.fiscalcode.to.data,update_birth_date:0
522+msgid "Update date of birth"
523 msgstr ""
524
525
526=== added directory 'l10n_it_account/wizard'
527=== added file 'l10n_it_account/wizard/__init__.py'
528--- l10n_it_account/wizard/__init__.py 1970-01-01 00:00:00 +0000
529+++ l10n_it_account/wizard/__init__.py 2013-05-07 13:44:26 +0000
530@@ -0,0 +1,22 @@
531+# -*- coding: utf-8 -*-
532+##############################################################################
533+#
534+# Copyright (C) 2012 Associazione OpenERP Italia
535+# (<http://www.openerp-italia.org>).
536+#
537+# This program is free software: you can redistribute it and/or modify
538+# it under the terms of the GNU Affero General Public License as published
539+# by the Free Software Foundation, either version 3 of the License, or
540+# (at your option) any later version.
541+#
542+# This program is distributed in the hope that it will be useful,
543+# but WITHOUT ANY WARRANTY; without even the implied warranty of
544+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
545+# GNU General Public License for more details.
546+#
547+# You should have received a copy of the GNU Affero General Public License
548+# along with this program. If not, see <http://www.gnu.org/licenses/>.
549+#
550+##############################################################################
551+
552+import fiscalcode_to_data
553
554=== added file 'l10n_it_account/wizard/fiscalcode_to_data.py'
555--- l10n_it_account/wizard/fiscalcode_to_data.py 1970-01-01 00:00:00 +0000
556+++ l10n_it_account/wizard/fiscalcode_to_data.py 2013-05-07 13:44:26 +0000
557@@ -0,0 +1,138 @@
558+# -*- coding: utf-8 -*-
559+##############################################################################
560+#
561+# Copyright (C) 2010-2012 Associazione OpenERP Italia
562+# (<http://www.openerp-italia.org>).
563+#
564+# This program is free software: you can redistribute it and/or modify
565+# it under the terms of the GNU Affero General Public License as published
566+# by the Free Software Foundation, either version 3 of the License, or
567+# (at your option) any later version.
568+#
569+# This program is distributed in the hope that it will be useful,
570+# but WITHOUT ANY WARRANTY; without even the implied warranty of
571+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
572+# GNU General Public License for more details.
573+#
574+# You should have received a copy of the GNU Affero General Public License
575+# along with this program. If not, see <http://www.gnu.org/licenses/>.
576+#
577+##############################################################################
578+
579+from osv import fields, osv
580+from tools.translate import _
581+from datetime import datetime
582+
583+
584+class wizard_fiscalcode_to_data(osv.osv_memory):
585+
586+ _name = "wizard.fiscalcode.to.data"
587+ _description = "Compute missing data from Fiscal Code"
588+ _columns = {
589+ 'update_birth_date': fields.boolean('Update date of birth'),
590+ 'update_birth_city': fields.boolean('Update city of birth'),
591+ 'update_sex': fields.boolean('Update sex'),
592+ 'relax_fc': fields.boolean('Ignore invalid Fiscal Code'),
593+ }
594+
595+ _defaults = {
596+ 'update_birth_date': True,
597+ 'update_birth_city': True,
598+ 'update_sex': True,
599+ }
600+
601+ def compute(self, cr, uid, ids, context):
602+ partner_obj = self.pool.get('res.partner')
603+ city_obj = self.pool.get('res.city')
604+ # leading space so that position is the month number
605+ month_codes = ' ABCDEHLMPRST'
606+ for wiz in self.browse(cr, uid, ids):
607+ for partner in partner_obj.browse(cr, uid, context['active_ids']):
608+ if partner.fiscalcode and len(partner.fiscalcode) == 16:
609+ # maybe check fiscalcode sanity here?
610+ data = {}
611+ fc = partner.fiscalcode.upper()
612+ if wiz.update_sex and not partner.sex:
613+ try:
614+ day = int(fc[9:11])
615+ except Exception:
616+ ### XXX handle insane fc here
617+ if wiz.relax_fc:
618+ continue
619+ else:
620+ raise
621+ sex = day > 40 and 'F' or 'M'
622+ data['sex'] = sex
623+ if wiz.update_birth_city and not partner.birth_city:
624+ cadaster_code = fc[11:15]
625+ birth_city = city_obj.search(cr, uid, [
626+ ('cadaster_code', '=', cadaster_code)
627+ ])
628+ if not birth_city:
629+ if wiz.relax_fc:
630+ continue
631+ else:
632+ raise osv.except_osv(
633+ _('Error'),
634+ _('City with cadaster code %s not found')
635+ % cadaster_code
636+ )
637+ if len(birth_city) > 1:
638+ if wiz.relax_fc:
639+ continue
640+ else:
641+ raise osv.except_osv(
642+ _('Error'),
643+ _('More than one city '
644+ 'with cadaster code %s')
645+ % cadaster_code
646+ )
647+ data['birth_city'] = birth_city[0]
648+ if wiz.update_birth_date:
649+ try:
650+ year = int(fc[6:8])
651+ day = int(fc[9:11])
652+ except ValueError:
653+ if wiz.relax_fc:
654+ continue
655+ else:
656+ raise osv.except_osv(
657+ _('Error'),
658+ _('Invalid Fiscal code: %s')
659+ % (fc)
660+ )
661+ day = day > 40 and day - 40 or day
662+ month = month_codes.find(fc[8])
663+ if month == -1:
664+ if wiz.relax_fc:
665+ continue
666+ else:
667+ raise osv.except_osv(
668+ _('Error'),
669+ _('Fiscal code %s: Invalid month code %s')
670+ % (fc, fc[8])
671+ )
672+
673+ # Don't format the date string directly to work out
674+ # the century
675+ try:
676+ d = datetime.strptime(
677+ '{}{}{}'.format(year, month, day), '%y%m%d'
678+ )
679+ except ValueError:
680+ if wiz.relax_fc:
681+ continue
682+ else:
683+ raise osv.except_osv(
684+ _('Error'),
685+ _('Invalid Fiscal code: %s')
686+ % (fc)
687+ )
688+
689+ if d > datetime.now():
690+ d = datetime(d.year - 100, d.month, d.day)
691+ data['birth_date'] = d.strftime('%Y-%m-%d')
692+ if data:
693+ partner_obj.write(cr, uid, partner.id, data)
694+
695+ return {}
696
697=== added file 'l10n_it_account/wizard/fiscalcode_to_data_view.xml'
698--- l10n_it_account/wizard/fiscalcode_to_data_view.xml 1970-01-01 00:00:00 +0000
699+++ l10n_it_account/wizard/fiscalcode_to_data_view.xml 2013-05-07 13:44:26 +0000
700@@ -0,0 +1,32 @@
701+<openerp>
702+ <data>
703+
704+ <record id="view_wizard_fiscalcode_to_data" model="ir.ui.view">
705+ <field name="name">Compute missing data from Fiscal Code</field>
706+ <field name="model">wizard.fiscalcode.to.data</field>
707+ <field name="type">form</field>
708+ <field name="arch" type="xml">
709+ <form string="Compute missing data from Fiscal Code">
710+ <group colspan="4" col="6">
711+ <field name="update_birth_date"/>
712+ <field name="update_birth_city"/>
713+ <field name="update_sex"/>
714+ </group>
715+ <field name="relax_fc"/>
716+ <newline/>
717+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
718+ <button name="compute" string="Compute" type="object" icon="gtk-ok"/>
719+ </form>
720+ </field>
721+ </record>
722+
723+ <act_window name="Compute missing data from Fiscal Code"
724+ res_model="wizard.fiscalcode.to.data"
725+ src_model="res.partner"
726+ view_mode="form"
727+ target="new"
728+ key2="client_action_multi"
729+ id="action_fiscalcode_to_data"/>
730+
731+ </data>
732+</openerp>
733\ No newline at end of file

Subscribers

People subscribed via source and target branches