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
1=== modified file 'l10n_it_fiscalcode/__openerp__.py'
2--- l10n_it_fiscalcode/__openerp__.py 2013-01-04 14:02:10 +0000
3+++ l10n_it_fiscalcode/__openerp__.py 2013-05-07 09:35:16 +0000
4@@ -33,16 +33,20 @@
5 'author': 'OpenERP Italian Community',
6 'website': 'http://www.openerp-italia.org',
7 'license': 'AGPL-3',
8- "depends" : ['base', 'l10n_it_base'],
9- "init_xml" : [
10+ "depends": [
11+ 'base',
12+ 'l10n_it_base'
13+ ],
14+ "init_xml": [
15 'fiscalcode_view.xml',
16- 'wizard/compute_fc_view.xml'
17- ],
18- "update_xml" : [],
19- "demo_xml" : [],
20+ 'wizard/compute_fc_view.xml',
21+ 'wizard/fiscalcode_to_data_view.xml'
22+ ],
23+ "update_xml": [],
24+ "demo_xml": [],
25 'test': [
26 'test/fiscalcode.yml',
27- ],
28+ ],
29 "active": False,
30 "installable": True
31 }
32
33=== modified file 'l10n_it_fiscalcode/fiscalcode.py'
34--- l10n_it_fiscalcode/fiscalcode.py 2013-01-04 14:02:10 +0000
35+++ l10n_it_fiscalcode/fiscalcode.py 2013-05-07 09:35:16 +0000
36@@ -5,8 +5,8 @@
37 # (<http://www.openerp-italia.org>).
38 #
39 # This program is free software: you can redistribute it and/or modify
40-# it under the terms of the GNU Affero General Public License as published by
41-# the Free Software Foundation, either version 3 of the License, or
42+# it under the terms of the GNU Affero General Public License as published
43+# by the Free Software Foundation, either version 3 of the License, or
44 # (at your option) any later version.
45 #
46 # This program is distributed in the hope that it will be useful,
47@@ -20,10 +20,7 @@
48 ##############################################################################
49
50 from osv import fields, osv
51-import tools
52-import pooler
53-from tools.translate import _
54-import datetime
55+
56
57 class res_partner(osv.osv):
58 _inherit = 'res.partner'
59@@ -39,13 +36,30 @@
60 return True
61
62 _columns = {
63- 'fiscalcode': fields.char('Fiscal Code', size=16, help="Italian Fiscal Code"),
64- 'individual': fields.boolean('Individual', help="If checked the C.F. is referred to a Individual Person"),
65+ 'fiscalcode': fields.char(
66+ 'Fiscal Code', size=16, help="Italian Fiscal Code"
67+ ),
68+ 'individual': fields.boolean(
69+ 'Individual',
70+ help="If checked the C.F. is referred to a Individual Person"
71+ ),
72+ 'birth_date': fields.date('Date of birth'),
73+ 'birth_city': fields.many2one('res.city', 'City of birth'),
74+ 'sex': fields.selection([
75+ ('M', 'Male'),
76+ ('F', 'Female'),
77+ ], "Sex"),
78 }
79 _defaults = {
80 'individual': False,
81 }
82- _constraints = [(check_fiscalcode, "The fiscal code doesn't seem to be correct.", ["fiscalcode"])]
83- _sql_constraints = [
84- ('fiscalcode_uniq', 'unique (fiscalcode, company_id)', 'The fiscal code must be unique per company !'),
85- ]
86+ _constraints = [(
87+ check_fiscalcode,
88+ "The fiscal code doesn't seem to be correct.",
89+ ["fiscalcode"]
90+ )]
91+ _sql_constraints = [(
92+ 'fiscalcode_uniq',
93+ 'unique (fiscalcode, company_id)',
94+ 'The fiscal code must be unique per company !'
95+ ), ]
96
97=== modified file 'l10n_it_fiscalcode/fiscalcode_view.xml'
98--- l10n_it_fiscalcode/fiscalcode_view.xml 2012-10-22 09:23:35 +0000
99+++ l10n_it_fiscalcode/fiscalcode_view.xml 2013-05-07 09:35:16 +0000
100@@ -11,6 +11,9 @@
101 <separator string="Fiscal Data" colspan="6"/>
102 <field name="fiscalcode"/>
103 <field name="individual" colspan="1" groups="base.group_extended" />
104+ <field name="birth_date"/>
105+ <field name="birth_city"/>
106+ <field name="sex"/>
107 </field>
108 </field>
109 </record>
110
111=== modified file 'l10n_it_fiscalcode/i18n/it.po'
112--- l10n_it_fiscalcode/i18n/it.po 2012-12-05 10:03:52 +0000
113+++ l10n_it_fiscalcode/i18n/it.po 2013-05-07 09:35:16 +0000
114@@ -6,13 +6,13 @@
115 msgstr ""
116 "Project-Id-Version: OpenERP Server 6.1\n"
117 "Report-Msgid-Bugs-To: \n"
118-"POT-Creation-Date: 2012-12-05 10:00+0000\n"
119-"PO-Revision-Date: 2012-12-05 11:02+0100\n"
120-"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>\n"
121+"POT-Creation-Date: 2013-05-07 09:23+0000\n"
122+"PO-Revision-Date: 2013-05-07 09:23+0000\n"
123+"Last-Translator: <>\n"
124 "Language-Team: \n"
125 "MIME-Version: 1.0\n"
126 "Content-Type: text/plain; charset=UTF-8\n"
127-"Content-Transfer-Encoding: 8bit\n"
128+"Content-Transfer-Encoding: \n"
129 "Plural-Forms: \n"
130
131 #. module: l10n_it_fiscalcode
132@@ -21,6 +21,12 @@
133 msgstr "Se selezionato il Cofice Fiscale farà riferimento a quello di una Persona Fisica"
134
135 #. module: l10n_it_fiscalcode
136+#: view:partner.sms.send:0
137+msgid "SMS - Gateway: clickatell"
138+msgstr "SMS - Gateway: clickatell"
139+
140+#. module: l10n_it_fiscalcode
141+#: field:res.partner,birth_date:0
142 #: field:wizard.compute.fc,birth_date:0
143 msgid "Date of birth"
144 msgstr "Data di nascita"
145@@ -38,6 +44,11 @@
146 msgstr "Calcola il Codice Fiscale"
147
148 #. module: l10n_it_fiscalcode
149+#: view:partner.sms.send:0
150+msgid "Bulk SMS send"
151+msgstr "Invio SMS di massa"
152+
153+#. module: l10n_it_fiscalcode
154 #: field:wizard.compute.fc,fiscalcode_firstname:0
155 msgid "First name"
156 msgstr "Nome"
157@@ -53,38 +64,83 @@
158 msgstr "Dati Fiscali"
159
160 #. module: l10n_it_fiscalcode
161+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:75
162+#, python-format
163+msgid "More than one city with cadaster code %s"
164+msgstr "Più di una città ha il codice catastale %s"
165+
166+#. module: l10n_it_fiscalcode
167+#: field:res.partner,birth_city:0
168 #: field:wizard.compute.fc,birth_city:0
169 msgid "City of birth"
170 msgstr "Città di Nascita"
171
172 #. module: l10n_it_fiscalcode
173+#: view:partner.sms.send:0
174+msgid "Send SMS"
175+msgstr "Invia SMS"
176+
177+#. module: l10n_it_fiscalcode
178+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:69
179+#, python-format
180+msgid "City with cadaster code %s not found"
181+msgstr "Città con codice catastale %s non trovata"
182+
183+#. module: l10n_it_fiscalcode
184 #: view:wizard.compute.fc:0
185+#: view:wizard.fiscalcode.to.data:0
186 msgid "Compute"
187 msgstr "Calcola"
188
189 #. module: l10n_it_fiscalcode
190+#: model:ir.actions.act_window,name:l10n_it_fiscalcode.action_fiscalcode_to_data
191+#: model:ir.model,name:l10n_it_fiscalcode.model_wizard_fiscalcode_to_data
192+#: view:wizard.fiscalcode.to.data:0
193+msgid "Compute missing data from Fiscal Code"
194+msgstr "Ricava i dati mancanti dal Codice Fiscale"
195+
196+#. module: l10n_it_fiscalcode
197+#: field:wizard.fiscalcode.to.data,update_birth_city:0
198+msgid "Update city of birth"
199+msgstr "Aggiorna la città di nascita"
200+
201+#. module: l10n_it_fiscalcode
202 #: constraint:res.partner:0
203 msgid "The fiscal code doesn't seem to be correct."
204 msgstr "Il Codice Fiscale non sembra corretto per una Persona Fisica."
205
206 #. module: l10n_it_fiscalcode
207+#: field:wizard.fiscalcode.to.data,update_sex:0
208+msgid "Update sex"
209+msgstr "Aggiorna il sesso"
210+
211+#. module: l10n_it_fiscalcode
212 #: sql_constraint:res.partner:0
213 msgid "The fiscal code must be unique per company !"
214 msgstr "Il codice fiscale deve essere unico!"
215
216 #. module: l10n_it_fiscalcode
217-#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:126
218+#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:148
219+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:68
220+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:74
221+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:86
222 #, python-format
223 msgid "Error"
224 msgstr "Errore"
225
226 #. module: l10n_it_fiscalcode
227+#: selection:res.partner,sex:0
228 #: selection:wizard.compute.fc,sex:0
229 msgid "Male"
230 msgstr "Maschio"
231
232 #. module: l10n_it_fiscalcode
233-#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:126
234+#: view:partner.sms.send:0
235+msgid "Message"
236+msgstr "Message"
237+
238+#. module: l10n_it_fiscalcode
239+#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:149
240 #, python-format
241 msgid "Existing fiscal code %s is different from the computed one (%s). If you want to use the computed one, remove the existing one"
242 msgstr "Il codice fiscale sistente %s è diverso da quello calcolato (%s). Se si vuole usare quello calcolato, rimuovere quello esistente."
243@@ -95,6 +151,13 @@
244 msgstr "Cognome"
245
246 #. module: l10n_it_fiscalcode
247+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:87
248+#, python-format
249+msgid "Fiscal code %s: Invalid month code %s"
250+msgstr "Codice Fiscale %s: Codice mese invalido %s"
251+
252+#. module: l10n_it_fiscalcode
253+#: field:res.partner,sex:0
254 #: field:wizard.compute.fc,sex:0
255 msgid "Sex"
256 msgstr "Sesso"
257@@ -110,12 +173,15 @@
258 msgstr "Persona Fisica"
259
260 #. module: l10n_it_fiscalcode
261+#: selection:res.partner,sex:0
262 #: selection:wizard.compute.fc,sex:0
263 msgid "Female"
264 msgstr "Femmina"
265
266 #. module: l10n_it_fiscalcode
267+#: view:partner.sms.send:0
268 #: view:wizard.compute.fc:0
269+#: view:wizard.fiscalcode.to.data:0
270 msgid "Cancel"
271 msgstr "Annulla"
272
273@@ -129,3 +195,8 @@
274 msgid "Compute F.C."
275 msgstr "Calcola C.F."
276
277+#. module: l10n_it_fiscalcode
278+#: field:wizard.fiscalcode.to.data,update_birth_date:0
279+msgid "Update date of birth"
280+msgstr "Aggiorna la data di nascita"
281+
282
283=== modified file 'l10n_it_fiscalcode/wizard/__init__.py'
284--- l10n_it_fiscalcode/wizard/__init__.py 2013-01-04 14:02:10 +0000
285+++ l10n_it_fiscalcode/wizard/__init__.py 2013-05-07 09:35:16 +0000
286@@ -5,8 +5,8 @@
287 # (<http://www.openerp-italia.org>).
288 #
289 # This program is free software: you can redistribute it and/or modify
290-# it under the terms of the GNU Affero General Public License as published by
291-# the Free Software Foundation, either version 3 of the License, or
292+# it under the terms of the GNU Affero General Public License as published
293+# by the Free Software Foundation, either version 3 of the License, or
294 # (at your option) any later version.
295 #
296 # This program is distributed in the hope that it will be useful,
297@@ -20,4 +20,4 @@
298 ##############################################################################
299
300 import compute_fc
301-
302+import fiscalcode_to_data
303
304=== modified file 'l10n_it_fiscalcode/wizard/compute_fc.py'
305--- l10n_it_fiscalcode/wizard/compute_fc.py 2013-01-04 14:02:10 +0000
306+++ l10n_it_fiscalcode/wizard/compute_fc.py 2013-05-07 09:35:16 +0000
307@@ -5,8 +5,8 @@
308 # (<http://www.openerp-italia.org>).
309 #
310 # This program is free software: you can redistribute it and/or modify
311-# it under the terms of the GNU Affero General Public License as published by
312-# the Free Software Foundation, either version 3 of the License, or
313+# it under the terms of the GNU Affero General Public License as published
314+# by the Free Software Foundation, either version 3 of the License, or
315 # (at your option) any later version.
316 #
317 # This program is distributed in the hope that it will be useful,
318@@ -20,12 +20,11 @@
319 ##############################################################################
320
321 from osv import fields, osv
322-import tools
323-import pooler
324 from tools.translate import _
325
326 import datetime
327
328+
329 class wizard_compute_fc(osv.osv_memory):
330
331 _name = "wizard.compute.fc"
332@@ -35,13 +34,14 @@
333 'fiscalcode_firstname': fields.char('First name', size=64),
334 'birth_date': fields.date('Date of birth'),
335 'birth_city': fields.many2one('res.city', 'City of birth'),
336- 'sex': fields.selection([('M','Male'),
337- ('F', 'Female'),
338- ], "Sex"),
339+ 'sex': fields.selection([
340+ ('M', 'Male'),
341+ ('F', 'Female')
342+ ], "Sex"),
343 }
344
345-
346- def _codicefiscale(self, cognome, nome, giornonascita, mesenascita, annonascita, sesso, cittanascita):
347+ def _codicefiscale(self, cognome, nome, giornonascita, mesenascita,
348+ annonascita, sesso, cittanascita):
349
350 MESI = 'ABCDEHLMPRST'
351 CONSONANTI = 'BCDFGHJKLMNPQRSTVWXYZ'
352@@ -49,48 +49,53 @@
353 LETTERE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
354
355 REGOLECONTROLLO = {
356- 'A':(0,1), 'B':(1,0), 'C':(2,5), 'D':(3,7), 'E':(4,9),
357- 'F':(5,13), 'G':(6,15), 'H':(7,17), 'I':(8,19), 'J':(9,21),
358- 'K':(10,2), 'L':(11,4), 'M':(12,18), 'N':(13,20), 'O':(14,11),
359- 'P':(15,3), 'Q':(16,6), 'R':(17,8), 'S':(18,12), 'T':(19,14),
360- 'U':(20,16), 'V':(21,10), 'W':(22,22), 'X':(23,25), 'Y':(24,24),
361- 'Z':(25,23),
362- '0':(0,1), '1':(1,0), '2':(2,5), '3':(3,7), '4':(4,9),
363- '5':(5,13), '6':(6,15), '7':(7,17), '8':(8,19), '9':(9,21)
364+ 'A': (0, 1), 'B': (1, 0), 'C': (2, 5), 'D': (3, 7), 'E': (4, 9),
365+ 'F': (5, 13), 'G': (6, 15), 'H': (7, 17), 'I': (8, 19),
366+ 'J': (9, 21), 'K': (10, 2), 'L': (11, 4), 'M': (12, 18),
367+ 'N': (13, 20), 'O': (14, 11), 'P': (15, 3), 'Q': (16, 6),
368+ 'R': (17, 8), 'S': (18, 12), 'T': (19, 14), 'U': (20, 16),
369+ 'V': (21, 10), 'W': (22, 22), 'X': (23, 25), 'Y': (24, 24),
370+ 'Z': (25, 23),
371+ '0': (0, 1), '1': (1, 0), '2': (2, 5), '3': (3, 7), '4': (4, 9),
372+ '5': (5, 13), '6': (6, 15), '7': (7, 17), '8': (8, 19),
373+ '9': (9, 21)
374 }
375
376 """Funzioni per il calcolo del C.F."""
377 def _surname(stringa):
378- """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""
379+ """Ricava, da stringa, 3 lettere in base alla convenzione dei
380+ C.F."""
381 cons = [c for c in stringa if c in CONSONANTI]
382 voc = [c for c in stringa if c in VOCALI]
383- chars=cons+voc
384- if len(chars)<3:
385- chars+=['X', 'X']
386+ chars = cons + voc
387+ if len(chars) < 3:
388+ chars += ['X', 'X']
389 return chars[:3]
390
391 def _name(stringa):
392- """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""
393+ """Ricava, da stringa, 3 lettere in base alla convenzione dei
394+ C.F."""
395 cons = [c for c in stringa if c in CONSONANTI]
396 voc = [c for c in stringa if c in VOCALI]
397- if len(cons)>3:
398- cons = [cons[0]] +[cons[2]] + [cons[3]]
399- chars=cons+voc
400- if len(chars)<3:
401- chars+=['X', 'X']
402+ if len(cons) > 3:
403+ cons = [cons[0]] + [cons[2]] + [cons[3]]
404+ chars = cons + voc
405+ if len(chars) < 3:
406+ chars += ['X', 'X']
407 return chars[:3]
408
409 def _datan(giorno, mese, anno, sesso):
410 """Restituisce il campo data del CF."""
411- chars = (list(anno[-2:]) + [MESI[int(mese)-1]])
412- gn=int(giorno)
413- if sesso=='F':
414- gn+=40
415+ chars = (list(anno[-2:]) + [MESI[int(mese) - 1]])
416+ gn = int(giorno)
417+ if sesso == 'F':
418+ gn += 40
419 chars += list("%02d" % gn)
420 return chars
421
422 def _codicecontrollo(c):
423- """Restituisce il codice di controllo, l'ultimo carattere del C.F."""
424+ """Restituisce il codice di controllo, l'ultimo carattere del
425+ C.F."""
426 sommone = 0
427 for i, car in enumerate(c):
428 j = 1 - i % 2
429@@ -99,9 +104,9 @@
430 return [LETTERE[resto]]
431
432 """Restituisce il C.F costruito sulla base degli argomenti."""
433- nome=nome.upper()
434- cognome=cognome.upper()
435- sesso=sesso.upper()
436+ nome = nome.upper()
437+ cognome = cognome.upper()
438+ sesso = sesso.upper()
439 cittanascita = cittanascita.upper()
440 chars = (_surname(cognome) +
441 _name(nome) +
442@@ -112,16 +117,41 @@
443
444 def compute_fc(self, cr, uid, ids, context):
445 active_id = context.get('active_id', [])
446- partner = self.pool.get('res.partner').browse(cr, uid, active_id, context)
447+ partner = self.pool.get('res.partner').browse(
448+ cr, uid, active_id, context
449+ )
450 form_obj = self.browse(cr, uid, ids, context)
451 for fields in form_obj:
452- if not fields.fiscalcode_surname or not fields.fiscalcode_firstname or not fields.birth_date or not fields.birth_city or not fields.sex:
453+ if (
454+ not fields.fiscalcode_surname or
455+ not fields.fiscalcode_firstname or
456+ not fields.birth_date or
457+ not fields.birth_city or
458+ not fields.sex
459+ ):
460 raise osv.except_osv('Error', 'One or more fields are missing')
461- birth_date = datetime.datetime.strptime(fields.birth_date, "%Y-%m-%d")
462- CF = self._codicefiscale(fields.fiscalcode_surname, fields.fiscalcode_firstname, str(birth_date.day),
463- str(birth_date.month), str(birth_date.year), fields.sex,
464- fields.birth_city.cadaster_code)
465+ birth_date = datetime.datetime.strptime(
466+ fields.birth_date,
467+ "%Y-%m-%d"
468+ )
469+ CF = self._codicefiscale(
470+ fields.fiscalcode_surname,
471+ fields.fiscalcode_firstname,
472+ str(birth_date.day),
473+ str(birth_date.month),
474+ str(birth_date.year),
475+ fields.sex,
476+ fields.birth_city.cadaster_code
477+ )
478 if partner.fiscalcode and partner.fiscalcode != CF:
479- 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))
480- self.pool.get('res.partner').write(cr, uid, active_id, {'fiscalcode': CF, 'individual': True})
481+ raise osv.except_osv(
482+ _('Error'),
483+ _('Existing fiscal code %s is different from the '
484+ 'computed one (%s). If you want to use the computed '
485+ 'one, remove the existing one') %
486+ (partner.fiscalcode, CF))
487+ self.pool.get('res.partner').write(cr, uid, active_id, {
488+ 'fiscalcode': CF,
489+ 'individual': True
490+ })
491 return {}
492
493=== modified file 'l10n_it_fiscalcode/wizard/compute_fc_view.xml'
494--- l10n_it_fiscalcode/wizard/compute_fc_view.xml 2012-10-22 09:23:35 +0000
495+++ l10n_it_fiscalcode/wizard/compute_fc_view.xml 2013-05-07 09:35:16 +0000
496@@ -1,6 +1,6 @@
497 <?xml version="1.0" ?>
498 <openerp>
499- <data>
500+ <data>
501
502 <record id="wizard_compute_fc_form" model="ir.ui.view">
503 <field name="name">wizard.compute.fc.form</field>
504@@ -46,5 +46,29 @@
505 </field>
506 </record>
507
508- </data>
509+<!-- Create Menu From view -->
510+
511+ <record id="view_partner_sms_send" model="ir.ui.view">
512+ <field name="name">Send SMS</field>
513+ <field name="model">partner.sms.send</field>
514+ <field name="type">form</field>
515+ <field name="arch" type="xml">
516+ <form string="SMS - Gateway: clickatell">
517+ <separator string="Bulk SMS send" colspan="4"/>
518+ <field name="mobile_to"/>
519+ <field name="app_id"/>
520+ <field name="user"/>
521+ <field name="password"/>
522+ <separator string="Message" colspan="4" />
523+ <field name="text" colspan="4" nolabel="1"/>
524+ <separator string="" colspan="4" />
525+ <group colspan="4" col="6">
526+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
527+ <button name="sms_send" string="Send SMS" type="object" icon="terp-mail-message-new"/>
528+ </group>
529+ </form>
530+ </field>
531+ </record>
532+
533+ </data>
534 </openerp>
535
536=== added file 'l10n_it_fiscalcode/wizard/fiscalcode_to_data.py'
537--- l10n_it_fiscalcode/wizard/fiscalcode_to_data.py 1970-01-01 00:00:00 +0000
538+++ l10n_it_fiscalcode/wizard/fiscalcode_to_data.py 2013-05-07 09:35:16 +0000
539@@ -0,0 +1,102 @@
540+# -*- coding: utf-8 -*-
541+##############################################################################
542+#
543+# Copyright (C) 2010-2012 Associazione OpenERP Italia
544+# (<http://www.openerp-italia.org>).
545+#
546+# This program is free software: you can redistribute it and/or modify
547+# it under the terms of the GNU Affero General Public License as published
548+# by the Free Software Foundation, either version 3 of the License, or
549+# (at your option) any later version.
550+#
551+# This program is distributed in the hope that it will be useful,
552+# but WITHOUT ANY WARRANTY; without even the implied warranty of
553+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
554+# GNU General Public License for more details.
555+#
556+# You should have received a copy of the GNU Affero General Public License
557+# along with this program. If not, see <http://www.gnu.org/licenses/>.
558+#
559+##############################################################################
560+
561+from osv import fields, osv
562+from tools.translate import _
563+from datetime import datetime
564+
565+
566+class wizard_fiscalcode_to_data(osv.osv_memory):
567+
568+ _name = "wizard.fiscalcode.to.data"
569+ _description = "Compute missing data from Fiscal Code"
570+ _columns = {
571+ 'update_birth_date': fields.boolean('Update date of birth'),
572+ 'update_birth_city': fields.boolean('Update city of birth'),
573+ 'update_sex': fields.boolean('Update sex'),
574+ }
575+
576+ _defaults = {
577+ 'update_birth_date': True,
578+ 'update_birth_city': True,
579+ 'update_sex': True,
580+ }
581+
582+ def compute(self, cr, uid, ids, context):
583+ partner_obj = self.pool.get('res.partner')
584+ city_obj = self.pool.get('res.city')
585+ # leading space so that position is the month number
586+ month_codes = ' ABCDEHLMPRST'
587+ for wiz in self.browse(cr, uid, ids):
588+ for partner in partner_obj.browse(cr, uid, context['active_ids']):
589+ if partner.fiscalcode:
590+ # maybe check fiscalcode sanity here?
591+ data = {}
592+ if wiz.update_sex and not partner.sex:
593+ try:
594+ day = int(partner.fiscalcode[9:11])
595+ except Exception:
596+ ### XXX handle insane fc here
597+ raise
598+ sex = day > 40 and 'F' or 'M'
599+ data['sex'] = sex
600+ if wiz.update_birth_city and not partner.birth_city:
601+ cadaster_code = partner.fiscalcode[11:15]
602+ birth_city = city_obj.search(cr, uid, [
603+ ('cadaster_code', '=', cadaster_code)
604+ ])
605+ if not birth_city:
606+ raise osv.except_osv(
607+ _('Error'),
608+ _('City with cadaster code %s not found')
609+ % cadaster_code
610+ )
611+ if len(birth_city) > 1:
612+ raise osv.except_osv(
613+ _('Error'),
614+ _('More than one city with cadaster code %s')
615+ % cadaster_code
616+ )
617+ data['birth_city'] = birth_city[0]
618+ if wiz.update_birth_date:
619+ year = int(partner.fiscalcode[6:8])
620+ day = int(partner.fiscalcode[9:11])
621+ day = day > 40 and day - 40 or day
622+ month = month_codes.find(partner.fiscalcode[8])
623+ if month == -1:
624+ raise osv.except_osv(
625+ _('Error'),
626+ _('Fiscal code %s: Invalid month code %s')
627+ % (partner.fiscalcode, partner.fiscalcode[8])
628+ )
629+
630+ # Don't format the date string directly to work out
631+ # the century
632+ d = datetime.strptime(
633+ '{}{}{}'.format(year, month, day), '%y%m%d'
634+ )
635+ if d > datetime.now():
636+ d = datetime(d.year - 100, d.month, d.day)
637+ data['birth_date'] = d.strftime('%Y-%m-%d')
638+ if data:
639+ partner_obj.write(cr, uid, partner.id, data)
640+
641+ return {}
642
643=== added file 'l10n_it_fiscalcode/wizard/fiscalcode_to_data_view.xml'
644--- l10n_it_fiscalcode/wizard/fiscalcode_to_data_view.xml 1970-01-01 00:00:00 +0000
645+++ l10n_it_fiscalcode/wizard/fiscalcode_to_data_view.xml 2013-05-07 09:35:16 +0000
646@@ -0,0 +1,30 @@
647+<openerp>
648+ <data>
649+
650+ <record id="view_wizard_fiscalcode_to_data" model="ir.ui.view">
651+ <field name="name">Compute missing data from Fiscal Code</field>
652+ <field name="model">wizard.fiscalcode.to.data</field>
653+ <field name="type">form</field>
654+ <field name="arch" type="xml">
655+ <form string="Compute missing data from Fiscal Code">
656+ <group colspan="4" col="6">
657+ <field name="update_birth_date"/>
658+ <field name="update_birth_city"/>
659+ <field name="update_sex"/>
660+ </group>
661+ <button special="cancel" string="Cancel" icon="gtk-cancel"/>
662+ <button name="compute" string="Compute" type="object" icon="gtk-ok"/>
663+ </form>
664+ </field>
665+ </record>
666+
667+ <act_window name="Compute missing data from Fiscal Code"
668+ res_model="wizard.fiscalcode.to.data"
669+ src_model="res.partner"
670+ view_mode="form"
671+ target="new"
672+ key2="client_action_multi"
673+ id="action_fiscalcode_to_data"/>
674+
675+ </data>
676+</openerp>
677\ No newline at end of file

Subscribers

People subscribed via source and target branches