1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2011-2014 OpenERP - Team de Localización Argentina.
5
# https://launchpad.net/~openerp-l10n-ar-localization
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
#############################################################################
22
from osv import fields,osv
23
from tools.translate import _
26
from banks_def import *
28
class l10n_ar_banks_wizard(osv.osv_memory):
29
_name = 'l10nar.banks.wizard'
31
def on_cancel(self, cr, uid, ids, context):
34
def on_process (self, cr, uid, ids, context):
36
Tomo los datos de los banco de BCRA.
40
bancos_actualizados = 0
42
bancos_desahabilitados = 0
44
update_date = time.strftime('%Y-%m-%d')
45
idargentina = self.pool.get('res.country').search(cr, uid, [('name', '=', 'Argentina')])[0]
46
idbuenosaires = self.pool.get('res.country.state').search(cr, uid, [('name', '=', 'Buenos Aires')])[0]
47
idciudadbuenosaires = self.pool.get('res.country.state').search(cr, uid, [('name', '=', 'Ciudad Autónoma de Buenos Aires')])[0]
48
Bancos_obj = self.pool.get('res.bank')
50
TodosLosBancosArgentinos = Bancos_obj.search(cr, uid, [('country', '=', idargentina)])
51
self.pool.get('res.bank').write(cr, uid, TodosLosBancosArgentinos, {'active': False}, context=context)
52
bancos_desahabilitados = len(TodosLosBancosArgentinos)
54
for bank in ar_banks_iterator():
55
bancos_procesados += 1
57
for key in bankfields:
63
if bank[key] == 'Buenos Aires':
65
elif bank[key] == 'Autonomous City of Buenos Aires':
66
valor = idciudadbuenosaires
68
valor = self.pool.get('res.country.state').search(cr, uid, [('name', '=', bank[key])])[0]
69
vals.update({key:valor})
71
vals.update({'update' : time.strftime('%Y-%m-%d')})
73
Bancos_ids = Bancos_obj.search(cr, uid, [('name', '=', bank.get('name')),('country', '=', idargentina),('active', '=', False)])
75
Bancos_ids = Bancos_obj.search(cr, uid, [('vat', '=', bank.get('vat')), ('country', '=', idargentina),('active', '=', False)])
77
Bancos_ids = Bancos_obj.search(cr, uid, [('street', '=', bank.get('street')), ('city', '=', bank.get('city')), ('country', '=', idargentina),('active', '=', False)])
80
bancos_desahabilitados -= 1
81
bancos_actualizados += 1
82
self.pool.get('res.bank').write(cr, uid, [Bancos_ids[0]], vals, context=context)
85
self.pool.get('res.bank').create(cr, uid, vals, context=context)
87
Resultados.update({'bancos_procesados' : bancos_procesados})
88
Resultados.update({'bancos_actualizados' : bancos_actualizados})
89
Resultados.update({'bancos_nuevos' : bancos_nuevos})
90
Resultados.update({'bancos_desahabilitados' : bancos_desahabilitados})
95
'context': Resultados,
96
'res_model': 'l10nar.banks.wizard.result',
97
'type': 'ir.actions.act_window',
101
l10n_ar_banks_wizard()
104
class l10n_ar_banks_wizard_result(osv.osv_memory):
105
_name = 'l10nar.banks.wizard.result'
107
def _get_bancos_actualizados(self, cr, uid, context=None):
110
valor = context.get('bancos_actualizados')
113
def _get_bancos_nuevos(self, cr, uid, context=None):
116
valor = context.get('bancos_nuevos')
119
def _get_bancos_desahabilitados(self, cr, uid, context=None):
122
valor = context.get('bancos_desahabilitados')
125
def _get_bancos_procesados(self, cr, uid, context=None):
128
valor = context.get('bancos_procesados')
132
'bancos_actualizados' : fields.char(_('Banks Upgraded'), size=3),
133
'bancos_nuevos' : fields.char(_('New Banks'), size=3),
134
'bancos_desahabilitados' : fields.char(_('Desactivated Banks'), size=3),
135
'bancos_procesados' : fields.char(_('Banks total processed'), size=3),
138
'bancos_actualizados' : _get_bancos_actualizados,
139
'bancos_nuevos' : _get_bancos_nuevos,
140
'bancos_desahabilitados' : _get_bancos_desahabilitados,
141
'bancos_procesados' : _get_bancos_procesados,
144
def on_close(self, cr, uid, ids, context):
147
l10n_ar_banks_wizard_result()
b'\\ No newline at end of file'