← Back to team overview

openobject-italia-core-devs team mailing list archive

[Merge] lp:~lpistone/openobject-italia/6.1-fiscalcode-to-data-lep into lp:openobject-italia/6.1

 

Leonardo Pistone - Agile BG - Domsense has proposed merging lp:~lpistone/openobject-italia/6.1-fiscalcode-to-data-lep into lp:openobject-italia/6.1.

Requested reviews:
  OpenERP Italia core devs (openobject-italia-core-devs)

For more details, see:
https://code.launchpad.net/~lpistone/openobject-italia/6.1-fiscalcode-to-data-lep/+merge/162736

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?
-- 
https://code.launchpad.net/~lpistone/openobject-italia/6.1-fiscalcode-to-data-lep/+merge/162736
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~lpistone/openobject-italia/6.1-fiscalcode-to-data-lep into lp:openobject-italia/6.1.
=== 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 @@
     'author': 'OpenERP Italian Community',
     'website': 'http://www.openerp-italia.org',
     'license': 'AGPL-3',
-    "depends" : ['base', 'l10n_it_base'],
-    "init_xml" : [
+    "depends": [
+        'base',
+        'l10n_it_base'
+    ],
+    "init_xml": [
         'fiscalcode_view.xml',
-        'wizard/compute_fc_view.xml'
-        ],
-    "update_xml" : [],
-    "demo_xml" : [],
+        'wizard/compute_fc_view.xml',
+        'wizard/fiscalcode_to_data_view.xml'
+    ],
+    "update_xml": [],
+    "demo_xml": [],
     'test': [
         'test/fiscalcode.yml',
-        ],
+    ],
     "active": False,
     "installable": True
 }

=== 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 @@
 #    (<http://www.openerp-italia.org>).
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
+#    it under the terms of the GNU Affero General Public License as published
+#    by the Free Software Foundation, either version 3 of the License, or
 #    (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
@@ -20,10 +20,7 @@
 ##############################################################################
 
 from osv import fields, osv
-import tools
-import pooler
-from tools.translate import _
-import datetime
+
 
 class res_partner(osv.osv):
     _inherit = 'res.partner'
@@ -39,13 +36,30 @@
                 return True
 
     _columns = {
-        'fiscalcode': fields.char('Fiscal Code', size=16, help="Italian Fiscal Code"),
-        'individual': fields.boolean('Individual', help="If checked the C.F. is referred to a Individual Person"),
+        'fiscalcode': fields.char(
+            'Fiscal Code', size=16, help="Italian Fiscal Code"
+        ),
+        'individual': fields.boolean(
+            'Individual',
+            help="If checked the C.F. is referred to a Individual Person"
+        ),
+        'birth_date': fields.date('Date of birth'),
+        'birth_city': fields.many2one('res.city', 'City of birth'),
+        'sex': fields.selection([
+            ('M', 'Male'),
+            ('F', 'Female'),
+        ], "Sex"),
     }
     _defaults = {
         'individual': False,
     }
-    _constraints = [(check_fiscalcode, "The fiscal code doesn't seem to be correct.", ["fiscalcode"])]
-    _sql_constraints = [
-        ('fiscalcode_uniq', 'unique (fiscalcode, company_id)', 'The fiscal code must be unique per company !'),
-        ]
+    _constraints = [(
+        check_fiscalcode,
+        "The fiscal code doesn't seem to be correct.",
+        ["fiscalcode"]
+    )]
+    _sql_constraints = [(
+        'fiscalcode_uniq',
+        'unique (fiscalcode, company_id)',
+        'The fiscal code must be unique per company !'
+    ), ]

=== 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 @@
                     <separator string="Fiscal Data" colspan="6"/>
                         <field name="fiscalcode"/>
                         <field name="individual" colspan="1" groups="base.group_extended" />
+                        <field name="birth_date"/>
+                        <field name="birth_city"/>
+                        <field name="sex"/>
                 </field>
             </field>
         </record>

=== 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 @@
 msgstr ""
 "Project-Id-Version: OpenERP Server 6.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-12-05 10:00+0000\n"
-"PO-Revision-Date: 2012-12-05 11:02+0100\n"
-"Last-Translator: Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>\n"
+"POT-Creation-Date: 2013-05-07 09:23+0000\n"
+"PO-Revision-Date: 2013-05-07 09:23+0000\n"
+"Last-Translator: <>\n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
+"Content-Transfer-Encoding: \n"
 "Plural-Forms: \n"
 
 #. module: l10n_it_fiscalcode
@@ -21,6 +21,12 @@
 msgstr "Se selezionato il Cofice Fiscale farà riferimento a quello di una Persona Fisica"
 
 #. module: l10n_it_fiscalcode
+#: view:partner.sms.send:0
+msgid "SMS - Gateway: clickatell"
+msgstr "SMS - Gateway: clickatell"
+
+#. module: l10n_it_fiscalcode
+#: field:res.partner,birth_date:0
 #: field:wizard.compute.fc,birth_date:0
 msgid "Date of birth"
 msgstr "Data di nascita"
@@ -38,6 +44,11 @@
 msgstr "Calcola il Codice Fiscale"
 
 #. module: l10n_it_fiscalcode
+#: view:partner.sms.send:0
+msgid "Bulk SMS send"
+msgstr "Invio SMS di massa"
+
+#. module: l10n_it_fiscalcode
 #: field:wizard.compute.fc,fiscalcode_firstname:0
 msgid "First name"
 msgstr "Nome"
@@ -53,38 +64,83 @@
 msgstr "Dati Fiscali"
 
 #. module: l10n_it_fiscalcode
+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:75
+#, python-format
+msgid "More than one city with cadaster code %s"
+msgstr "Più di una città ha il codice catastale %s"
+
+#. module: l10n_it_fiscalcode
+#: field:res.partner,birth_city:0
 #: field:wizard.compute.fc,birth_city:0
 msgid "City of birth"
 msgstr "Città di Nascita"
 
 #. module: l10n_it_fiscalcode
+#: view:partner.sms.send:0
+msgid "Send SMS"
+msgstr "Invia SMS"
+
+#. module: l10n_it_fiscalcode
+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:69
+#, python-format
+msgid "City with cadaster code %s not found"
+msgstr "Città con codice catastale %s non trovata"
+
+#. module: l10n_it_fiscalcode
 #: view:wizard.compute.fc:0
+#: view:wizard.fiscalcode.to.data:0
 msgid "Compute"
 msgstr "Calcola"
 
 #. module: l10n_it_fiscalcode
+#: model:ir.actions.act_window,name:l10n_it_fiscalcode.action_fiscalcode_to_data
+#: model:ir.model,name:l10n_it_fiscalcode.model_wizard_fiscalcode_to_data
+#: view:wizard.fiscalcode.to.data:0
+msgid "Compute missing data from Fiscal Code"
+msgstr "Ricava i dati mancanti dal Codice Fiscale"
+
+#. module: l10n_it_fiscalcode
+#: field:wizard.fiscalcode.to.data,update_birth_city:0
+msgid "Update city of birth"
+msgstr "Aggiorna la città di nascita"
+
+#. module: l10n_it_fiscalcode
 #: constraint:res.partner:0
 msgid "The fiscal code doesn't seem to be correct."
 msgstr "Il Codice Fiscale non sembra corretto per una Persona Fisica."
 
 #. module: l10n_it_fiscalcode
+#: field:wizard.fiscalcode.to.data,update_sex:0
+msgid "Update sex"
+msgstr "Aggiorna il sesso"
+
+#. module: l10n_it_fiscalcode
 #: sql_constraint:res.partner:0
 msgid "The fiscal code must be unique per company !"
 msgstr "Il codice fiscale deve essere unico!"
 
 #. module: l10n_it_fiscalcode
-#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:126
+#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:148
+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:68
+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:74
+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:86
 #, python-format
 msgid "Error"
 msgstr "Errore"
 
 #. module: l10n_it_fiscalcode
+#: selection:res.partner,sex:0
 #: selection:wizard.compute.fc,sex:0
 msgid "Male"
 msgstr "Maschio"
 
 #. module: l10n_it_fiscalcode
-#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:126
+#: view:partner.sms.send:0
+msgid "Message"
+msgstr "Message"
+
+#. module: l10n_it_fiscalcode
+#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:149
 #, python-format
 msgid "Existing fiscal code %s is different from the computed one (%s). If you want to use the computed one, remove the existing one"
 msgstr "Il codice fiscale sistente %s è diverso da quello calcolato (%s). Se si vuole usare quello calcolato, rimuovere quello esistente."
@@ -95,6 +151,13 @@
 msgstr "Cognome"
 
 #. module: l10n_it_fiscalcode
+#: code:addons/l10n_it_fiscalcode/wizard/fiscalcode_to_data.py:87
+#, python-format
+msgid "Fiscal code %s: Invalid month code %s"
+msgstr "Codice Fiscale %s: Codice mese invalido %s"
+
+#. module: l10n_it_fiscalcode
+#: field:res.partner,sex:0
 #: field:wizard.compute.fc,sex:0
 msgid "Sex"
 msgstr "Sesso"
@@ -110,12 +173,15 @@
 msgstr "Persona Fisica"
 
 #. module: l10n_it_fiscalcode
+#: selection:res.partner,sex:0
 #: selection:wizard.compute.fc,sex:0
 msgid "Female"
 msgstr "Femmina"
 
 #. module: l10n_it_fiscalcode
+#: view:partner.sms.send:0
 #: view:wizard.compute.fc:0
+#: view:wizard.fiscalcode.to.data:0
 msgid "Cancel"
 msgstr "Annulla"
 
@@ -129,3 +195,8 @@
 msgid "Compute F.C."
 msgstr "Calcola C.F."
 
+#. module: l10n_it_fiscalcode
+#: field:wizard.fiscalcode.to.data,update_birth_date:0
+msgid "Update date of birth"
+msgstr "Aggiorna la data di nascita"
+

=== 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 @@
 #    (<http://www.openerp-italia.org>).
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
+#    it under the terms of the GNU Affero General Public License as published
+#    by the Free Software Foundation, either version 3 of the License, or
 #    (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
@@ -20,4 +20,4 @@
 ##############################################################################
 
 import compute_fc
-
+import fiscalcode_to_data

=== 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 @@
 #    (<http://www.openerp-italia.org>).
 #
 #    This program is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU Affero General Public License as published by
-#    the Free Software Foundation, either version 3 of the License, or
+#    it under the terms of the GNU Affero General Public License as published
+#    by the Free Software Foundation, either version 3 of the License, or
 #    (at your option) any later version.
 #
 #    This program is distributed in the hope that it will be useful,
@@ -20,12 +20,11 @@
 ##############################################################################
 
 from osv import fields, osv
-import tools
-import pooler
 from tools.translate import _
 
 import datetime
 
+
 class wizard_compute_fc(osv.osv_memory):
 
     _name = "wizard.compute.fc"
@@ -35,13 +34,14 @@
         'fiscalcode_firstname': fields.char('First name', size=64),
         'birth_date': fields.date('Date of birth'),
         'birth_city': fields.many2one('res.city', 'City of birth'),
-        'sex': fields.selection([('M','Male'),
-                                 ('F', 'Female'),
-                                ], "Sex"),
+        'sex': fields.selection([
+            ('M', 'Male'),
+            ('F', 'Female')
+        ], "Sex"),
     }
 
-
-    def _codicefiscale(self, cognome, nome, giornonascita, mesenascita, annonascita, sesso, cittanascita):
+    def _codicefiscale(self, cognome, nome, giornonascita, mesenascita,
+                       annonascita, sesso, cittanascita):
 
         MESI = 'ABCDEHLMPRST'
         CONSONANTI = 'BCDFGHJKLMNPQRSTVWXYZ'
@@ -49,48 +49,53 @@
         LETTERE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 
         REGOLECONTROLLO = {
-            'A':(0,1),   'B':(1,0),   'C':(2,5),   'D':(3,7),   'E':(4,9),
-            'F':(5,13),  'G':(6,15),  'H':(7,17),  'I':(8,19),  'J':(9,21),
-            'K':(10,2),  'L':(11,4),  'M':(12,18), 'N':(13,20), 'O':(14,11),
-            'P':(15,3),  'Q':(16,6),  'R':(17,8),  'S':(18,12), 'T':(19,14),
-            'U':(20,16), 'V':(21,10), 'W':(22,22), 'X':(23,25), 'Y':(24,24),
-            'Z':(25,23),
-            '0':(0,1),   '1':(1,0),   '2':(2,5),   '3':(3,7),   '4':(4,9),
-            '5':(5,13),  '6':(6,15),  '7':(7,17),  '8':(8,19),  '9':(9,21)
+            'A': (0, 1), 'B': (1, 0), 'C': (2, 5), 'D': (3, 7), 'E': (4, 9),
+            'F': (5, 13), 'G': (6, 15), 'H': (7, 17), 'I': (8, 19),
+            'J': (9, 21), 'K': (10, 2), 'L': (11, 4), 'M': (12, 18),
+            'N': (13, 20), 'O': (14, 11), 'P': (15, 3), 'Q': (16, 6),
+            'R': (17, 8), 'S': (18, 12), 'T': (19, 14), 'U': (20, 16),
+            'V': (21, 10), 'W': (22, 22), 'X': (23, 25), 'Y': (24, 24),
+            'Z': (25, 23),
+            '0': (0, 1), '1': (1, 0), '2': (2, 5), '3': (3, 7), '4': (4, 9),
+            '5': (5, 13), '6': (6, 15), '7': (7, 17), '8': (8, 19),
+            '9': (9, 21)
         }
 
         """Funzioni per il calcolo del C.F."""
         def _surname(stringa):
-            """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""
+            """Ricava, da stringa, 3 lettere in base alla convenzione dei
+            C.F."""
             cons = [c for c in stringa if c in CONSONANTI]
             voc = [c for c in stringa if c in VOCALI]
-            chars=cons+voc
-            if len(chars)<3:
-                chars+=['X', 'X']
+            chars = cons + voc
+            if len(chars) < 3:
+                chars += ['X', 'X']
             return chars[:3]
 
         def _name(stringa):
-            """Ricava, da stringa, 3 lettere in base alla convenzione dei C.F."""
+            """Ricava, da stringa, 3 lettere in base alla convenzione dei
+            C.F."""
             cons = [c for c in stringa if c in CONSONANTI]
             voc = [c for c in stringa if c in VOCALI]
-            if len(cons)>3:
-                cons = [cons[0]] +[cons[2]] + [cons[3]]
-            chars=cons+voc
-            if len(chars)<3:
-                chars+=['X', 'X']
+            if len(cons) > 3:
+                cons = [cons[0]] + [cons[2]] + [cons[3]]
+            chars = cons + voc
+            if len(chars) < 3:
+                chars += ['X', 'X']
             return chars[:3]
 
         def _datan(giorno, mese, anno, sesso):
             """Restituisce il campo data del CF."""
-            chars = (list(anno[-2:]) + [MESI[int(mese)-1]])
-            gn=int(giorno)
-            if sesso=='F':
-                gn+=40
+            chars = (list(anno[-2:]) + [MESI[int(mese) - 1]])
+            gn = int(giorno)
+            if sesso == 'F':
+                gn += 40
             chars += list("%02d" % gn)
             return chars
 
         def _codicecontrollo(c):
-            """Restituisce il codice di controllo, l'ultimo carattere del C.F."""
+            """Restituisce il codice di controllo, l'ultimo carattere del
+            C.F."""
             sommone = 0
             for i, car in enumerate(c):
                 j = 1 - i % 2
@@ -99,9 +104,9 @@
             return [LETTERE[resto]]
 
         """Restituisce il C.F costruito sulla base degli argomenti."""
-        nome=nome.upper()
-        cognome=cognome.upper()
-        sesso=sesso.upper()
+        nome = nome.upper()
+        cognome = cognome.upper()
+        sesso = sesso.upper()
         cittanascita = cittanascita.upper()
         chars = (_surname(cognome) +
                  _name(nome) +
@@ -112,16 +117,41 @@
 
     def compute_fc(self, cr, uid, ids, context):
         active_id = context.get('active_id', [])
-        partner = self.pool.get('res.partner').browse(cr, uid, active_id, context)
+        partner = self.pool.get('res.partner').browse(
+            cr, uid, active_id, context
+        )
         form_obj = self.browse(cr, uid, ids, context)
         for fields in form_obj:
-            if not fields.fiscalcode_surname or not fields.fiscalcode_firstname or not fields.birth_date or not fields.birth_city or not fields.sex:
+            if (
+                not fields.fiscalcode_surname or
+                not fields.fiscalcode_firstname or
+                not fields.birth_date or
+                not fields.birth_city or
+                not fields.sex
+            ):
                 raise osv.except_osv('Error', 'One or more fields are missing')
-            birth_date = datetime.datetime.strptime(fields.birth_date, "%Y-%m-%d")
-            CF = self._codicefiscale(fields.fiscalcode_surname, fields.fiscalcode_firstname, str(birth_date.day),
-                str(birth_date.month), str(birth_date.year), fields.sex,
-                fields.birth_city.cadaster_code)
+            birth_date = datetime.datetime.strptime(
+                fields.birth_date,
+                "%Y-%m-%d"
+            )
+            CF = self._codicefiscale(
+                fields.fiscalcode_surname,
+                fields.fiscalcode_firstname,
+                str(birth_date.day),
+                str(birth_date.month),
+                str(birth_date.year),
+                fields.sex,
+                fields.birth_city.cadaster_code
+            )
             if partner.fiscalcode and partner.fiscalcode != CF:
-                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))
-            self.pool.get('res.partner').write(cr, uid, active_id, {'fiscalcode': CF, 'individual': True})
+                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))
+            self.pool.get('res.partner').write(cr, uid, active_id, {
+                'fiscalcode': CF,
+                'individual': True
+            })
         return {}

=== 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 @@
 <?xml version="1.0" ?>
 <openerp>
-	<data>
+    <data>
 
         <record id="wizard_compute_fc_form" model="ir.ui.view">
             <field name="name">wizard.compute.fc.form</field>
@@ -46,5 +46,29 @@
             </field>
         </record>
 
-	</data>
+<!-- Create Menu From view -->
+
+        <record id="view_partner_sms_send" model="ir.ui.view">
+            <field name="name">Send SMS</field>
+            <field name="model">partner.sms.send</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+              <form string="SMS - Gateway: clickatell">
+                    <separator string="Bulk SMS send" colspan="4"/>
+                    <field name="mobile_to"/>
+                    <field name="app_id"/>
+                    <field name="user"/>
+                    <field name="password"/>
+                    <separator string="Message" colspan="4" />
+                    <field name="text" colspan="4" nolabel="1"/>
+                    <separator string="" colspan="4" />
+                    <group colspan="4" col="6">
+                        <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+                        <button name="sms_send" string="Send SMS" type="object" icon="terp-mail-message-new"/>
+                    </group>
+             </form>
+            </field>
+        </record>
+
+    </data>
 </openerp>

=== 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 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2010-2012 Associazione OpenERP Italia
+#    (<http://www.openerp-italia.org>).
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as published
+#    by the Free Software Foundation, either version 3 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields, osv
+from tools.translate import _
+from datetime import datetime
+
+
+class wizard_fiscalcode_to_data(osv.osv_memory):
+
+    _name = "wizard.fiscalcode.to.data"
+    _description = "Compute missing data from Fiscal Code"
+    _columns = {
+        'update_birth_date': fields.boolean('Update date of birth'),
+        'update_birth_city': fields.boolean('Update city of birth'),
+        'update_sex': fields.boolean('Update sex'),
+    }
+
+    _defaults = {
+        'update_birth_date': True,
+        'update_birth_city': True,
+        'update_sex': True,
+    }
+
+    def compute(self, cr, uid, ids, context):
+        partner_obj = self.pool.get('res.partner')
+        city_obj = self.pool.get('res.city')
+        # leading space so that position is the month number
+        month_codes = ' ABCDEHLMPRST'
+        for wiz in self.browse(cr, uid, ids):
+            for partner in partner_obj.browse(cr, uid, context['active_ids']):
+                if partner.fiscalcode:
+                    # maybe check fiscalcode sanity here?
+                    data = {}
+                    if wiz.update_sex and not partner.sex:
+                        try:
+                            day = int(partner.fiscalcode[9:11])
+                        except Exception:
+                            ### XXX handle insane fc here
+                            raise
+                        sex = day > 40 and 'F' or 'M'
+                        data['sex'] = sex
+                    if wiz.update_birth_city and not partner.birth_city:
+                        cadaster_code = partner.fiscalcode[11:15]
+                        birth_city = city_obj.search(cr, uid, [
+                            ('cadaster_code', '=', cadaster_code)
+                        ])
+                        if not birth_city:
+                            raise osv.except_osv(
+                                _('Error'),
+                                _('City with cadaster code %s not found')
+                                % cadaster_code
+                            )
+                        if len(birth_city) > 1:
+                            raise osv.except_osv(
+                                _('Error'),
+                                _('More than one city with cadaster code %s')
+                                % cadaster_code
+                            )
+                        data['birth_city'] = birth_city[0]
+                    if wiz.update_birth_date:
+                        year = int(partner.fiscalcode[6:8])
+                        day = int(partner.fiscalcode[9:11])
+                        day = day > 40 and day - 40 or day
+                        month = month_codes.find(partner.fiscalcode[8])
+                        if month == -1:
+                            raise osv.except_osv(
+                                _('Error'),
+                                _('Fiscal code %s: Invalid month code %s')
+                                % (partner.fiscalcode, partner.fiscalcode[8])
+                            )
+
+                        # Don't format the date string directly to work out
+                        # the century
+                        d = datetime.strptime(
+                            '{}{}{}'.format(year, month, day), '%y%m%d'
+                        )
+                        if d > datetime.now():
+                            d = datetime(d.year - 100, d.month, d.day)
+                        data['birth_date'] = d.strftime('%Y-%m-%d')
+                    if data:
+                        partner_obj.write(cr, uid, partner.id, data)
+
+        return {}

=== 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 @@
+<openerp>
+    <data>
+
+        <record id="view_wizard_fiscalcode_to_data" model="ir.ui.view">
+            <field name="name">Compute missing data from Fiscal Code</field>
+            <field name="model">wizard.fiscalcode.to.data</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+              <form string="Compute missing data from Fiscal Code">
+                    <group colspan="4" col="6">
+                        <field name="update_birth_date"/>
+                        <field name="update_birth_city"/>
+                        <field name="update_sex"/>
+                    </group>
+                    <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+                    <button name="compute" string="Compute" type="object" icon="gtk-ok"/>
+             </form>
+            </field>
+        </record>
+
+       <act_window name="Compute missing data from Fiscal Code"
+            res_model="wizard.fiscalcode.to.data"
+            src_model="res.partner"
+            view_mode="form"
+            target="new"
+            key2="client_action_multi"
+            id="action_fiscalcode_to_data"/>
+
+    </data>
+</openerp>
\ No newline at end of file


Follow ups