diff --git a/l10n_es_partner/gen_src/README.rst b/l10n_es_partner/gen_src/README.rst new file mode 100644 index 00000000000..f676d8d69e4 --- /dev/null +++ b/l10n_es_partner/gen_src/README.rst @@ -0,0 +1,13 @@ +Utilidad para generar el archivo de bancos a partir de la información del Banco de España +========================================================================================= + +**NOTA**: Necesita la librería python 'xlrd' + +1. Descargar el excel de las 'Entidades con establecimiento' de la web del +Banco de España: +http://goo.gl/EPfcR5 +2. Mover el archivo descargado 'REGBANESP_CONESTAB_A.XLS' a la carpeta gen_src +3. Ejecutar: + python gen_data_banks.py +4. Se generará un archivo data_banks.xml en la carpeta wizard que sustituirá el +anterior diff --git a/l10n_es_partner/gen_src/gen_data_banks.py b/l10n_es_partner/gen_src/gen_data_banks.py new file mode 100644 index 00000000000..f246256be8b --- /dev/null +++ b/l10n_es_partner/gen_src/gen_data_banks.py @@ -0,0 +1,84 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2014 Factor Libre S.L (http://www.factorlibre.com) +# Ismael Calvo +# $Id$ +# +# 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 . +# +############################################################################## +from xlrd import open_workbook +import codecs + +if __name__ == "__main__": + # Abre el archivo que contine la información de los bancos + book = False + try: + book = open_workbook('REGBANESP_CONESTAB_A.XLS') + except IOError: + print "Archivo REGBANESP_CONESTAB_A.XLS no encontrado." + + if book: + sheet = book.sheet_by_index(0) + + # Prepara el archivo resultante + output = codecs.open("../wizard/data_banks.xml", mode='w', + encoding='utf-8') + output.write("\n") + output.write("\n") + output.write(" \n") + + # Genera los nuevos registros de los bancos + for row_index in range(1, sheet.nrows): + row = sheet.row_values(row_index) + if row[29]: + name = "res_bank_" + row[40].lower().replace( + ' ', '').replace(',', '').replace('.', '').replace( + '-', '').replace(u'\xf1', 'n') + street = row[7] + '. ' + row[8] + ', ' + row[9] + ' ' + row[10] + output.write(' \n' % + name) + output.write(' %s\n' % ( + row[40])) + output.write(' %s\n' % ( + row[4])) + output.write(' %s\n' % ( + row[1])) + output.write(' %s\n' % ( + row[29])) + output.write(' %s\n' % ( + row[6])) + output.write(' %s\n' % + (street)) + output.write(' %s\n' % ( + row[12])) + output.write(' %s\n' % ( + row[11])) + output.write(' ' + '%s\n' % row[16]) + output.write(' %s\n' % ( + row[18])) + output.write(' %s\n' % + (row[19])) + output.write(' \n') + output.write(' \n') + output.write(' \n') + output.write(" \n") + output.write("\n") + + output.close() + print "data_banks.xml generado correctamente."