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

Proposed by Leonardo Pistone
Status: Rejected
Rejected by: Leonardo Pistone
Proposed branch: lp:~lepistone/openobject-italia/6.1-fiscalcode-to-data-lep
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons-6.1
Diff against target: 677 lines (+351/-73)
9 files modified
l10n_it_fiscalcode/__openerp__.py (+11/-7)
l10n_it_fiscalcode/fiscalcode.py (+26/-12)
l10n_it_fiscalcode/fiscalcode_view.xml (+3/-0)
l10n_it_fiscalcode/i18n/it.po (+77/-6)
l10n_it_fiscalcode/wizard/__init__.py (+3/-3)
l10n_it_fiscalcode/wizard/compute_fc.py (+73/-43)
l10n_it_fiscalcode/wizard/compute_fc_view.xml (+26/-2)
l10n_it_fiscalcode/wizard/fiscalcode_to_data.py (+102/-0)
l10n_it_fiscalcode/wizard/fiscalcode_to_data_view.xml (+30/-0)
To merge this branch: bzr merge lp:~lepistone/openobject-italia/6.1-fiscalcode-to-data-lep
Reviewer Review Type Date Requested Status
Leonardo Pistone (community) Needs Resubmitting
Lorenzo Battistini Needs Fixing
Review via email: mp+162736@code.launchpad.net

Description of the change

http://www.openerp-italia.org/index.php/kunena/25-localizzazione/11326-calcolo-dati-mancanti-dal-cf

Fatto così aggiungo la funzionalità (più i campi data e luogo di nascita e sesso) al modulo l10n_it_fiscalcode. In alternativa potrebbe essere un modulo a parte.

Cosa ne pensate?

To post a comment you must log in.
Revision history for this message
Lorenzo Battistini (elbati) wrote :

In 6.1 quei campi (insieme al calcolo del CF) sono presenti in 'l10n_it_account'. (Nota: il calcolo del CF è duplicato in 'l10n_it_fiscalcode')

Quindi volendo introdurre questa funzionalità in 6.1, si potrebbe aggiungere a 'l10n_it_account' (deprecato in 7.0).

Per la 7 bisognerà fare un discorso diverso.

In generale non introdurrei nuove funzionalità solo in 6.1, senza farlo anche per 7.0.

Per la 7.0, che attualmente non ha moduli che aggiungono data di nascita, città di nascita e sesso, sarebbe probabilmente da fare un modulo a parte.

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

Sono d'accordo. Nuovo branch, nuova MP:

https://code.launchpad.net/~lpistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-lep/+merge/162763

cancello quindi questa

> Quindi volendo introdurre questa funzionalità in 6.1, si potrebbe aggiungere a
> 'l10n_it_account' (deprecato in 7.0).

review: Needs Resubmitting

Unmerged revisions

234. By Leonardo Pistone

[imp] fiscalcode to data: it.po

233. By Leonardo Pistone

[imp] fiscalcode to data: compute birthday

232. By Leonardo Pistone

[imp] compute birth city and sex from fiscal code. birth date not done yet

231. By Leonardo Pistone

[ref] cleanup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'l10n_it_fiscalcode/__openerp__.py'
--- l10n_it_fiscalcode/__openerp__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_fiscalcode/__openerp__.py 2013-05-07 09:35:16 +0000
@@ -33,16 +33,20 @@
33 'author': 'OpenERP Italian Community',33 'author': 'OpenERP Italian Community',
34 'website': 'http://www.openerp-italia.org',34 'website': 'http://www.openerp-italia.org',
35 'license': 'AGPL-3',35 'license': 'AGPL-3',
36 "depends" : ['base', 'l10n_it_base'],36 "depends": [
37 "init_xml" : [37 'base',
38 'l10n_it_base'
39 ],
40 "init_xml": [
38 'fiscalcode_view.xml',41 'fiscalcode_view.xml',
39 'wizard/compute_fc_view.xml'42 'wizard/compute_fc_view.xml',
40 ],43 'wizard/fiscalcode_to_data_view.xml'
41 "update_xml" : [],44 ],
42 "demo_xml" : [],45 "update_xml": [],
46 "demo_xml": [],
43 'test': [47 'test': [
44 'test/fiscalcode.yml',48 'test/fiscalcode.yml',
45 ],49 ],
46 "active": False,50 "active": False,
47 "installable": True51 "installable": True
48}52}
4953
=== modified file 'l10n_it_fiscalcode/fiscalcode.py'
--- l10n_it_fiscalcode/fiscalcode.py 2013-01-04 14:02:10 +0000
+++ l10n_it_fiscalcode/fiscalcode.py 2013-05-07 09:35:16 +0000
@@ -5,8 +5,8 @@
5# (<http://www.openerp-italia.org>).5# (<http://www.openerp-italia.org>).
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published by8# it under the terms of the GNU Affero General Public License as published
9# the Free Software Foundation, either version 3 of the License, or9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.10# (at your option) any later version.
11#11#
12# This program is distributed in the hope that it will be useful,12# This program is distributed in the hope that it will be useful,
@@ -20,10 +20,7 @@
20##############################################################################20##############################################################################
2121
22from osv import fields, osv22from osv import fields, osv
23import tools23
24import pooler
25from tools.translate import _
26import datetime
2724
28class res_partner(osv.osv):25class res_partner(osv.osv):
29 _inherit = 'res.partner'26 _inherit = 'res.partner'
@@ -39,13 +36,30 @@
39 return True36 return True
4037
41 _columns = {38 _columns = {
42 'fiscalcode': fields.char('Fiscal Code', size=16, help="Italian Fiscal Code"),39 'fiscalcode': fields.char(
43 'individual': fields.boolean('Individual', help="If checked the C.F. is referred to a Individual Person"),40 'Fiscal Code', size=16, help="Italian Fiscal Code"
41 ),
42 'individual': fields.boolean(
43 'Individual',
44 help="If checked the C.F. is referred to a Individual Person"
45 ),
46 'birth_date': fields.date('Date of birth'),
47 'birth_city': fields.many2one('res.city', 'City of birth'),
48 'sex': fields.selection([
49 ('M', 'Male'),
50 ('F', 'Female'),
51 ], "Sex"),
44 }52 }
45 _defaults = {53 _defaults = {
46 'individual': False,54 'individual': False,
47 }55 }
48 _constraints = [(check_fiscalcode, "The fiscal code doesn't seem to be correct.", ["fiscalcode"])]56 _constraints = [(
49 _sql_constraints = [57 check_fiscalcode,
50 ('fiscalcode_uniq', 'unique (fiscalcode, company_id)', 'The fiscal code must be unique per company !'),58 "The fiscal code doesn't seem to be correct.",
51 ]59 ["fiscalcode"]
60 )]
61 _sql_constraints = [(
62 'fiscalcode_uniq',
63 'unique (fiscalcode, company_id)',
64 'The fiscal code must be unique per company !'
65 ), ]
5266
=== modified file 'l10n_it_fiscalcode/fiscalcode_view.xml'
--- l10n_it_fiscalcode/fiscalcode_view.xml 2012-10-22 09:23:35 +0000
+++ l10n_it_fiscalcode/fiscalcode_view.xml 2013-05-07 09:35:16 +0000
@@ -11,6 +11,9 @@
11 <separator string="Fiscal Data" colspan="6"/>11 <separator string="Fiscal Data" colspan="6"/>
12 <field name="fiscalcode"/>12 <field name="fiscalcode"/>
13 <field name="individual" colspan="1" groups="base.group_extended" />13 <field name="individual" colspan="1" groups="base.group_extended" />
14 <field name="birth_date"/>
15 <field name="birth_city"/>
16 <field name="sex"/>
14 </field>17 </field>
15 </field>18 </field>
16 </record>19 </record>
1720
=== modified file 'l10n_it_fiscalcode/i18n/it.po'
--- l10n_it_fiscalcode/i18n/it.po 2012-12-05 10:03:52 +0000
+++ l10n_it_fiscalcode/i18n/it.po 2013-05-07 09:35:16 +0000
@@ -6,13 +6,13 @@
6msgstr ""6msgstr ""
7"Project-Id-Version: OpenERP Server 6.1\n"7"Project-Id-Version: OpenERP Server 6.1\n"
8"Report-Msgid-Bugs-To: \n"8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2012-12-05 10:00+0000\n"9"POT-Creation-Date: 2013-05-07 09:23+0000\n"
10"PO-Revision-Date: 2012-12-05 11:02+0100\n"10"PO-Revision-Date: 2013-05-07 09:23+0000\n"
11"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"11"Last-Translator: <>\n"
12"Language-Team: \n"12"Language-Team: \n"
13"MIME-Version: 1.0\n"13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"16"Plural-Forms: \n"
1717
18#. module: l10n_it_fiscalcode18#. module: l10n_it_fiscalcode
@@ -21,6 +21,12 @@
21msgstr "Se selezionato il Cofice Fiscale farà riferimento a quello di una Persona Fisica"21msgstr "Se selezionato il Cofice Fiscale farà riferimento a quello di una Persona Fisica"
2222
23#. module: l10n_it_fiscalcode23#. module: l10n_it_fiscalcode
24#: view:partner.sms.send:0
25msgid "SMS - Gateway: clickatell"
26msgstr "SMS - Gateway: clickatell"
27
28#. module: l10n_it_fiscalcode
29#: field:res.partner,birth_date:0
24#: field:wizard.compute.fc,birth_date:030#: field:wizard.compute.fc,birth_date:0
25msgid "Date of birth"31msgid "Date of birth"
26msgstr "Data di nascita"32msgstr "Data di nascita"
@@ -38,6 +44,11 @@
38msgstr "Calcola il Codice Fiscale"44msgstr "Calcola il Codice Fiscale"
3945
40#. module: l10n_it_fiscalcode46#. module: l10n_it_fiscalcode
47#: view:partner.sms.send:0
48msgid "Bulk SMS send"
49msgstr "Invio SMS di massa"
50
51#. module: l10n_it_fiscalcode
41#: field:wizard.compute.fc,fiscalcode_firstname:052#: field:wizard.compute.fc,fiscalcode_firstname:0
42msgid "First name"53msgid "First name"
43msgstr "Nome"54msgstr "Nome"
@@ -53,38 +64,83 @@
53msgstr "Dati Fiscali"64msgstr "Dati Fiscali"
5465
55#. module: l10n_it_fiscalcode66#. module: l10n_it_fiscalcode
67#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:75
68#, python-format
69msgid "More than one city with cadaster code %s"
70msgstr "Più di una città ha il codice catastale %s"
71
72#. module: l10n_it_fiscalcode
73#: field:res.partner,birth_city:0
56#: field:wizard.compute.fc,birth_city:074#: field:wizard.compute.fc,birth_city:0
57msgid "City of birth"75msgid "City of birth"
58msgstr "Città di Nascita"76msgstr "Città di Nascita"
5977
60#. module: l10n_it_fiscalcode78#. module: l10n_it_fiscalcode
79#: view:partner.sms.send:0
80msgid "Send SMS"
81msgstr "Invia SMS"
82
83#. module: l10n_it_fiscalcode
84#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:69
85#, python-format
86msgid "City with cadaster code %s not found"
87msgstr "Città con codice catastale %s non trovata"
88
89#. module: l10n_it_fiscalcode
61#: view:wizard.compute.fc:090#: view:wizard.compute.fc:0
91#: view:wizard.fiscalcode.to.data:0
62msgid "Compute"92msgid "Compute"
63msgstr "Calcola"93msgstr "Calcola"
6494
65#. module: l10n_it_fiscalcode95#. module: l10n_it_fiscalcode
96#: model:ir.actions.act_window,name:l10n_it_fiscalcode.action_fiscalcode_to_data
97#: model:ir.model,name:l10n_it_fiscalcode.model_wizard_fiscalcode_to_data
98#: view:wizard.fiscalcode.to.data:0
99msgid "Compute missing data from Fiscal Code"
100msgstr "Ricava i dati mancanti dal Codice Fiscale"
101
102#. module: l10n_it_fiscalcode
103#: field:wizard.fiscalcode.to.data,update_birth_city:0
104msgid "Update city of birth"
105msgstr "Aggiorna la città di nascita"
106
107#. module: l10n_it_fiscalcode
66#: constraint:res.partner:0108#: constraint:res.partner:0
67msgid "The fiscal code doesn't seem to be correct."109msgid "The fiscal code doesn't seem to be correct."
68msgstr "Il Codice Fiscale non sembra corretto per una Persona Fisica."110msgstr "Il Codice Fiscale non sembra corretto per una Persona Fisica."
69111
70#. module: l10n_it_fiscalcode112#. module: l10n_it_fiscalcode
113#: field:wizard.fiscalcode.to.data,update_sex:0
114msgid "Update sex"
115msgstr "Aggiorna il sesso"
116
117#. module: l10n_it_fiscalcode
71#: sql_constraint:res.partner:0118#: sql_constraint:res.partner:0
72msgid "The fiscal code must be unique per company !"119msgid "The fiscal code must be unique per company !"
73msgstr "Il codice fiscale deve essere unico!"120msgstr "Il codice fiscale deve essere unico!"
74121
75#. module: l10n_it_fiscalcode122#. module: l10n_it_fiscalcode
76#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:126123#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:148
124#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:68
125#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:74
126#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:86
77#, python-format127#, python-format
78msgid "Error"128msgid "Error"
79msgstr "Errore"129msgstr "Errore"
80130
81#. module: l10n_it_fiscalcode131#. module: l10n_it_fiscalcode
132#: selection:res.partner,sex:0
82#: selection:wizard.compute.fc,sex:0133#: selection:wizard.compute.fc,sex:0
83msgid "Male"134msgid "Male"
84msgstr "Maschio"135msgstr "Maschio"
85136
86#. module: l10n_it_fiscalcode137#. module: l10n_it_fiscalcode
87#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:126138#: view:partner.sms.send:0
139msgid "Message"
140msgstr "Message"
141
142#. module: l10n_it_fiscalcode
143#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:149
88#, python-format144#, python-format
89msgid "Existing fiscal code %s is different from the computed one (%s). If you want to use the computed one, remove the existing one"145msgid "Existing fiscal code %s is different from the computed one (%s). If you want to use the computed one, remove the existing one"
90msgstr "Il codice fiscale sistente %s è diverso da quello calcolato (%s). Se si vuole usare quello calcolato, rimuovere quello esistente."146msgstr "Il codice fiscale sistente %s è diverso da quello calcolato (%s). Se si vuole usare quello calcolato, rimuovere quello esistente."
@@ -95,6 +151,13 @@
95msgstr "Cognome"151msgstr "Cognome"
96152
97#. module: l10n_it_fiscalcode153#. module: l10n_it_fiscalcode
154#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:87
155#, python-format
156msgid "Fiscal code %s: Invalid month code %s"
157msgstr "Codice Fiscale %s: Codice mese invalido %s"
158
159#. module: l10n_it_fiscalcode
160#: field:res.partner,sex:0
98#: field:wizard.compute.fc,sex:0161#: field:wizard.compute.fc,sex:0
99msgid "Sex"162msgid "Sex"
100msgstr "Sesso"163msgstr "Sesso"
@@ -110,12 +173,15 @@
110msgstr "Persona Fisica"173msgstr "Persona Fisica"
111174
112#. module: l10n_it_fiscalcode175#. module: l10n_it_fiscalcode
176#: selection:res.partner,sex:0
113#: selection:wizard.compute.fc,sex:0177#: selection:wizard.compute.fc,sex:0
114msgid "Female"178msgid "Female"
115msgstr "Femmina"179msgstr "Femmina"
116180
117#. module: l10n_it_fiscalcode181#. module: l10n_it_fiscalcode
182#: view:partner.sms.send:0
118#: view:wizard.compute.fc:0183#: view:wizard.compute.fc:0
184#: view:wizard.fiscalcode.to.data:0
119msgid "Cancel"185msgid "Cancel"
120msgstr "Annulla"186msgstr "Annulla"
121187
@@ -129,3 +195,8 @@
129msgid "Compute F.C."195msgid "Compute F.C."
130msgstr "Calcola C.F."196msgstr "Calcola C.F."
131197
198#. module: l10n_it_fiscalcode
199#: field:wizard.fiscalcode.to.data,update_birth_date:0
200msgid "Update date of birth"
201msgstr "Aggiorna la data di nascita"
202
132203
=== modified file 'l10n_it_fiscalcode/wizard/__init__.py'
--- l10n_it_fiscalcode/wizard/__init__.py 2013-01-04 14:02:10 +0000
+++ l10n_it_fiscalcode/wizard/__init__.py 2013-05-07 09:35:16 +0000
@@ -5,8 +5,8 @@
5# (<http://www.openerp-italia.org>).5# (<http://www.openerp-italia.org>).
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published by8# it under the terms of the GNU Affero General Public License as published
9# the Free Software Foundation, either version 3 of the License, or9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.10# (at your option) any later version.
11#11#
12# This program is distributed in the hope that it will be useful,12# This program is distributed in the hope that it will be useful,
@@ -20,4 +20,4 @@
20##############################################################################20##############################################################################
2121
22import compute_fc22import compute_fc
2323import fiscalcode_to_data
2424
=== modified file 'l10n_it_fiscalcode/wizard/compute_fc.py'
--- l10n_it_fiscalcode/wizard/compute_fc.py 2013-01-04 14:02:10 +0000
+++ l10n_it_fiscalcode/wizard/compute_fc.py 2013-05-07 09:35:16 +0000
@@ -5,8 +5,8 @@
5# (<http://www.openerp-italia.org>).5# (<http://www.openerp-italia.org>).
6#6#
7# This program is free software: you can redistribute it and/or modify7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published by8# it under the terms of the GNU Affero General Public License as published
9# the Free Software Foundation, either version 3 of the License, or9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.10# (at your option) any later version.
11#11#
12# This program is distributed in the hope that it will be useful,12# This program is distributed in the hope that it will be useful,
@@ -20,12 +20,11 @@
20##############################################################################20##############################################################################
2121
22from osv import fields, osv22from osv import fields, osv
23import tools
24import pooler
25from tools.translate import _23from tools.translate import _
2624
27import datetime25import datetime
2826
27
29class wizard_compute_fc(osv.osv_memory):28class wizard_compute_fc(osv.osv_memory):
3029
31 _name = "wizard.compute.fc"30 _name = "wizard.compute.fc"
@@ -35,13 +34,14 @@
35 'fiscalcode_firstname': fields.char('First name', size=64),34 'fiscalcode_firstname': fields.char('First name', size=64),
36 'birth_date': fields.date('Date of birth'),35 'birth_date': fields.date('Date of birth'),
37 'birth_city': fields.many2one('res.city', 'City of birth'),36 'birth_city': fields.many2one('res.city', 'City of birth'),
38 'sex': fields.selection([('M','Male'),37 'sex': fields.selection([
39 ('F', 'Female'),38 ('M', 'Male'),
40 ], "Sex"),39 ('F', 'Female')
40 ], "Sex"),
41 }41 }
4242
4343 def _codicefiscale(self, cognome, nome, giornonascita, mesenascita,
44 def _codicefiscale(self, cognome, nome, giornonascita, mesenascita, annonascita, sesso, cittanascita):44 annonascita, sesso, cittanascita):
4545
46 MESI = 'ABCDEHLMPRST'46 MESI = 'ABCDEHLMPRST'
47 CONSONANTI = 'BCDFGHJKLMNPQRSTVWXYZ'47 CONSONANTI = 'BCDFGHJKLMNPQRSTVWXYZ'
@@ -49,48 +49,53 @@
49 LETTERE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'49 LETTERE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
5050
51 REGOLECONTROLLO = {51 REGOLECONTROLLO = {
52 'A':(0,1), 'B':(1,0), 'C':(2,5), 'D':(3,7), 'E':(4,9),52 'A': (0, 1), 'B': (1, 0), 'C': (2, 5), 'D': (3, 7), 'E': (4, 9),
53 'F':(5,13), 'G':(6,15), 'H':(7,17), 'I':(8,19), 'J':(9,21),53 'F': (5, 13), 'G': (6, 15), 'H': (7, 17), 'I': (8, 19),
54 'K':(10,2), 'L':(11,4), 'M':(12,18), 'N':(13,20), 'O':(14,11),54 'J': (9, 21), 'K': (10, 2), 'L': (11, 4), 'M': (12, 18),
55 'P':(15,3), 'Q':(16,6), 'R':(17,8), 'S':(18,12), 'T':(19,14),55 'N': (13, 20), 'O': (14, 11), 'P': (15, 3), 'Q': (16, 6),
56 'U':(20,16), 'V':(21,10), 'W':(22,22), 'X':(23,25), 'Y':(24,24),56 'R': (17, 8), 'S': (18, 12), 'T': (19, 14), 'U': (20, 16),
57 'Z':(25,23),57 'V': (21, 10), 'W': (22, 22), 'X': (23, 25), 'Y': (24, 24),
58 '0':(0,1), '1':(1,0), '2':(2,5), '3':(3,7), '4':(4,9),58 'Z': (25, 23),
59 '5':(5,13), '6':(6,15), '7':(7,17), '8':(8,19), '9':(9,21)59 '0': (0, 1), '1': (1, 0), '2': (2, 5), '3': (3, 7), '4': (4, 9),
60 '5': (5, 13), '6': (6, 15), '7': (7, 17), '8': (8, 19),
61 '9': (9, 21)
60 }62 }
6163
62 """Funzioni per il calcolo del C.F."""64 """Funzioni per il calcolo del C.F."""
63 def _surname(stringa):65 def _surname(stringa):
64 """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""66 """Ricava, da stringa, 3 lettere in base alla convenzione dei
67 C.F."""
65 cons = [c for c in stringa if c in CONSONANTI]68 cons = [c for c in stringa if c in CONSONANTI]
66 voc = [c for c in stringa if c in VOCALI]69 voc = [c for c in stringa if c in VOCALI]
67 chars=cons+voc70 chars = cons + voc
68 if len(chars)<3:71 if len(chars) < 3:
69 chars+=['X', 'X']72 chars += ['X', 'X']
70 return chars[:3]73 return chars[:3]
7174
72 def _name(stringa):75 def _name(stringa):
73 """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""76 """Ricava, da stringa, 3 lettere in base alla convenzione dei
77 C.F."""
74 cons = [c for c in stringa if c in CONSONANTI]78 cons = [c for c in stringa if c in CONSONANTI]
75 voc = [c for c in stringa if c in VOCALI]79 voc = [c for c in stringa if c in VOCALI]
76 if len(cons)>3:80 if len(cons) > 3:
77 cons = [cons[0]] +[cons[2]] + [cons[3]]81 cons = [cons[0]] + [cons[2]] + [cons[3]]
78 chars=cons+voc82 chars = cons + voc
79 if len(chars)<3:83 if len(chars) < 3:
80 chars+=['X', 'X']84 chars += ['X', 'X']
81 return chars[:3]85 return chars[:3]
8286
83 def _datan(giorno, mese, anno, sesso):87 def _datan(giorno, mese, anno, sesso):
84 """Restituisce il campo data del CF."""88 """Restituisce il campo data del CF."""
85 chars = (list(anno[-2:]) + [MESI[int(mese)-1]])89 chars = (list(anno[-2:]) + [MESI[int(mese) - 1]])
86 gn=int(giorno)90 gn = int(giorno)
87 if sesso=='F':91 if sesso == 'F':
88 gn+=4092 gn += 40
89 chars += list("%02d" % gn)93 chars += list("%02d" % gn)
90 return chars94 return chars
9195
92 def _codicecontrollo(c):96 def _codicecontrollo(c):
93 """Restituisce il codice di controllo, l'ultimo carattere del C.F."""97 """Restituisce il codice di controllo, l'ultimo carattere del
98 C.F."""
94 sommone = 099 sommone = 0
95 for i, car in enumerate(c):100 for i, car in enumerate(c):
96 j = 1 - i % 2101 j = 1 - i % 2
@@ -99,9 +104,9 @@
99 return [LETTERE[resto]]104 return [LETTERE[resto]]
100105
101 """Restituisce il C.F costruito sulla base degli argomenti."""106 """Restituisce il C.F costruito sulla base degli argomenti."""
102 nome=nome.upper()107 nome = nome.upper()
103 cognome=cognome.upper()108 cognome = cognome.upper()
104 sesso=sesso.upper()109 sesso = sesso.upper()
105 cittanascita = cittanascita.upper()110 cittanascita = cittanascita.upper()
106 chars = (_surname(cognome) +111 chars = (_surname(cognome) +
107 _name(nome) +112 _name(nome) +
@@ -112,16 +117,41 @@
112117
113 def compute_fc(self, cr, uid, ids, context):118 def compute_fc(self, cr, uid, ids, context):
114 active_id = context.get('active_id', [])119 active_id = context.get('active_id', [])
115 partner = self.pool.get('res.partner').browse(cr, uid, active_id, context)120 partner = self.pool.get('res.partner').browse(
121 cr, uid, active_id, context
122 )
116 form_obj = self.browse(cr, uid, ids, context)123 form_obj = self.browse(cr, uid, ids, context)
117 for fields in form_obj:124 for fields in form_obj:
118 if not fields.fiscalcode_surname or not fields.fiscalcode_firstname or not fields.birth_date or not fields.birth_city or not fields.sex:125 if (
126 not fields.fiscalcode_surname or
127 not fields.fiscalcode_firstname or
128 not fields.birth_date or
129 not fields.birth_city or
130 not fields.sex
131 ):
119 raise osv.except_osv('Error', 'One or more fields are missing')132 raise osv.except_osv('Error', 'One or more fields are missing')
120 birth_date = datetime.datetime.strptime(fields.birth_date, "%Y-%m-%d")133 birth_date = datetime.datetime.strptime(
121 CF = self._codicefiscale(fields.fiscalcode_surname, fields.fiscalcode_firstname, str(birth_date.day),134 fields.birth_date,
122 str(birth_date.month), str(birth_date.year), fields.sex,135 "%Y-%m-%d"
123 fields.birth_city.cadaster_code)136 )
137 CF = self._codicefiscale(
138 fields.fiscalcode_surname,
139 fields.fiscalcode_firstname,
140 str(birth_date.day),
141 str(birth_date.month),
142 str(birth_date.year),
143 fields.sex,
144 fields.birth_city.cadaster_code
145 )
124 if partner.fiscalcode and partner.fiscalcode != CF:146 if partner.fiscalcode and partner.fiscalcode != CF:
125 raise osv.except_osv(_('Error'), _('Existing fiscal code %s is different from the computed one (%s). If you want to use the computed one, remove the existing one') % (partner.fiscalcode, CF))147 raise osv.except_osv(
126 self.pool.get('res.partner').write(cr, uid, active_id, {'fiscalcode': CF, 'individual': True})148 _('Error'),
149 _('Existing fiscal code %s is different from the '
150 'computed one (%s). If you want to use the computed '
151 'one, remove the existing one') %
152 (partner.fiscalcode, CF))
153 self.pool.get('res.partner').write(cr, uid, active_id, {
154 'fiscalcode': CF,
155 'individual': True
156 })
127 return {}157 return {}
128158
=== modified file 'l10n_it_fiscalcode/wizard/compute_fc_view.xml'
--- l10n_it_fiscalcode/wizard/compute_fc_view.xml 2012-10-22 09:23:35 +0000
+++ l10n_it_fiscalcode/wizard/compute_fc_view.xml 2013-05-07 09:35:16 +0000
@@ -1,6 +1,6 @@
1<?xml version="1.0" ?>1<?xml version="1.0" ?>
2<openerp>2<openerp>
3 <data>3 <data>
44
5 <record id="wizard_compute_fc_form" model="ir.ui.view">5 <record id="wizard_compute_fc_form" model="ir.ui.view">
6 <field name="name">wizard.compute.fc.form</field>6 <field name="name">wizard.compute.fc.form</field>
@@ -46,5 +46,29 @@
46 </field>46 </field>
47 </record>47 </record>
4848
49 </data>49<!-- Create Menu From view -->
50
51 <record id="view_partner_sms_send" model="ir.ui.view">
52 <field name="name">Send SMS</field>
53 <field name="model">partner.sms.send</field>
54 <field name="type">form</field>
55 <field name="arch" type="xml">
56 <form string="SMS - Gateway: clickatell">
57 <separator string="Bulk SMS send" colspan="4"/>
58 <field name="mobile_to"/>
59 <field name="app_id"/>
60 <field name="user"/>
61 <field name="password"/>
62 <separator string="Message" colspan="4" />
63 <field name="text" colspan="4" nolabel="1"/>
64 <separator string="" colspan="4" />
65 <group colspan="4" col="6">
66 <button special="cancel" string="Cancel" icon="gtk-cancel"/>
67 <button name="sms_send" string="Send SMS" type="object" icon="terp-mail-message-new"/>
68 </group>
69 </form>
70 </field>
71 </record>
72
73 </data>
50</openerp>74</openerp>
5175
=== added file 'l10n_it_fiscalcode/wizard/fiscalcode_to_data.py'
--- l10n_it_fiscalcode/wizard/fiscalcode_to_data.py 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/wizard/fiscalcode_to_data.py 2013-05-07 09:35:16 +0000
@@ -0,0 +1,102 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Copyright (C) 2010-2012 Associazione OpenERP Italia
5# (<http://www.openerp-italia.org>).
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as published
9# by the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20##############################################################################
21
22from osv import fields, osv
23from tools.translate import _
24from datetime import datetime
25
26
27class wizard_fiscalcode_to_data(osv.osv_memory):
28
29 _name = "wizard.fiscalcode.to.data"
30 _description = "Compute missing data from Fiscal Code"
31 _columns = {
32 'update_birth_date': fields.boolean('Update date of birth'),
33 'update_birth_city': fields.boolean('Update city of birth'),
34 'update_sex': fields.boolean('Update sex'),
35 }
36
37 _defaults = {
38 'update_birth_date': True,
39 'update_birth_city': True,
40 'update_sex': True,
41 }
42
43 def compute(self, cr, uid, ids, context):
44 partner_obj = self.pool.get('res.partner')
45 city_obj = self.pool.get('res.city')
46 # leading space so that position is the month number
47 month_codes = ' ABCDEHLMPRST'
48 for wiz in self.browse(cr, uid, ids):
49 for partner in partner_obj.browse(cr, uid, context['active_ids']):
50 if partner.fiscalcode:
51 # maybe check fiscalcode sanity here?
52 data = {}
53 if wiz.update_sex and not partner.sex:
54 try:
55 day = int(partner.fiscalcode[9:11])
56 except Exception:
57 ### XXX handle insane fc here
58 raise
59 sex = day > 40 and 'F' or 'M'
60 data['sex'] = sex
61 if wiz.update_birth_city and not partner.birth_city:
62 cadaster_code = partner.fiscalcode[11:15]
63 birth_city = city_obj.search(cr, uid, [
64 ('cadaster_code', '=', cadaster_code)
65 ])
66 if not birth_city:
67 raise osv.except_osv(
68 _('Error'),
69 _('City with cadaster code %s not found')
70 % cadaster_code
71 )
72 if len(birth_city) > 1:
73 raise osv.except_osv(
74 _('Error'),
75 _('More than one city with cadaster code %s')
76 % cadaster_code
77 )
78 data['birth_city'] = birth_city[0]
79 if wiz.update_birth_date:
80 year = int(partner.fiscalcode[6:8])
81 day = int(partner.fiscalcode[9:11])
82 day = day > 40 and day - 40 or day
83 month = month_codes.find(partner.fiscalcode[8])
84 if month == -1:
85 raise osv.except_osv(
86 _('Error'),
87 _('Fiscal code %s: Invalid month code %s')
88 % (partner.fiscalcode, partner.fiscalcode[8])
89 )
90
91 # Don't format the date string directly to work out
92 # the century
93 d = datetime.strptime(
94 '{}{}{}'.format(year, month, day), '%y%m%d'
95 )
96 if d > datetime.now():
97 d = datetime(d.year - 100, d.month, d.day)
98 data['birth_date'] = d.strftime('%Y-%m-%d')
99 if data:
100 partner_obj.write(cr, uid, partner.id, data)
101
102 return {}
0103
=== added file 'l10n_it_fiscalcode/wizard/fiscalcode_to_data_view.xml'
--- l10n_it_fiscalcode/wizard/fiscalcode_to_data_view.xml 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/wizard/fiscalcode_to_data_view.xml 2013-05-07 09:35:16 +0000
@@ -0,0 +1,30 @@
1<openerp>
2 <data>
3
4 <record id="view_wizard_fiscalcode_to_data" model="ir.ui.view">
5 <field name="name">Compute missing data from Fiscal Code</field>
6 <field name="model">wizard.fiscalcode.to.data</field>
7 <field name="type">form</field>
8 <field name="arch" type="xml">
9 <form string="Compute missing data from Fiscal Code">
10 <group colspan="4" col="6">
11 <field name="update_birth_date"/>
12 <field name="update_birth_city"/>
13 <field name="update_sex"/>
14 </group>
15 <button special="cancel" string="Cancel" icon="gtk-cancel"/>
16 <button name="compute" string="Compute" type="object" icon="gtk-ok"/>
17 </form>
18 </field>
19 </record>
20
21 <act_window name="Compute missing data from Fiscal Code"
22 res_model="wizard.fiscalcode.to.data"
23 src_model="res.partner"
24 view_mode="form"
25 target="new"
26 key2="client_action_multi"
27 id="action_fiscalcode_to_data"/>
28
29 </data>
30</openerp>
0\ No newline at end of file31\ No newline at end of file

Subscribers

People subscribed via source and target branches