Skip to content
Snippets Groups Projects
Commit ac134e04 authored by Benjamin - Le Filament's avatar Benjamin - Le Filament
Browse files

[debug] revert debug

parent 9f31b5fc
Branches
No related tags found
No related merge requests found
......@@ -3,4 +3,3 @@
from . import account
from . import sale
from . import ebics_xfer
# Copyright 2020 Le Filament
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
import base64
import logging
import os
from sys import exc_info
from traceback import format_exception
from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.tools import config
_logger = logging.getLogger(__name__)
try:
import fintech
from fintech.ebics import EbicsKeyRing, EbicsBank, EbicsUser, EbicsClient,\
EbicsFunctionalError, EbicsTechnicalError, EbicsVerificationError
fintech.cryptolib = 'cryptography'
except ImportError:
EbicsBank = object
_logger.warning('Failed to import fintech')
fintech_register_name = config.get('fintech_register_name')
fintech_register_keycode = config.get('fintech_register_keycode')
fintech_register_users = config.get('fintech_register_users')
class EbicsXfer(models.TransientModel):
_inherit = 'ebics.xfer'
@api.multi
def ebics_download(self):
self.ensure_one()
self.ebics_config_id._check_ebics_files()
ctx = self._context.copy()
_logger.info(fintech_register_name)
_logger.info(fintech_register_keycode)
_logger.info(fintech_register_users)
self.note = ''
client = self._setup_client()
_logger.info(client)
if client:
download_formats = (
self.format_id
or self.ebics_config_id.ebics_file_format_ids.filtered(lambda r: r.type == 'down')
)
ebics_files = self.env['ebics.file']
date_from = self.date_from and self.date_from.isoformat() or None
date_to = self.date_to and self.date_to.isoformat() or None
for df in download_formats:
try:
success = False
if df.order_type == 'FDL':
_logger.info("Download FDL")
_logger.info(df)
data = client.FDL(df.name, date_from, date_to)
_logger.info("Data FDL")
_logger.info(data)
else:
params = None
if date_from and date_to:
params = {'DateRange': {
'Start': date_from,
'End': date_to,
}}
data = client.download(df.order_type, params=params)
ebics_files += self._handle_download_data(data, df)
success = True
except EbicsFunctionalError:
_logger.info("EbicsFunctionalError")
e = exc_info()
_logger.info(e)
self.note += '\n'
self.note += _(
"EBICS Functional Error during download of File Format %s (%s):"
) % (df.name, df.order_type)
self.note += '\n'
self.note += '%s (code: %s)' % (e[1].message, e[1].code)
except EbicsTechnicalError:
_logger.info("EbicsTechnicalError")
e = exc_info()
_logger.info(e)
self.note += '\n'
self.note += _(
"EBICS Technical Error during download of File Format %s (%s):"
) % (df.name, df.order_type)
self.note += '\n'
self.note += '%s (code: %s)' % (e[1].message, e[1].code)
except EbicsVerificationError:
self.note += '\n'
self.note += _(
"EBICS Verification Error during download of "
"File Format %s (%s):"
) % (df.name, df.order_type)
self.note += '\n'
self.note += _("The EBICS response could not be verified.")
except UserError as e:
self.note += '\n'
self.note += _(
"Warning during download of File Format %s (%s):"
) % (df.name, df.order_type)
self.note += '\n'
self.note += e.name
except Exception:
self.note += '\n'
self.note += _(
"Unknown Error during download of File Format %s (%s):"
) % (df.name, df.order_type)
tb = ''.join(format_exception(*exc_info()))
self.note += '\n%s' % tb
else:
# mark received data so that it is not included in further
# downloads
trans_id = client.last_trans_id
client.confirm_download(trans_id=trans_id, success=success)
ctx['ebics_file_ids'] = ebics_files._ids
if ebics_files:
self.note += '\n'
for f in ebics_files:
self.note += _(
"EBICS File '%s' is available for further processing."
) % f.name
self.note += '\n'
result_view = self.env.ref(
'account_ebics.ebics_xfer_view_form_result')
return {
'name': _('EBICS file transfer result'),
'res_id': self.id,
'view_type': 'form',
'view_mode': 'form',
'res_model': 'ebics.xfer',
'view_id': result_view.id,
'target': 'new',
'context': ctx,
'type': 'ir.actions.act_window',
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment