← Back to team overview

openobject-italia-core-devs team mailing list archive

lp:~lpistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-lep into lp:openobject-italia/6.1

 

Leonardo Pistone - Agile BG - Domsense has proposed merging lp:~lpistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-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-l10n_it_account-lep/+merge/162763

Questa MP sostituisce:

https://code.launchpad.net/~lpistone/openobject-italia/6.1-fiscalcode-to-data-lep/+merge/162736
-- 
https://code.launchpad.net/~lpistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-lep/+merge/162763
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~lpistone/openobject-italia/6.1-fiscalcode-to-data-l10n_it_account-lep into lp:openobject-italia/6.1.
=== modified file 'l10n_it_account/AUTHORS.txt'
--- l10n_it_account/AUTHORS.txt	2012-10-19 16:06:38 +0000
+++ l10n_it_account/AUTHORS.txt	2013-05-07 12:30:45 +0000
@@ -6,4 +6,4 @@
 Giovanni Barzan <giovanni.barzan@xxxxxxxxx>
 Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
 Roberto Onnis <onnis.roberto@xxxxxxxxx>
-
+Leonardo Pistone <leonardo.pistone@xxxxxxxxxxx>

=== modified file 'l10n_it_account/__init__.py'
--- l10n_it_account/__init__.py	2013-01-04 14:02:10 +0000
+++ l10n_it_account/__init__.py	2013-05-07 12:30:45 +0000
@@ -20,5 +20,7 @@
 ##############################################################################
 
 import account
+import wizard
+
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 

=== modified file 'l10n_it_account/__openerp__.py'
--- l10n_it_account/__openerp__.py	2013-01-04 14:02:10 +0000
+++ l10n_it_account/__openerp__.py	2013-05-07 12:30:45 +0000
@@ -34,7 +34,10 @@
     'website': 'http://www.openerp-italia.org',
     'license': 'AGPL-3',
     "depends" : ['account','base_vat','account_chart','base_iban', 'l10n_it_base'],
-    "init_xml" : ['account/partner_view.xml'],
+    "init_xml": [
+        'account/partner_view.xml',
+        'wizard/fiscalcode_to_data_view.xml',
+    ],
     "update_xml" : [],
     "demo_xml" : [],
     "active": False,

=== modified file 'l10n_it_account/i18n/it.po'
--- l10n_it_account/i18n/it.po	2011-05-05 16:46:44 +0000
+++ l10n_it_account/i18n/it.po	2013-05-07 12:30:45 +0000
@@ -4,10 +4,10 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: OpenERP Server 6.0.2\n"
-"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
-"POT-Creation-Date: 2011-05-05 16:45+0000\n"
-"PO-Revision-Date: 2011-05-05 16:45+0000\n"
+"Project-Id-Version: OpenERP Server 6.1\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-05-07 12:00+0000\n"
+"PO-Revision-Date: 2013-05-07 12:00+0000\n"
 "Last-Translator: <>\n"
 "Language-Team: \n"
 "MIME-Version: 1.0\n"
@@ -16,25 +16,71 @@
 "Plural-Forms: \n"
 
 #. module: l10n_it_account
+#: field:res.partner,birth_date:0
+msgid "Date of birth"
+msgstr "Data di nascita"
+
+#. module: l10n_it_account
+#: view:res.partner:0
+#: field:res.partner,fiscalcode:0
+msgid "Fiscal Code"
+msgstr "Codice fiscale"
+
+#. module: l10n_it_account
+#: view:res.partner:0
+msgid "Compute Fiscal Code"
+msgstr "Calcola codice fiscale"
+
+#. module: l10n_it_account
+#: field:res.partner,fiscalcode_firstname:0
+msgid "First name"
+msgstr "Nome"
+
+#. module: l10n_it_account
+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:75
+#, python-format
+msgid "More than one city with cadaster code %s"
+msgstr "Più di una città ha codice catastale %s"
+
+#. module: l10n_it_account
+#: field:res.partner,birth_city:0
+msgid "City of birth"
+msgstr "Città di nascita"
+
+#. module: l10n_it_account
 #: code:addons/l10n_it_account/account/invoice.py:45
 #, python-format
 msgid "Cannot create invoice! Post the invoice with a greater date"
 msgstr "Impossibile registrare la fattura in contabilità! Esistono fatture registrate con data successiva alla fattura corrente; inserisci una data superiore per il documento"
 
 #. module: l10n_it_account
+#: code:addons/l10n_it_account/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_account
 #: view:res.partner:0
+#: view:wizard.fiscalcode.to.data:0
 msgid "Compute"
 msgstr "Calcola"
 
 #. module: l10n_it_account
-#: model:ir.model,name:l10n_it_account.model_account_invoice
-msgid "Invoice"
-msgstr "Fattura"
-
-#. module: l10n_it_account
-#: field:res.partner,birth_date:0
-msgid "Date of birth"
-msgstr "Data di nascita"
+#: selection:res.partner,sex:0
+msgid "Female"
+msgstr "Femmina"
+
+#. module: l10n_it_account
+#: model:ir.actions.act_window,name:l10n_it_account.action_fiscalcode_to_data
+#: model:ir.model,name:l10n_it_account.model_wizard_fiscalcode_to_data
+#: view:wizard.fiscalcode.to.data:0
+msgid "Compute missing data from Fiscal Code"
+msgstr "Recupera i dati mancanti dal Codice Fiscale"
+
+#. module: l10n_it_account
+#: field:wizard.fiscalcode.to.data,update_birth_city:0
+msgid "Update city of birth"
+msgstr "Aggiorna la città di nascita"
 
 #. module: l10n_it_account
 #: view:res.partner:0
@@ -42,22 +88,49 @@
 msgstr "Note"
 
 #. module: l10n_it_account
-#: model:ir.module.module,description:l10n_it_account.module_meta_information
-msgid "This module customizes OpenERP in order to fit italian laws and mores - Account version\n"
-"\n"
-"Functionalities:\n"
-"\n"
-"- Fiscal code computation for partner\n"
-"- Check invoice date consistency\n"
-"\n"
-""
-msgstr "Questo modulo personalizza OpenERP al fine di rispettare le leggi e le usanze italiane - Versione contabilità\n"
-"Funzionalità:\n"
-"\n"
-"- Calcolo del codice fiscale sul partner\n"
-"- Controllo della consistenza delle date delle fatture\n"
-"\n"
-""
+#: field:wizard.fiscalcode.to.data,update_sex:0
+msgid "Update sex"
+msgstr "Aggiorna il sesso"
+
+#. module: l10n_it_account
+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:68
+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:74
+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:86
+#, python-format
+msgid "Error"
+msgstr "Errore"
+
+#. module: l10n_it_account
+#: selection:res.partner,sex:0
+msgid "Male"
+msgstr "Maschio"
+
+#. module: l10n_it_account
+#: code:addons/l10n_it_account/account/invoice.py:44
+#, python-format
+msgid "Date Inconsistency"
+msgstr "Inconsistenza nelle date"
+
+#. module: l10n_it_account
+#: sql_constraint:account.invoice:0
+msgid "Invoice Number must be unique per Company!"
+msgstr "Nell'azienda il numero fattura dev'essere univoco!"
+
+#. module: l10n_it_account
+#: field:res.partner,fiscalcode_surname:0
+msgid "Surname"
+msgstr "Cognome"
+
+#. module: l10n_it_account
+#: code:addons/l10n_it_account/wizard/fiscalcode_to_data.py:87
+#, python-format
+msgid "Fiscal code %s: Invalid month code %s"
+msgstr "Codice Fiscale %s: codice mese non valido %s"
+
+#. module: l10n_it_account
+#: field:res.partner,sex:0
+msgid "Sex"
+msgstr "Sesso"
 
 #. module: l10n_it_account
 #: help:res.partner,fiscalcode:0
@@ -65,35 +138,14 @@
 msgstr "Codice Fiscale Italiano"
 
 #. module: l10n_it_account
-#: field:res.partner,sex:0
-msgid "Sex"
-msgstr "Sesso"
-
-#. module: l10n_it_account
-#: field:res.partner,fiscalcode_surname:0
-msgid "Surname"
-msgstr "Cognome"
-
-#. module: l10n_it_account
-#: field:res.partner,fiscalcode_firstname:0
-msgid "First name"
-msgstr "Nome"
-
-#. module: l10n_it_account
-#: view:res.partner:0
-#: field:res.partner,fiscalcode:0
-msgid "Fiscal Code"
-msgstr "Codice fiscale"
-
-#. module: l10n_it_account
-#: model:ir.module.module,shortdesc:l10n_it_account.module_meta_information
-msgid "Italian Localisation - Account"
-msgstr "Localizzazione Italiana - Contabilità"
-
-#. module: l10n_it_account
-#: selection:res.partner,sex:0
-msgid "Female"
-msgstr "Femmina"
+#: model:ir.model,name:l10n_it_account.model_account_invoice
+msgid "Invoice"
+msgstr "Fattura"
+
+#. module: l10n_it_account
+#: view:wizard.fiscalcode.to.data:0
+msgid "Cancel"
+msgstr "Annulla"
 
 #. module: l10n_it_account
 #: model:ir.model,name:l10n_it_account.model_res_partner
@@ -101,23 +153,7 @@
 msgstr "Partner"
 
 #. module: l10n_it_account
-#: view:res.partner:0
-msgid "Compute Fiscal Code"
-msgstr "Calcola codice fiscale"
-
-#. module: l10n_it_account
-#: selection:res.partner,sex:0
-msgid "Male"
-msgstr "Maschio"
-
-#. module: l10n_it_account
-#: code:addons/l10n_it_account/account/invoice.py:44
-#, python-format
-msgid "Date Inconsistency"
-msgstr "Inconsistenza nelle date"
-
-#. module: l10n_it_account
-#: field:res.partner,birth_city:0
-msgid "City of birth"
-msgstr "Città natale"
+#: field:wizard.fiscalcode.to.data,update_birth_date:0
+msgid "Update date of birth"
+msgstr "Aggiorna la data di nascita"
 

=== added directory 'l10n_it_account/wizard'
=== added file 'l10n_it_account/wizard/__init__.py'
--- l10n_it_account/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ l10n_it_account/wizard/__init__.py	2013-05-07 12:30:45 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 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/>.
+#
+##############################################################################
+
+import fiscalcode_to_data

=== added file 'l10n_it_account/wizard/fiscalcode_to_data.py'
--- l10n_it_account/wizard/fiscalcode_to_data.py	1970-01-01 00:00:00 +0000
+++ l10n_it_account/wizard/fiscalcode_to_data.py	2013-05-07 12:30:45 +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_account/wizard/fiscalcode_to_data_view.xml'
--- l10n_it_account/wizard/fiscalcode_to_data_view.xml	1970-01-01 00:00:00 +0000
+++ l10n_it_account/wizard/fiscalcode_to_data_view.xml	2013-05-07 12:30:45 +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