← Back to team overview

openobject-italia-core-devs team mailing list archive

[Merge] lp:~a-camilli/openobject-italia/7.0_add_abi_cab into lp:openobject-italia/7.0

 

Alessandro Camilli has proposed merging lp:~a-camilli/openobject-italia/7.0_add_abi_cab into lp:openobject-italia/7.0.

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

For more details, see:
https://code.launchpad.net/~a-camilli/openobject-italia/7.0_add_abi_cab/+merge/170086

Adeguamento del modulo abi e cab alla versione 7.0.

Aggiunta un'utility per importare le banche nazionali dal file TXT che si può scaricare sia dai siti che dai programmi di homebanking. 
L'utility l'ho messa nel menu di contabilità->configurazione->varie
-- 
https://code.launchpad.net/~a-camilli/openobject-italia/7.0_add_abi_cab/+merge/170086
Your team OpenERP Italia core devs is requested to review the proposed merge of lp:~a-camilli/openobject-italia/7.0_add_abi_cab into lp:openobject-italia/7.0.
=== added directory 'l10n_it_abicab'
=== added file 'l10n_it_abicab/AUTHORS.txt'
--- l10n_it_abicab/AUTHORS.txt	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/AUTHORS.txt	2013-06-18 14:14:40 +0000
@@ -0,0 +1,2 @@
+Franco Tampieri <franco.tampieri@xxxxxxxxxxx>
+Alessandro Camilli <a.camilli@xxxxxxxx>

=== added file 'l10n_it_abicab/__init__.py'
--- l10n_it_abicab/__init__.py	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/__init__.py	2013-06-18 14:14:40 +0000
@@ -0,0 +1,25 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    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 Affero 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 abicab
+import bank
+import wizard
\ No newline at end of file

=== added file 'l10n_it_abicab/__openerp__.py'
--- l10n_it_abicab/__openerp__.py	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/__openerp__.py	2013-06-18 14:14:40 +0000
@@ -0,0 +1,38 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    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 Affero 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 - Base Bank ABI/CAB codes',
+    'version': '1.0',
+    'category': 'Localisation/Italy',
+    'description': """
+    Insert in the res.bank model the proprieties of the ABI/CAB
+    Utility to import italian bank from txt file 
+    """,
+    'author': 'OpenERP Italian Community',
+    'depends': ['base'],
+    'website': 'http://www.openerp-italia.org/',
+    'update_xml': ['abicab_view.xml', 'wizard/import_italian_bank_view.xml'],
+    'installable': True,
+    'active': False,
+    'certificate': '',
+}
\ No newline at end of file

=== added file 'l10n_it_abicab/abicab.py'
--- l10n_it_abicab/abicab.py	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/abicab.py	2013-06-18 14:14:40 +0000
@@ -0,0 +1,46 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    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 Affero 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
+
+class res_bank(osv.osv):
+    _inherit = "res.bank"
+    _columns = {
+        'abi': fields.char('ABI', size=5),
+        'cab': fields.char('CAB', size=5),
+    }
+
+class res_partner_bank(osv.osv):
+    _inherit = "res.partner.bank"
+    _columns = {
+        'bank_abi': fields.char('ABI', size=5),
+        'bank_cab': fields.char('CAB', size=5),
+    }
+
+    def onchange_bank_id(self, cr, uid, ids, bank_id, context=None):
+        result = super(res_partner_bank, self).onchange_bank_id(cr, uid, ids, bank_id, context=context)
+        if bank_id:
+            bank = self.pool.get('res.bank').browse(cr, uid, bank_id, context=context)
+            result['value']['bank_abi'] = bank.abi
+            result['value']['bank_cab'] = bank.cab
+        return result
+

=== added file 'l10n_it_abicab/abicab_view.xml'
--- l10n_it_abicab/abicab_view.xml	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/abicab_view.xml	2013-06-18 14:14:40 +0000
@@ -0,0 +1,61 @@
+<?xml version="1.0" ?>
+<openerp>
+	<data>
+
+       <record id="view_bank_tree_abicab" model="ir.ui.view">
+            <field name="name">res.bank.tree.abicab</field>
+            <field name="model">res.bank</field>
+            <field name="inherit_id" ref="base.view_res_bank_tree"/>
+            <field name="arch" type="xml">
+                <field name="name" position="after">
+                    <field name="abi"/>
+                    <field name="cab"/>
+                </field>
+            </field>
+        </record>
+
+        <record id="view_bank_form_abicab" model="ir.ui.view">
+            <field name="name">res.bank.form.abicab</field>
+            <field name="model">res.bank</field>
+            <field name="inherit_id" ref="base.view_res_bank_form"/>
+            <field name="arch" type="xml">
+                <field name="name" position="after">
+                    <newline/>
+                    <separator string="Bank Details" colspan="6"/>
+                    <group colspan="6" col="6">
+                        <field name="abi"/>
+                        <field name="cab"/>
+                    </group>
+                </field>
+            </field>
+    	</record>
+    	
+    	<record id="view_partner_bank_form_abicab_form" model="ir.ui.view">
+            <field name="name">res.partner.bank.form</field>
+            <field name="model">res.partner.bank</field>
+            <field name="inherit_id" ref="base.view_partner_bank_form"/>
+            <field name="arch" type="xml">
+            
+                <field name="bank_bic" position="after">
+                    <field name="bank_abi"/>
+                    <field name="bank_cab"/>
+                </field>
+                
+            </field>
+        </record>
+
+        <record id="view_partner_bank_form_abicab" model="ir.ui.view">
+            <field name="name">res.partner.bank.form</field>
+            <field name="model">res.partner</field>
+            <field name="inherit_id" ref="account.view_partner_property_form"/>
+            <field name="arch" type="xml">
+                
+                <field name="bank_name" position="after">
+                    <field name="bank_abi"/>
+                    <field name="bank_cab"/>
+                </field>
+            </field>
+        </record>
+
+	</data>
+</openerp>
\ No newline at end of file

=== added directory 'l10n_it_abicab/bank'
=== added file 'l10n_it_abicab/bank/__init__.py'
--- l10n_it_abicab/bank/__init__.py	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/bank/__init__.py	2013-06-18 14:14:40 +0000
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#    
+#    Copyright (C) 2013 Alessandro Camilli (a.camilli@xxxxxxxx)
+#
+#    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 bank

=== added file 'l10n_it_abicab/bank/bank.py'
--- l10n_it_abicab/bank/bank.py	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/bank/bank.py	2013-06-18 14:14:40 +0000
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+#################################################################################
+#    Author: Alessandro Camilli a.camilli@xxxxxxxx
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU 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 General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from osv import fields,osv
+from tools.translate import _
+import time
+import base64
+import tools
+from os import path
+
+class bank(osv.osv_memory):
+    
+    _name = "l10n_it_abicab.utility.import"
+    
+    _description = 'Use this wizard to import bank from txt'
+    
+    def import_from_abicab(self, cr, uid, ids, data, context=None):
+        
+        addons_path = tools.config.get('addons_path')
+        path_for_file = ""
+        for os_path in addons_path.split(','):
+            path_for_file = os_path + "/l10n_it_abicab/bank/"
+            if path.exists(path_for_file):
+                break
+        
+        file_txt_to_import = base64.decodestring(data['form']['file_txt_to_import'])
+        f = open(path_for_file + "abicab.txt", "w")
+        f.write(file_txt_to_import)
+        f.close()
+        
+        iFile = open(path_for_file + 'abicab.txt')
+        reader = iFile.readlines()
+        
+        for row in reader:
+            
+            prefissoRiga = row[:2]
+            #
+            # INTESTAZIONE BANCA
+            #
+            if prefissoRiga == '11':
+                banca_descrizione = row[13:93]
+            #
+            # INDIRIZZO AGENZIA
+            #
+            if prefissoRiga == '21':
+                agenzia_indirizzo = row[20:60]
+                agenzia_localita = row[140:180]
+                agenzia_cap = row[180:185]
+                agenzia_provincia = row[185:187] 
+            #
+            # AGENZIA
+            #
+            if prefissoRiga == '31':
+                agenzia_abi = row[2:7]
+                agenzia_cab = row[7:12]
+                agenzia_descrizione = row[12:52]
+                
+                # Creazione banca ( dopo ogni agenzia)
+                bank_dati = {
+                        'name': banca_descrizione.strip().decode('cp1252') + ' - ' + agenzia_descrizione.strip().decode('cp1252'),
+                        'abi' : agenzia_abi,
+                        'cab': agenzia_cab,
+                        'street': agenzia_indirizzo.strip().decode('cp1252'),
+                        'zip': agenzia_cap,
+                        'city': agenzia_localita.strip().decode('cp1252'),
+                        }
+                
+                cr.execute('SELECT  name,id FROM res_bank where abi =%s and cab=%s', (agenzia_abi, agenzia_cab) )
+                bank_exists = cr.fetchall()
+                if len(bank_exists) == 0:
+                    try:
+                        bank_id = self.pool.get('res.bank').create(cr, uid, bank_dati)
+                        cr.commit()
+                    except Exception:
+                        cr.rollback()
+                        raise ("error creating %s: abi %s, cab %s", (banca_descrizione,agenzia_abi,agenzia_cab))    
+                
+            
+        iFile.close()
+bank()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added directory 'l10n_it_abicab/i18n'
=== added file 'l10n_it_abicab/i18n/it.mo'
Binary files l10n_it_abicab/i18n/it.mo	1970-01-01 00:00:00 +0000 and l10n_it_abicab/i18n/it.mo	2013-06-18 14:14:40 +0000 differ
=== added file 'l10n_it_abicab/i18n/it.po'
--- l10n_it_abicab/i18n/it.po	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/i18n/it.po	2013-06-18 14:14:40 +0000
@@ -0,0 +1,37 @@
+# Translation of OpenERP Server.
+# This file contains the translation of the following modules:
+#	* l10n_it_abicab
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: OpenERP Server 6.0.3\n"
+"Report-Msgid-Bugs-To: support@xxxxxxxxxxx\n"
+"POT-Creation-Date: 2011-12-29 13:07+0000\n"
+"PO-Revision-Date: 2011-12-29 14:08+0100\n"
+"Last-Translator: Franco Tampieri <info@xxxxxxxxxx>\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_abicab
+#: field:res.bank,abi:0
+msgid "ABI"
+msgstr "ABI"
+
+#. module: l10n_it_abicab
+#: view:res.bank:0
+msgid "Bank Details"
+msgstr "Dettagli Banca"
+
+#. module: l10n_it_abicab
+#: model:ir.model,name:l10n_it_abicab.model_res_bank
+msgid "Bank"
+msgstr "Banca"
+
+#. module: l10n_it_abicab
+#: field:res.bank,cab:0
+msgid "CAB"
+msgstr "CAB"
+

=== added directory 'l10n_it_abicab/wizard'
=== added file 'l10n_it_abicab/wizard/__init__.py'
--- l10n_it_abicab/wizard/__init__.py	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/wizard/__init__.py	2013-06-18 14:14:40 +0000
@@ -0,0 +1,22 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    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 Affero 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 import_italian_bank
\ No newline at end of file

=== added file 'l10n_it_abicab/wizard/import_italian_bank.py'
--- l10n_it_abicab/wizard/import_italian_bank.py	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/wizard/import_italian_bank.py	2013-06-18 14:14:40 +0000
@@ -0,0 +1,57 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+#    OpenERP, Open Source Management Solution
+#    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 Affero 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 _
+import time
+import psycopg2
+from StringIO import StringIO
+
+
+class wizard_import_italian_bank(osv.osv_memory):
+    
+    _name = "wizard.import.italian.bank"
+    
+    _description = 'Use this wizard to import italian bank from ufficial file txt'
+    
+    _columns={
+        'file_txt_to_import': fields.binary('File TXT to import', required=True, help="Se il file è troppo grande, dividerlo facendo attenzione \
+                affinchè la prima riga del nuovo file inizi con il previsso 11, ovvero con l'intestazione della nuova banca."),
+    }
+
+    
+    def import_italian_bank(self, cr, uid, ids, data, context=None):
+        
+        for wiz_obj in self.read(cr,uid,ids):
+            if 'form' not in data:
+                data['form'] = {}
+            #data['form']['type'] = wiz_obj['type']
+            data['form']['file_txt_to_import'] = wiz_obj['file_txt_to_import']
+        
+            self.pool.get('l10n_it_abicab.utility.import').import_from_abicab(cr, uid, ids, data, context=None)
+
+        return {'type': 'ir.actions.act_window_close'}
+    
+    
+wizard_import_italian_bank()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file

=== added file 'l10n_it_abicab/wizard/import_italian_bank_view.xml'
--- l10n_it_abicab/wizard/import_italian_bank_view.xml	1970-01-01 00:00:00 +0000
+++ l10n_it_abicab/wizard/import_italian_bank_view.xml	2013-06-18 14:14:40 +0000
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+    	<!-- 
+		Form           
+		-->
+        <record id="l10n_it_abicab_utility_import_italian_bank" model="ir.ui.view">
+	        <field eval="1" name="priority"/>
+	        <field name="name">openforce.utility.import.italian.bank</field>
+	        <field name="model">wizard.import.italian.bank</field>
+	        <field name="type">form</field>
+	        <field name="arch" type="xml">
+		        <form string="Params" version="7.0">
+		        	<group  col="4">
+			        	<field name="file_txt_to_import" />
+		            </group>
+		            <button name="import_italian_bank" string="Import italian banks " type="object" icon="gtk-execute" />
+		      	</form>
+	        </field>
+    	</record>
+
+        <!-- ACTION -->
+        
+        <record id="l10n_it_abicab_utility_import_italian_bank_action" model="ir.actions.act_window">
+			<field name="name">Import italian bank</field>
+	        <field name="res_model">wizard.import.italian.bank</field>
+	        <field name="view_type">form</field>
+	        <field name="view_mode">form,tree,graph</field>
+	        <field name="view_id" ref="l10n_it_abicab_utility_import_italian_bank"/>
+	        <field name="help">Import italian bank from txt abicab</field>
+	        <field name="target">new</field>
+    	</record>
+    	
+    <menuitem action="l10n_it_abicab_utility_import_italian_bank_action" id="menu_l10n_it_abicab_utility_import_italian_bank" parent="account.menu_configuration_misc"/>
+    
+    </data>
+</openerp>


Follow ups