-
-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMP] l10n_es_partner: Generador del archivo de bancos
- Loading branch information
1 parent
850ed6c
commit 07bb319
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <ismael.calvo@factorlibre.com> | ||
# $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 <http://www.gnu.org/licenses/>. | ||
# | ||
############################################################################## | ||
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("<?xml version='1.0' encoding='UTF-8'?>\n") | ||
output.write("<openerp>\n") | ||
output.write(" <data noupdate='1'>\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(' <record id="%s" model="res.bank">\n' % | ||
name) | ||
output.write(' <field name="name">%s<field/>\n' % ( | ||
row[40])) | ||
output.write(' <field name="lname">%s<field/>\n' % ( | ||
row[4])) | ||
output.write(' <field name="code">%s<field/>\n' % ( | ||
row[1])) | ||
output.write(' <field name="bic">%s<field/>\n' % ( | ||
row[29])) | ||
output.write(' <field name="vat">%s<field/>\n' % ( | ||
row[6])) | ||
output.write(' <field name="street">%s<field/>\n' % | ||
(street)) | ||
output.write(' <field name="city">%s<field/>\n' % ( | ||
row[12])) | ||
output.write(' <field name="zip">%s<field/>\n' % ( | ||
row[11])) | ||
output.write(' <field name="phone">' | ||
'%s<field/>\n' % row[16]) | ||
output.write(' <field name="fax">%s<field/>\n' % ( | ||
row[18])) | ||
output.write(' <field name="website">%s<field/>\n' % | ||
(row[19])) | ||
output.write(' <field eval="1" name="active"/>\n') | ||
output.write(' <field name="country_id"' | ||
' ref="base.es"/>\n') | ||
output.write(' </record>\n') | ||
output.write(" </data>\n") | ||
output.write("</openerp>\n") | ||
|
||
output.close() | ||
print "data_banks.xml generado correctamente." |