openobject-italia-core-devs team mailing list archive
-
openobject-italia-core-devs team
-
Mailing list archive
-
Message #01087
[Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
Andrea Cometa has proposed merging lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0.
Requested reviews:
OpenERP Italia core devs (openobject-italia-core-devs)
For more details, see:
https://code.launchpad.net/~scigghia/openobject-italia/add_fiscalcode/+merge/146667
--
https://code.launchpad.net/~scigghia/openobject-italia/add_fiscalcode/+merge/146667
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0.
=== added directory 'l10n_it_fiscalcode'
=== added file 'l10n_it_fiscalcode/AUTHORS.txt'
--- l10n_it_fiscalcode/AUTHORS.txt 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/AUTHORS.txt 2013-02-05 16:24:41 +0000
@@ -0,0 +1,10 @@
+Davide Corio <davide.corio@xxxxxxxxxxxx>
+Luca Subiaco <subluca@xxxxxxxxx>
+Simone Orsi <simone.orsi@xxxxxxxxxxxx>
+Mario Riva <mario.riva@xxxxxxxxxxxx>
+Mauro Soligo <mauro.soligo@xxxxxxxxxx>
+Giovanni Barzan <giovanni.barzan@xxxxxxxxx>
+Lorenzo Battistini <lorenzo.battistini@xxxxxxxxxxx>
+Roberto Onnis <onnis.roberto@xxxxxxxxx>
+Franco Tampieri <franco.tampieri@xxxxxxxxxxx>
+Andrea Cometa <info@xxxxxxxxxxxxxxx>
=== added file 'l10n_it_fiscalcode/__init__.py'
--- l10n_it_fiscalcode/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/__init__.py 2013-02-05 16:24:41 +0000
@@ -0,0 +1,24 @@
+# -*- 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
+import wizard
+
=== added file 'l10n_it_fiscalcode/__openerp__.py'
--- l10n_it_fiscalcode/__openerp__.py 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/__openerp__.py 2013-02-05 16:24:41 +0000
@@ -0,0 +1,48 @@
+# -*- 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/>.
+#
+##############################################################################
+{
+ 'name': 'Italian Localisation - Fiscal Code',
+ 'version': '0.1',
+ 'category': 'Localisation/Italy',
+ 'description': """
+This module customizes OpenERP in order to fit italian laws and mores - Account version
+
+Functionalities:
+
+- Fiscal code computation for partner
+
+""",
+ 'author': 'OpenERP Italian Community',
+ 'website': 'http://www.openerp-italia.org',
+ 'license': 'AGPL-3',
+ "depends" : ['base', 'l10n_it_base'],
+ "init_xml" : [
+ 'fiscalcode_view.xml',
+ 'wizard/compute_fc_view.xml'
+ ],
+ "update_xml" : [],
+ "demo_xml" : [],
+ 'test': [
+ 'test/fiscalcode.yml',
+ ],
+ "active": False,
+ "installable": True
+}
=== added file 'l10n_it_fiscalcode/fiscalcode.py'
--- l10n_it_fiscalcode/fiscalcode.py 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/fiscalcode.py 2013-02-05 16:24:41 +0000
@@ -0,0 +1,51 @@
+# -*- 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
+import tools
+import pooler
+from tools.translate import _
+import datetime
+
+class res_partner(osv.osv):
+ _inherit = 'res.partner'
+
+ def check_fiscalcode(self, cr, uid, ids, context={}):
+
+ for partner in self.browse(cr, uid, ids):
+ if not partner.fiscalcode:
+ return True
+ elif len(partner.fiscalcode) != 16 and partner.individual:
+ return False
+ else:
+ 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"),
+ }
+ _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 !'),
+ ]
=== added file 'l10n_it_fiscalcode/fiscalcode_view.xml'
--- l10n_it_fiscalcode/fiscalcode_view.xml 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/fiscalcode_view.xml 2013-02-05 16:24:41 +0000
@@ -0,0 +1,19 @@
+<?xml version="1.0" ?>
+<openerp>
+ <data>
+
+ <record id="view_partner_form_fiscalcode_data" model="ir.ui.view">
+ <field name="name">res.partner.fiscalcode.data</field>
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="base.view_partner_form"/>
+ <field name="arch" type="xml">
+ <field name="lang" position="after">
+ <separator string="Fiscal Data" colspan="6"/>
+ <field name="fiscalcode"/>
+ <field name="individual" colspan="1" groups="base.group_extended" />
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
=== added directory 'l10n_it_fiscalcode/i18n'
=== added file 'l10n_it_fiscalcode/i18n/it.mo'
Binary files l10n_it_fiscalcode/i18n/it.mo 1970-01-01 00:00:00 +0000 and l10n_it_fiscalcode/i18n/it.mo 2013-02-05 16:24:41 +0000 differ
=== added file 'l10n_it_fiscalcode/i18n/it.po'
--- l10n_it_fiscalcode/i18n/it.po 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/i18n/it.po 2013-02-05 16:24:41 +0000
@@ -0,0 +1,131 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * l10n_it_fiscalcode
+#
+msgid ""
+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"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: \n"
+
+#. module: l10n_it_fiscalcode
+#: help:res.partner,individual:0
+msgid "If checked the C.F. is referred to a Individual Person"
+msgstr "Se selezionato il Cofice Fiscale farà riferimento a quello di una Persona Fisica"
+
+#. module: l10n_it_fiscalcode
+#: field:wizard.compute.fc,birth_date:0
+msgid "Date of birth"
+msgstr "Data di nascita"
+
+#. module: l10n_it_fiscalcode
+#: field:res.partner,fiscalcode:0
+#: view:wizard.compute.fc:0
+msgid "Fiscal Code"
+msgstr "Codice Fiscale"
+
+#. module: l10n_it_fiscalcode
+#: model:ir.actions.act_window,name:l10n_it_fiscalcode.action_compute_fc
+#: model:ir.model,name:l10n_it_fiscalcode.model_wizard_compute_fc
+msgid "Compute Fiscal Code"
+msgstr "Calcola il Codice Fiscale"
+
+#. module: l10n_it_fiscalcode
+#: field:wizard.compute.fc,fiscalcode_firstname:0
+msgid "First name"
+msgstr "Nome"
+
+#. module: l10n_it_fiscalcode
+#: view:wizard.compute.fc:0
+msgid "Individual Data"
+msgstr "Dati Persona Fisica"
+
+#. module: l10n_it_fiscalcode
+#: view:res.partner:0
+msgid "Fiscal Data"
+msgstr "Dati Fiscali"
+
+#. module: l10n_it_fiscalcode
+#: field:wizard.compute.fc,birth_city:0
+msgid "City of birth"
+msgstr "Città di Nascita"
+
+#. module: l10n_it_fiscalcode
+#: view:wizard.compute.fc:0
+msgid "Compute"
+msgstr "Calcola"
+
+#. 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
+#: 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
+#, python-format
+msgid "Error"
+msgstr "Errore"
+
+#. module: l10n_it_fiscalcode
+#: selection:wizard.compute.fc,sex:0
+msgid "Male"
+msgstr "Maschio"
+
+#. module: l10n_it_fiscalcode
+#: code:addons/l10n_it_fiscalcode/wizard/compute_fc.py:126
+#, 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."
+
+#. module: l10n_it_fiscalcode
+#: field:wizard.compute.fc,fiscalcode_surname:0
+msgid "Surname"
+msgstr "Cognome"
+
+#. module: l10n_it_fiscalcode
+#: field:wizard.compute.fc,sex:0
+msgid "Sex"
+msgstr "Sesso"
+
+#. module: l10n_it_fiscalcode
+#: help:res.partner,fiscalcode:0
+msgid "Italian Fiscal Code"
+msgstr "Codice fiscale Italiano"
+
+#. module: l10n_it_fiscalcode
+#: field:res.partner,individual:0
+msgid "Individual"
+msgstr "Persona Fisica"
+
+#. module: l10n_it_fiscalcode
+#: selection:wizard.compute.fc,sex:0
+msgid "Female"
+msgstr "Femmina"
+
+#. module: l10n_it_fiscalcode
+#: view:wizard.compute.fc:0
+msgid "Cancel"
+msgstr "Annulla"
+
+#. module: l10n_it_fiscalcode
+#: model:ir.model,name:l10n_it_fiscalcode.model_res_partner
+msgid "Partner"
+msgstr "Partner"
+
+#. module: l10n_it_fiscalcode
+#: view:res.partner:0
+msgid "Compute F.C."
+msgstr "Calcola C.F."
+
=== added file 'l10n_it_fiscalcode/i18n/l10n_it_account.pot'
--- l10n_it_fiscalcode/i18n/l10n_it_account.pot 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/i18n/l10n_it_account.pot 2013-02-05 16:24:41 +0000
@@ -0,0 +1,117 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+# * l10n_it_account
+#
+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:44+0000\n"
+"PO-Revision-Date: 2011-05-05 16:44+0000\n"
+"Last-Translator: <>\n"
+"Language-Team: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Plural-Forms: \n"
+
+#. 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 ""
+
+#. module: l10n_it_account
+#: view:res.partner:0
+msgid "Compute"
+msgstr ""
+
+#. module: l10n_it_account
+#: model:ir.model,name:l10n_it_account.model_account_invoice
+msgid "Invoice"
+msgstr ""
+
+#. module: l10n_it_account
+#: field:res.partner,birth_date:0
+msgid "Date of birth"
+msgstr ""
+
+#. module: l10n_it_account
+#: view:res.partner:0
+msgid "Notes"
+msgstr ""
+
+#. 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 ""
+
+#. module: l10n_it_account
+#: help:res.partner,fiscalcode:0
+msgid "Italian Fiscal Code"
+msgstr ""
+
+#. module: l10n_it_account
+#: field:res.partner,sex:0
+msgid "Sex"
+msgstr ""
+
+#. module: l10n_it_account
+#: field:res.partner,fiscalcode_surname:0
+msgid "Surname"
+msgstr ""
+
+#. module: l10n_it_account
+#: field:res.partner,fiscalcode_firstname:0
+msgid "First name"
+msgstr ""
+
+#. module: l10n_it_account
+#: view:res.partner:0
+#: field:res.partner,fiscalcode:0
+msgid "Fiscal Code"
+msgstr ""
+
+#. module: l10n_it_account
+#: model:ir.module.module,shortdesc:l10n_it_account.module_meta_information
+msgid "Italian Localisation - Account"
+msgstr ""
+
+#. module: l10n_it_account
+#: selection:res.partner,sex:0
+msgid "Female"
+msgstr ""
+
+#. module: l10n_it_account
+#: model:ir.model,name:l10n_it_account.model_res_partner
+msgid "Partner"
+msgstr ""
+
+#. module: l10n_it_account
+#: view:res.partner:0
+msgid "Compute Fiscal Code"
+msgstr ""
+
+#. module: l10n_it_account
+#: selection:res.partner,sex:0
+msgid "Male"
+msgstr ""
+
+#. module: l10n_it_account
+#: code:addons/l10n_it_account/account/invoice.py:44
+#, python-format
+msgid "Date Inconsistency"
+msgstr ""
+
+#. module: l10n_it_account
+#: field:res.partner,birth_city:0
+msgid "City of birth"
+msgstr ""
+
=== added directory 'l10n_it_fiscalcode/test'
=== added file 'l10n_it_fiscalcode/test/fiscalcode.yml'
--- l10n_it_fiscalcode/test/fiscalcode.yml 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/test/fiscalcode.yml 2013-02-05 16:24:41 +0000
@@ -0,0 +1,28 @@
+-
+ I create the wizard record
+-
+ !record {model: wizard.compute.fc, id: wizard_fc_1}:
+ fiscalcode_surname: 'Tampieri'
+ fiscalcode_firstname: 'Franco'
+ birth_date: '1976-07-04'
+ birth_city: l10n_it_base.4059
+ sex: 'M'
+
+-
+ I run the wizard
+-
+ !python {model: wizard.compute.fc}: |
+ self.view_init(cr, uid, [ref("wizard_fc_1")], {"lang": 'en_US',
+ "active_model": "res.partner", "tz": False, "active_ids":
+ [ref("base.res_partner_c2c")], "active_id": ref("base.res_partner_c2c"),
+ })
+ self.compute_fc(cr, uid, [ref("wizard_fc_1")], {"lang": 'en_US',
+ "active_model": "res.partner", "tz": False, "active_ids":
+ [ref("base.res_partner_c2c")], "active_id": ref("base.res_partner_c2c"),
+ })
+
+-
+ I check the fiscal code
+-
+ !assert {model: res.partner, id: base.res_partner_c2c}:
+ - fiscalcode == 'TMPFNC76L04E289A'
=== added directory 'l10n_it_fiscalcode/wizard'
=== added file 'l10n_it_fiscalcode/wizard/__init__.py'
--- l10n_it_fiscalcode/wizard/__init__.py 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/wizard/__init__.py 2013-02-05 16:24:41 +0000
@@ -0,0 +1,23 @@
+# -*- 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 compute_fc
+
=== added file 'l10n_it_fiscalcode/wizard/compute_fc.py'
--- l10n_it_fiscalcode/wizard/compute_fc.py 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/wizard/compute_fc.py 2013-02-05 16:24:41 +0000
@@ -0,0 +1,127 @@
+# -*- 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
+import tools
+import pooler
+from tools.translate import _
+
+import datetime
+
+class wizard_compute_fc(osv.osv_memory):
+
+ _name = "wizard.compute.fc"
+ _description = "Compute Fiscal Code"
+ _columns = {
+ 'fiscalcode_surname': fields.char('Surname', size=64),
+ '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"),
+ }
+
+
+ def _codicefiscale(self, cognome, nome, giornonascita, mesenascita, annonascita, sesso, cittanascita):
+
+ MESI = 'ABCDEHLMPRST'
+ CONSONANTI = 'BCDFGHJKLMNPQRSTVWXYZ'
+ VOCALI = 'AEIOU'
+ 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)
+ }
+
+ """Funzioni per il calcolo del C.F."""
+ def _surname(stringa):
+ """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']
+ return chars[:3]
+
+ def _name(stringa):
+ """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']
+ 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("%02d" % gn)
+ return chars
+
+ def _codicecontrollo(c):
+ """Restituisce il codice di controllo, l'ultimo carattere del C.F."""
+ sommone = 0
+ for i, car in enumerate(c):
+ j = 1 - i % 2
+ sommone += REGOLECONTROLLO[car][j]
+ resto = sommone % 26
+ return [LETTERE[resto]]
+
+ """Restituisce il C.F costruito sulla base degli argomenti."""
+ nome=nome.upper()
+ cognome=cognome.upper()
+ sesso=sesso.upper()
+ cittanascita = cittanascita.upper()
+ chars = (_surname(cognome) +
+ _name(nome) +
+ _datan(giornonascita, mesenascita, annonascita, sesso) +
+ list(cittanascita))
+ chars += _codicecontrollo(chars)
+ return ''.join(chars)
+
+ 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)
+ 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:
+ 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)
+ 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})
+ return {}
=== added file 'l10n_it_fiscalcode/wizard/compute_fc_view.xml'
--- l10n_it_fiscalcode/wizard/compute_fc_view.xml 1970-01-01 00:00:00 +0000
+++ l10n_it_fiscalcode/wizard/compute_fc_view.xml 2013-02-05 16:24:41 +0000
@@ -0,0 +1,50 @@
+<?xml version="1.0" ?>
+<openerp>
+ <data>
+
+ <record id="wizard_compute_fc_form" model="ir.ui.view">
+ <field name="name">wizard.compute.fc.form</field>
+ <field name="model">wizard.compute.fc</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Fiscal Code">
+ <group col="2" width="250">
+ <group string="Individual Data">
+ <field name="fiscalcode_surname" colspan="2" default_focus="1"/>
+ <field name="fiscalcode_firstname" colspan="2"/>
+ <field name="sex" colspan="2"/>
+ <field name="birth_date" colspan="2"/>
+ <field name="birth_city" colspan="2"/>
+ </group>
+ <newline/>
+ <group col="2">
+ <button string="Cancel" special="cancel" icon="gtk-cancel" colspan="1"/>
+ <button name="compute_fc" type="object" string="Compute" colspan="1"/>
+ </group>
+ </group>
+ </form>
+ </field>
+ </record>
+
+ <record id="action_compute_fc" model="ir.actions.act_window">
+ <field name="name">Compute Fiscal Code</field>
+ <field name="type">ir.actions.act_window</field>
+ <field name="res_model">wizard.compute.fc</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="target">new</field>
+ </record>
+
+ <record id="view_partner_form_fiscalcode_button" model="ir.ui.view">
+ <field name="name">res.partner.fiscalcode.button</field>
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="l10n_it_fiscalcode.view_partner_form_fiscalcode_data"/>
+ <field name="arch" type="xml">
+ <field name="fiscalcode" position="after">
+ <button name="%(l10n_it_fiscalcode.action_compute_fc)d" string="Compute F.C." type="action" icon="gtk-execute" colspan="2"/>
+ </field>
+ </field>
+ </record>
+
+ </data>
+</openerp>
Follow ups
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Davide Corio - agilebg.com, 2013-02-12
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Davide Corio - agilebg.com, 2013-02-12
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Francesco Apruzzese, 2013-02-12
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Davide Corio - agilebg.com, 2013-02-12
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: massimo.rc, 2013-02-12
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Andrea Cometa, 2013-02-07
-
[Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: noreply, 2013-02-07
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Andrea Cometa, 2013-02-07
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Andrea Cometa, 2013-02-06
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Lorenzo Battistini - Agile BG - Domsense, 2013-02-06
-
Re: [Merge] lp:~scigghia/openobject-italia/add_fiscalcode into lp:openobject-italia/7.0
From: Lorenzo Battistini - Agile BG - Domsense, 2013-02-06