Merge lp:~nicolariolini/openobject-italia/save_fiscalcode_data into lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0

Proposed by Nicola Riolini - Micronaet
Status: Needs review
Proposed branch: lp:~nicolariolini/openobject-italia/save_fiscalcode_data
Merge into: lp:~openobject-italia-core-devs/openobject-italia/italian-addons-7.0
Diff against target: 501 lines (+225/-132)
6 files modified
l10n_it_fiscalcode/__init__.py (+15/-16)
l10n_it_fiscalcode/__openerp__.py (+10/-11)
l10n_it_fiscalcode/fiscalcode.py (+46/-27)
l10n_it_fiscalcode/wizard/__init__.py (+15/-16)
l10n_it_fiscalcode/wizard/compute_fc.py (+138/-61)
l10n_it_fiscalcode/wizard/compute_fc_view.xml (+1/-1)
To merge this branch: bzr merge lp:~nicolariolini/openobject-italia/save_fiscalcode_data
Reviewer Review Type Date Requested Status
Lorenzo Battistini code review Approve
Review via email: mp+194457@code.launchpad.net

Description of the change

Modificato l10n_it_fiscalcode:
Creato in res.partner i campi che accolgono i dati per il calcolo del CF, non li faccio vedere però nelle viste, vengono solamente caricati come default se apro il wizard per il calcolo.
Alla chiusura del wizard, con il "calcola", vengono salvati assieme al valore del CF

La modifica è fatta nel caso avessi sbagliato dei dati: cancello il CF, richiamo il wizard e non devo riscriverli per forza tutti

To post a comment you must log in.
230. By Nicola Riolini - Micronaet

Cambiato un commento errato

Revision history for this message
Lorenzo Battistini (elbati) wrote :

riga 86 del diff:
anche senza mettere
context="{'partner_id':active_id,}"
poi non riusciresti comunque a recuperare il partner tramite
context.get('active_id')
?

Inoltre sarebbe una buona cosa (wishlist) se riuscissi a dare una ripassata al codice con PEP8
https://pypi.python.org/pypi/pep8
e pyflakes
https://pypi.python.org/pypi/pyflakes

Così iniziamo a usare codice migliore anche per i moduli italiani.

review: Needs Information
231. By Nicola Riolini - Micronaet

Tolto partner_id nel context non necessario leggendo active_id

Revision history for this message
Nicola Riolini - Micronaet (nicolariolini) wrote :

Come al solito hai ragione Lorenzo :), errore mio, ho messo active_id (ho erroneamente visto i valori differenti nel debug pensando che active_id fosse l'id del wizard, non devo più lavorare dopo le 19 :) )

Sto ripassando in questi giorni la PEP8, non fa mai male, a tal proposito, ho visto che è commentato molto spesso in italiano, che facciamo per i commenti?
Anche se non voglio mettere l'inglese dappertutto credo sia più corretto per aiutare anche quelli che prendono spunto dai moduli l10n_it

Revision history for this message
Lorenzo Battistini (elbati) wrote :

On 11/08/2013 09:49 AM, Nicola Riolini - Micronaet wrote:
> Sto ripassando in questi giorni la PEP8, non fa mai male, a tal proposito, ho visto che è commentato molto spesso in italiano, che facciamo per i commenti?
> Anche se non voglio mettere l'inglese dappertutto credo sia più corretto per aiutare anche quelli che prendono spunto dai moduli l10n_it

In generale, e quando possibile, sì, sarebbe bene usare l'inglese anche
nei commenti.

232. By Nicola Riolini - Micronaet

Normalizzazione file py in PEP8
Non finito compunte_fc perche' devo ancora capire bene come vuole
l'intentazione :)

Revision history for this message
Nicola Riolini - Micronaet (nicolariolini) wrote :

Ho rivisto un po' i moduli py in pep8... che tribulata!!! :)
mancano un paio di indentazioni da correggere nel py del wizard

Revision history for this message
Lorenzo Battistini (elbati) wrote :

On 11/08/2013 10:46 AM, Nicola Riolini - Micronaet wrote:
> Ho rivisto un po' i moduli py in pep8... che tribulata!!! :)
> mancano un paio di indentazioni da correggere nel py del wizard

Ecco:
https://code.launchpad.net/~agilebg/openobject-italia/imp_save_fiscalcode_data/+merge/194477
<https://code.launchpad.net/%7Eagilebg/openobject-italia/imp_save_fiscalcode_data/+merge/194477>

233. By Nicola Riolini - Micronaet

Merge (spero) delle modifiche fatte da Lorenzo

234. By Nicola Riolini - Micronaet

Impostato orm al posto di osv
data al posto di update_xml

Revision history for this message
Nicola Riolini - Micronaet (nicolariolini) wrote :

Lorenzo ciao, ho finito le migliori/correzioni, ho attualizzato anche: orm al posto di osv e osv_memory, il raise e 'data' al posto di 'update_xml'
Dimmi se ti viene in mente altro.
ciao

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Thanks!

review: Approve (code review)
Revision history for this message
Nicola Riolini - Micronaet (nicolariolini) wrote :

> Thanks!
To you :)

Revision history for this message
Lorenzo Battistini (elbati) wrote :

This project is now hosted on https://github.com/OCA/l10n-italy. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

Unmerged revisions

234. By Nicola Riolini - Micronaet

Impostato orm al posto di osv
data al posto di update_xml

233. By Nicola Riolini - Micronaet

Merge (spero) delle modifiche fatte da Lorenzo

232. By Nicola Riolini - Micronaet

Normalizzazione file py in PEP8
Non finito compunte_fc perche' devo ancora capire bene come vuole
l'intentazione :)

231. By Nicola Riolini - Micronaet

Tolto partner_id nel context non necessario leggendo active_id

230. By Nicola Riolini - Micronaet

Cambiato un commento errato

229. By Nicola Riolini - Micronaet

Finito debug iniziale

228. By Nicola Riolini - Micronaet

Correggere errori JSON durante l'attribuzione dei valori default

227. By Nicola Riolini - Micronaet

Aggiunta dei campi a res.partner
Aggiunta dei defaults nel wizard
Scrittura dei valori in uscita del wizard per storicizzare
Inizio debug

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_it_fiscalcode/__init__.py'
2--- l10n_it_fiscalcode/__init__.py 2013-02-05 16:15:05 +0000
3+++ l10n_it_fiscalcode/__init__.py 2013-11-13 12:56:08 +0000
4@@ -1,24 +1,23 @@
5 # -*- coding: utf-8 -*-
6 ##############################################################################
7 #
8-# Copyright (C) 2012 Associazione OpenERP Italia
9-# (<http://www.openerp-italia.org>).
10-#
11-# This program is free software: you can redistribute it and/or modify
12-# it under the terms of the GNU Affero General Public License as published by
13-# the Free Software Foundation, either version 3 of the License, or
14-# (at your option) any later version.
15-#
16-# This program is distributed in the hope that it will be useful,
17-# but WITHOUT ANY WARRANTY; without even the implied warranty of
18-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-# GNU General Public License for more details.
20-#
21-# You should have received a copy of the GNU Affero General Public License
22-# along with this program. If not, see <http://www.gnu.org/licenses/>.
23+# Copyright (C) 2012 Associazione OpenERP Italia
24+# (<http://www.openerp-italia.org>).
25+#
26+# This program is free software: you can redistribute it and/or modify
27+# it under the terms of the GNU Affero General Public License as published by
28+# the Free Software Foundation, either version 3 of the License, or
29+# (at your option) any later version.
30+#
31+# This program is distributed in the hope that it will be useful,
32+# but WITHOUT ANY WARRANTY; without even the implied warranty of
33+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34+# GNU General Public License for more details.
35+#
36+# You should have received a copy of the GNU Affero General Public License
37+# along with this program. If not, see <http://www.gnu.org/licenses/>.
38 #
39 ##############################################################################
40
41 import fiscalcode
42 import wizard
43-
44
45=== modified file 'l10n_it_fiscalcode/__openerp__.py'
46--- l10n_it_fiscalcode/__openerp__.py 2013-02-05 16:15:05 +0000
47+++ l10n_it_fiscalcode/__openerp__.py 2013-11-13 12:56:08 +0000
48@@ -23,23 +23,22 @@
49 'version': '0.1',
50 'category': 'Localisation/Italy',
51 'description': """
52-This module customizes OpenERP in order to fit italian laws and mores - Account version
53-
54-Functionalities:
55-
56-- Fiscal code computation for partner
57-
58-""",
59+ This module customizes OpenERP in order to fit italian laws and mores
60+ - Account version
61+
62+ Functionalities:
63+ - Fiscal code computation for partner
64+ """,
65 'author': 'OpenERP Italian Community',
66 'website': 'http://www.openerp-italia.org',
67 'license': 'AGPL-3',
68- "depends" : ['base', 'l10n_it_base'],
69- "init_xml" : [
70+ "depends": ['base', 'l10n_it_base'],
71+ "init_xml": [
72 'fiscalcode_view.xml',
73 'wizard/compute_fc_view.xml'
74 ],
75- "update_xml" : [],
76- "demo_xml" : [],
77+ "data": [],
78+ "demo_xml": [],
79 'test': [
80 'test/fiscalcode.yml',
81 ],
82
83=== modified file 'l10n_it_fiscalcode/fiscalcode.py'
84--- l10n_it_fiscalcode/fiscalcode.py 2013-02-05 16:15:05 +0000
85+++ l10n_it_fiscalcode/fiscalcode.py 2013-11-13 12:56:08 +0000
86@@ -1,31 +1,32 @@
87 # -*- coding: utf-8 -*-
88 ##############################################################################
89 #
90-# Copyright (C) 2010-2012 Associazione OpenERP Italia
91-# (<http://www.openerp-italia.org>).
92-#
93-# This program is free software: you can redistribute it and/or modify
94-# it under the terms of the GNU Affero General Public License as published by
95-# the Free Software Foundation, either version 3 of the License, or
96-# (at your option) any later version.
97-#
98-# This program is distributed in the hope that it will be useful,
99-# but WITHOUT ANY WARRANTY; without even the implied warranty of
100-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101-# GNU General Public License for more details.
102-#
103-# You should have received a copy of the GNU Affero General Public License
104-# along with this program. If not, see <http://www.gnu.org/licenses/>.
105+# Copyright (C) 2010-2012 Associazione OpenERP Italia
106+# (<http://www.openerp-italia.org>).
107+#
108+# This program is free software: you can redistribute it and/or modify
109+# it under the terms of the GNU Affero General Public License as published by
110+# the Free Software Foundation, either version 3 of the License, or
111+# (at your option) any later version.
112+#
113+# This program is distributed in the hope that it will be useful,
114+# but WITHOUT ANY WARRANTY; without even the implied warranty of
115+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
116+# GNU General Public License for more details.
117+#
118+# You should have received a copy of the GNU Affero General Public License
119+# along with this program. If not, see <http://www.gnu.org/licenses/>.
120 #
121 ##############################################################################
122
123-from osv import fields, osv
124-import tools
125-import pooler
126-from tools.translate import _
127-import datetime
128-
129-class res_partner(osv.osv):
130+from openerp.osv import fields, orm
131+
132+
133+class res_partner(orm.Model):
134+ ''' Add extra fields in res.partner
135+ Add also fiscal code check function
136+ '''
137+
138 _inherit = 'res.partner'
139
140 def check_fiscalcode(self, cr, uid, ids, context={}):
141@@ -39,13 +40,31 @@
142 return True
143
144 _columns = {
145- 'fiscalcode': fields.char('Fiscal Code', size=16, help="Italian Fiscal Code"),
146- 'individual': fields.boolean('Individual', help="If checked the C.F. is referred to a Individual Person"),
147+ 'fiscalcode': fields.char(
148+ 'Fiscal Code', size=16,
149+ help="Italian Fiscal Code"),
150+ 'individual': fields.boolean(
151+ 'Individual',
152+ help="If checked the C.F. is referred to a Individual Person"),
153+
154+ # Field for save fiscalcode calculation data:
155+ 'fiscalcode_surname': fields.char('Surname', size=64),
156+ 'fiscalcode_firstname': fields.char('First name', size=64),
157+ 'birth_date': fields.date('Date of birth'),
158+ 'birth_city': fields.many2one('res.city', 'City of birth'),
159+ 'sex': fields.selection(
160+ [('M', 'Male'), ('F', 'Female'), ],
161+ "Sex"),
162 }
163+
164 _defaults = {
165 'individual': False,
166 }
167- _constraints = [(check_fiscalcode, "The fiscal code doesn't seem to be correct.", ["fiscalcode"])]
168+
169+ _constraints = [
170+ (check_fiscalcode, "The fiscal code doesn't seem to be correct.",
171+ ["fiscalcode"],)]
172+
173 _sql_constraints = [
174- ('fiscalcode_uniq', 'unique (fiscalcode, company_id)', 'The fiscal code must be unique per company !'),
175- ]
176+ ('fiscalcode_uniq', 'unique (fiscalcode, company_id)',
177+ 'The fiscal code must be unique per company !'), ]
178
179=== modified file 'l10n_it_fiscalcode/wizard/__init__.py'
180--- l10n_it_fiscalcode/wizard/__init__.py 2013-02-05 16:15:05 +0000
181+++ l10n_it_fiscalcode/wizard/__init__.py 2013-11-13 12:56:08 +0000
182@@ -1,23 +1,22 @@
183 # -*- coding: utf-8 -*-
184 ##############################################################################
185 #
186-# Copyright (C) 2012 Associazione OpenERP Italia
187-# (<http://www.openerp-italia.org>).
188-#
189-# This program is free software: you can redistribute it and/or modify
190-# it under the terms of the GNU Affero General Public License as published by
191-# the Free Software Foundation, either version 3 of the License, or
192-# (at your option) any later version.
193-#
194-# This program is distributed in the hope that it will be useful,
195-# but WITHOUT ANY WARRANTY; without even the implied warranty of
196-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
197-# GNU General Public License for more details.
198-#
199-# You should have received a copy of the GNU Affero General Public License
200-# along with this program. If not, see <http://www.gnu.org/licenses/>.
201+# Copyright (C) 2012 Associazione OpenERP Italia
202+# (<http://www.openerp-italia.org>).
203+#
204+# This program is free software: you can redistribute it and/or modify
205+# it under the terms of the GNU Affero General Public License as published by
206+# the Free Software Foundation, either version 3 of the License, or
207+# (at your option) any later version.
208+#
209+# This program is distributed in the hope that it will be useful,
210+# but WITHOUT ANY WARRANTY; without even the implied warranty of
211+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
212+# GNU General Public License for more details.
213+#
214+# You should have received a copy of the GNU Affero General Public License
215+# along with this program. If not, see <http://www.gnu.org/licenses/>.
216 #
217 ##############################################################################
218
219 import compute_fc
220-
221
222=== modified file 'l10n_it_fiscalcode/wizard/compute_fc.py'
223--- l10n_it_fiscalcode/wizard/compute_fc.py 2013-03-01 11:07:49 +0000
224+++ l10n_it_fiscalcode/wizard/compute_fc.py 2013-11-13 12:56:08 +0000
225@@ -1,47 +1,92 @@
226 # -*- coding: utf-8 -*-
227 ##############################################################################
228 #
229-# Copyright (C) 2010-2012 Associazione OpenERP Italia
230-# (<http://www.openerp-italia.org>).
231-#
232-# This program is free software: you can redistribute it and/or modify
233-# it under the terms of the GNU Affero General Public License as published by
234-# the Free Software Foundation, either version 3 of the License, or
235-# (at your option) any later version.
236-#
237-# This program is distributed in the hope that it will be useful,
238-# but WITHOUT ANY WARRANTY; without even the implied warranty of
239-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
240-# GNU General Public License for more details.
241-#
242-# You should have received a copy of the GNU Affero General Public License
243-# along with this program. If not, see <http://www.gnu.org/licenses/>.
244+# Copyright (C) 2010-2012 Associazione OpenERP Italia
245+# (<http://www.openerp-italia.org>).
246+#
247+# This program is free software: you can redistribute it and/or modify
248+# it under the terms of the GNU Affero General Public License as published by
249+# the Free Software Foundation, either version 3 of the License, or
250+# (at your option) any later version.
251+#
252+# This program is distributed in the hope that it will be useful,
253+# but WITHOUT ANY WARRANTY; without even the implied warranty of
254+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
255+# GNU General Public License for more details.
256+#
257+# You should have received a copy of the GNU Affero General Public License
258+# along with this program. If not, see <http://www.gnu.org/licenses/>.
259 #
260 ##############################################################################
261
262-from osv import fields, osv
263-import tools
264-import pooler
265+from openerp.osv import fields, orm
266 from tools.translate import _
267-
268 import datetime
269
270-class wizard_compute_fc(osv.osv_memory):
271+
272+class wizard_compute_fc(orm.TransientModel):
273+ ''' Wizard for calculation of fiscalcode
274+ '''
275
276 _name = "wizard.compute.fc"
277 _description = "Compute Fiscal Code"
278+
279 _columns = {
280 'fiscalcode_surname': fields.char('Surname', size=64),
281 'fiscalcode_firstname': fields.char('First name', size=64),
282 'birth_date': fields.date('Date of birth'),
283 'birth_city': fields.many2one('res.city', 'City of birth'),
284- 'sex': fields.selection([('M','Male'),
285- ('F', 'Female'),
286- ], "Sex"),
287- }
288-
289-
290- def _codicefiscale(self, cognome, nome, giornonascita, mesenascita, annonascita, sesso, cittanascita):
291+ 'sex': fields.selection([('M', 'Male'),
292+ ('F', 'Female'), ], 'Sex'),
293+ }
294+
295+ _defaults = {
296+ # Leggo da res.partner i dati se presenti per impostarli come default:
297+ 'fiscalcode_surname': (
298+ lambda s, cr, uid, c: s.get_default_from_partner(
299+ cr, uid, 'fiscalcode_surname', context=c)
300+ ),
301+ 'fiscalcode_firstname': (
302+ lambda s, cr, uid, c: s.get_default_from_partner(
303+ cr, uid, 'fiscalcode_firstname', context=c)
304+ ),
305+ 'birth_date': (
306+ lambda s, cr, uid, c: s.get_default_from_partner(
307+ cr, uid, 'birth_date', context=c)
308+ ),
309+ 'birth_city': (
310+ lambda s, cr, uid, c: s.get_default_from_partner(
311+ cr, uid, 'birth_city', context=c)
312+ ),
313+ 'sex': (
314+ lambda s, cr, uid, c: s.get_default_from_partner(
315+ cr, uid, 'sex', context=c)
316+ ),
317+ }
318+
319+ def get_default_from_partner(self, cr, uid, field, context=None):
320+ ''' Legge il valore del campo richiesto da res_partner per proporre
321+ il valore di default nel wizard
322+ '''
323+ if context is None:
324+ context = {}
325+
326+ try:
327+ partner_id = context.get('active_id', 0)
328+ if not partner_id:
329+ return False
330+ partner_proxy = self.pool.get('res.partner').browse(
331+ cr, uid, partner_id, context=context)
332+ res = partner_proxy.__getattr__(field)
333+
334+ if field == 'birth_city': # many2one
335+ return res.id
336+ return res
337+ except: # in caso di errore il campo rimane vuoto
338+ return False
339+
340+ def _codicefiscale(self, cognome, nome, giornonascita, mesenascita,
341+ annonascita, sesso, cittanascita):
342
343 MESI = 'ABCDEHLMPRST'
344 CONSONANTI = 'BCDFGHJKLMNPQRSTVWXYZ'
345@@ -49,48 +94,50 @@
346 LETTERE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
347
348 REGOLECONTROLLO = {
349- 'A':(0,1), 'B':(1,0), 'C':(2,5), 'D':(3,7), 'E':(4,9),
350- 'F':(5,13), 'G':(6,15), 'H':(7,17), 'I':(8,19), 'J':(9,21),
351- 'K':(10,2), 'L':(11,4), 'M':(12,18), 'N':(13,20), 'O':(14,11),
352- 'P':(15,3), 'Q':(16,6), 'R':(17,8), 'S':(18,12), 'T':(19,14),
353- 'U':(20,16), 'V':(21,10), 'W':(22,22), 'X':(23,25), 'Y':(24,24),
354- 'Z':(25,23),
355- '0':(0,1), '1':(1,0), '2':(2,5), '3':(3,7), '4':(4,9),
356- '5':(5,13), '6':(6,15), '7':(7,17), '8':(8,19), '9':(9,21)
357+ 'A': (0, 1), 'B': (1, 0), 'C': (2, 5), 'D': (3, 7), 'E': (4, 9),
358+ 'F': (5, 13), 'G': (6, 15), 'H': (7, 17), 'I': (8, 19),
359+ 'J': (9, 21), 'K': (10, 2), 'L': (11, 4), 'M': (12, 18),
360+ 'N': (13, 20), 'O': (14, 11), 'P': (15, 3), 'Q': (16, 6),
361+ 'R': (17, 8), 'S': (18, 12), 'T': (19, 14), 'U': (20, 16),
362+ 'V': (21, 10), 'W': (22, 22), 'X': (23, 25), 'Y': (24, 24),
363+ 'Z': (25, 23),
364+ '0': (0, 1), '1': (1, 0), '2': (2, 5), '3': (3, 7), '4': (4, 9),
365+ '5': (5, 13), '6': (6, 15), '7': (7, 17), '8': (8, 19),
366+ '9': (9, 21),
367 }
368
369 """Funzioni per il calcolo del C.F."""
370 def _surname(stringa):
371- """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""
372+ """Ricava da stringa 3 lettere in base alla convenzione dei C.F."""
373 cons = [c for c in stringa if c in CONSONANTI]
374 voc = [c for c in stringa if c in VOCALI]
375- chars=cons+voc
376- if len(chars)<3:
377- chars+=['X', 'X']
378+ chars = cons + voc
379+ if len(chars) < 3:
380+ chars += ['X', 'X']
381 return chars[:3]
382
383 def _name(stringa):
384- """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""
385+ """Ricava da stringa 3 lettere in base alla convenzione dei C.F."""
386 cons = [c for c in stringa if c in CONSONANTI]
387 voc = [c for c in stringa if c in VOCALI]
388- if len(cons)>3:
389- cons = [cons[0]] +[cons[2]] + [cons[3]]
390- chars=cons+voc
391- if len(chars)<3:
392- chars+=['X', 'X']
393+ if len(cons) > 3:
394+ cons = [cons[0]] + [cons[2]] + [cons[3]]
395+ chars = cons + voc
396+ if len(chars) < 3:
397+ chars += ['X', 'X']
398 return chars[:3]
399
400 def _datan(giorno, mese, anno, sesso):
401 """Restituisce il campo data del CF."""
402- chars = (list(anno[-2:]) + [MESI[int(mese)-1]])
403- gn=int(giorno)
404- if sesso=='F':
405- gn+=40
406+ chars = (list(anno[-2:]) + [MESI[int(mese) - 1]])
407+ gn = int(giorno)
408+ if sesso == 'F':
409+ gn += 40
410 chars += list("%02d" % gn)
411 return chars
412
413 def _codicecontrollo(c):
414- """Restituisce il codice di controllo, l'ultimo carattere del C.F."""
415+ """Restituisce il codice di controllo l'ultimo carat. del C.F."""
416 sommone = 0
417 for i, car in enumerate(c):
418 j = 1 - i % 2
419@@ -99,9 +146,9 @@
420 return [LETTERE[resto]]
421
422 """Restituisce il C.F costruito sulla base degli argomenti."""
423- nome=nome.upper()
424- cognome=cognome.upper()
425- sesso=sesso.upper()
426+ nome = nome.upper()
427+ cognome = cognome.upper()
428+ sesso = sesso.upper()
429 cittanascita = cittanascita.upper()
430 chars = (_surname(cognome) +
431 _name(nome) +
432@@ -112,18 +159,48 @@
433
434 def compute_fc(self, cr, uid, ids, context):
435 active_id = context.get('active_id', [])
436- partner = self.pool.get('res.partner').browse(cr, uid, active_id, context)
437+ partner = self.pool.get('res.partner').browse(cr,
438+ uid,
439+ active_id,
440+ context)
441 form_obj = self.browse(cr, uid, ids, context)
442 for fields in form_obj:
443- if not fields.fiscalcode_surname or not fields.fiscalcode_firstname or not fields.birth_date or not fields.birth_city or not fields.sex:
444- raise osv.except_osv(_('Error'), _('One or more fields are missing'))
445+ if (
446+ not fields.fiscalcode_surname or
447+ not fields.fiscalcode_firstname or
448+ not fields.birth_date or
449+ not fields.birth_city or not fields.sex
450+ ):
451+ raise orm.except_orm(_('Error'),
452+ _('One or more fields are missing'))
453 if not fields.birth_city.cadaster_code:
454- raise osv.except_osv(_('Error'), _('Cataster code is missing'))
455- birth_date = datetime.datetime.strptime(fields.birth_date, "%Y-%m-%d")
456- CF = self._codicefiscale(fields.fiscalcode_surname, fields.fiscalcode_firstname, str(birth_date.day),
457+ raise orm.except_orm(_('Error'),
458+ _('Cataster code is missing'))
459+ birth_date = datetime.datetime.strptime(fields.birth_date,
460+ "%Y-%m-%d")
461+ CF = self._codicefiscale(
462+ fields.fiscalcode_surname,
463+ fields.fiscalcode_firstname,
464+ str(birth_date.day),
465 str(birth_date.month), str(birth_date.year), fields.sex,
466 fields.birth_city.cadaster_code)
467 if partner.fiscalcode and partner.fiscalcode != CF:
468- 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))
469- self.pool.get('res.partner').write(cr, uid, active_id, {'fiscalcode': CF, 'individual': True})
470+ raise orm.except_orm(
471+ _('Error'),
472+ _("""Existing fiscal code %s is different from the computed
473+ one (%s). If you want to use the computed one, remove
474+ the existing one') % (partner.fiscalcode, CF"""))
475+ self.pool.get('res.partner').write(
476+ cr, uid, active_id,
477+ {'fiscalcode': CF,
478+ 'individual': True,
479+ # Storicizzo in res.partner i dati usati dal wizard
480+ 'fiscalcode_surname': fields.fiscalcode_surname,
481+ 'fiscalcode_firstname': fields.fiscalcode_firstname,
482+ 'birth_date': fields.birth_date,
483+ 'birth_city': (
484+ fields.birth_city.id if fields.birth_city
485+ else False
486+ ),
487+ 'sex': fields.sex, })
488 return {}
489
490=== modified file 'l10n_it_fiscalcode/wizard/compute_fc_view.xml'
491--- l10n_it_fiscalcode/wizard/compute_fc_view.xml 2013-02-05 16:15:05 +0000
492+++ l10n_it_fiscalcode/wizard/compute_fc_view.xml 2013-11-13 12:56:08 +0000
493@@ -41,7 +41,7 @@
494 <field name="inherit_id" ref="l10n_it_fiscalcode.view_partner_form_fiscalcode_data"/>
495 <field name="arch" type="xml">
496 <field name="fiscalcode" position="after">
497- <button name="%(l10n_it_fiscalcode.action_compute_fc)d" string="Compute F.C." type="action" icon="gtk-execute" colspan="2"/>
498+ <button name="%(l10n_it_fiscalcode.action_compute_fc)d" string="Compute F.C." type="action" icon="gtk-execute" colspan="2" />
499 </field>
500 </field>
501 </record>

Subscribers

People subscribed via source and target branches