mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-22 04:02:03 +00:00
fix ebics.file download handler
This commit is contained in:
parent
f16e81f0a4
commit
5565717998
@ -139,7 +139,39 @@ class EbicsFile(models.Model):
|
|||||||
"\nPlease install module '%s'")
|
"\nPlease install module '%s'")
|
||||||
% (self.format_id.name, module))
|
% (self.format_id.name, module))
|
||||||
|
|
||||||
def _process_result_action(self, ctx):
|
def _process_result_action(self, res):
|
||||||
|
notifications = []
|
||||||
|
st_line_ids = []
|
||||||
|
statement_ids = []
|
||||||
|
if res.get('context'):
|
||||||
|
notifications = res['context'].get('notifications', [])
|
||||||
|
st_line_ids = res['context'].get('statement_line_ids', [])
|
||||||
|
if notifications:
|
||||||
|
for notif in notifications:
|
||||||
|
parts = []
|
||||||
|
for k in ['type', 'message', 'details']:
|
||||||
|
if notif.get(k):
|
||||||
|
msg = '%s: %s' % (k, notif[k])
|
||||||
|
parts.append(msg)
|
||||||
|
self.note_process += '\n'.join(parts)
|
||||||
|
self.note_process += '\n'
|
||||||
|
self.note_process += '\n'
|
||||||
|
if st_line_ids:
|
||||||
|
self.env.cr.execute(
|
||||||
|
"""
|
||||||
|
SELECT DISTINCT statement_id
|
||||||
|
FROM account_bank_statement_line
|
||||||
|
WHERE id IN %s
|
||||||
|
"""
|
||||||
|
% (tuple(st_line_ids),)
|
||||||
|
)
|
||||||
|
statement_ids = list(self.env.cr.fetchall()[0])
|
||||||
|
self.note_process += _(
|
||||||
|
"Number of Bank Statements: %s"
|
||||||
|
) % len(statement_ids)
|
||||||
|
if statement_ids:
|
||||||
|
self.sudo().bank_statement_ids = [(6, 0, statement_ids)]
|
||||||
|
ctx = dict(self.env.context, statement_ids=statement_ids)
|
||||||
module = __name__.split('addons.')[1].split('.')[0]
|
module = __name__.split('addons.')[1].split('.')[0]
|
||||||
result_view = self.env.ref('%s.ebics_file_view_form_result' % module)
|
result_view = self.env.ref('%s.ebics_file_view_form_result' % module)
|
||||||
return {
|
return {
|
||||||
@ -185,28 +217,7 @@ class EbicsFile(models.Model):
|
|||||||
wiz_ctx = dict(self.env.context, active_model='ebics.file')
|
wiz_ctx = dict(self.env.context, active_model='ebics.file')
|
||||||
wiz = self.env[wiz_model].with_context(wiz_ctx).create(wiz_vals)
|
wiz = self.env[wiz_model].with_context(wiz_ctx).create(wiz_vals)
|
||||||
res = wiz.import_file()
|
res = wiz.import_file()
|
||||||
notifications = []
|
return self._process_result_action(res)
|
||||||
statement_ids = []
|
|
||||||
if res.get('context'):
|
|
||||||
notifications = res['context'].get('notifications', [])
|
|
||||||
statement_ids = res['context'].get('statement_ids', [])
|
|
||||||
if notifications:
|
|
||||||
for notif in notifications:
|
|
||||||
parts = []
|
|
||||||
for k in ['type', 'message', 'details']:
|
|
||||||
if notif.get(k):
|
|
||||||
msg = '%s: %s' % (k, notif[k])
|
|
||||||
parts.append(msg)
|
|
||||||
self.note_process += '\n'.join(parts)
|
|
||||||
self.note_process += '\n'
|
|
||||||
self.note_process += '\n'
|
|
||||||
self.note_process += _(
|
|
||||||
"Number of Bank Statements: %s"
|
|
||||||
) % len(statement_ids)
|
|
||||||
if statement_ids:
|
|
||||||
self.bank_statement_ids = [(6, 0, statement_ids)]
|
|
||||||
ctx = dict(self._context, statement_ids=statement_ids)
|
|
||||||
return self._process_result_action(ctx)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _unlink_cfonb120(self):
|
def _unlink_cfonb120(self):
|
||||||
@ -250,28 +261,7 @@ class EbicsFile(models.Model):
|
|||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
"No financial journal found for Company Bank Account %s"
|
"No financial journal found for Company Bank Account %s"
|
||||||
) % bank_account)
|
) % bank_account)
|
||||||
notifications = []
|
return self._process_result_action(res)
|
||||||
statement_ids = []
|
|
||||||
if res.get('context'):
|
|
||||||
notifications = res['context'].get('notifications', [])
|
|
||||||
statement_ids = res['context'].get('statement_ids', [])
|
|
||||||
if notifications:
|
|
||||||
for notif in notifications:
|
|
||||||
parts = []
|
|
||||||
for k in ['type', 'message', 'details']:
|
|
||||||
if notif.get(k):
|
|
||||||
msg = '%s: %s' % (k, notif[k])
|
|
||||||
parts.append(msg)
|
|
||||||
self.note_process += '\n'.join(parts)
|
|
||||||
self.note_process += '\n'
|
|
||||||
self.note_process += '\n'
|
|
||||||
self.note_process += _(
|
|
||||||
"Number of Bank Statements: %s"
|
|
||||||
) % len(statement_ids)
|
|
||||||
if statement_ids:
|
|
||||||
self.bank_statement_ids = [(6, 0, statement_ids)]
|
|
||||||
ctx = dict(self._context, statement_ids=statement_ids)
|
|
||||||
return self._process_result_action(ctx)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _unlink_camt053(self):
|
def _unlink_camt053(self):
|
||||||
|
@ -51,12 +51,12 @@ class AccountBankStatementImport(models.TransientModel):
|
|||||||
break
|
break
|
||||||
if not transactions:
|
if not transactions:
|
||||||
message = _('This file doesn\'t contain any transaction.')
|
message = _('This file doesn\'t contain any transaction.')
|
||||||
statement_ids = []
|
st_line_ids = []
|
||||||
notifications = {
|
notifications = {
|
||||||
'type': 'warning',
|
'type': 'warning',
|
||||||
'message': message,
|
'message': message,
|
||||||
'details': ''
|
'details': ''
|
||||||
}
|
}
|
||||||
return statement_ids, [notifications]
|
return st_line_ids, [notifications]
|
||||||
|
|
||||||
return super()._create_bank_statements(stmts_vals)
|
return super()._create_bank_statements(stmts_vals)
|
||||||
|
Loading…
Reference in New Issue
Block a user