mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-23 20:52:04 +00:00
[8.0]add support for multi bankaccont cfonb statements
This commit is contained in:
parent
5613480cc6
commit
3562cd78da
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'EBICS banking protocol',
|
'name': 'EBICS banking protocol',
|
||||||
'version': '8.0.1.5.1',
|
'version': '8.0.1.6.0',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'author': 'Noviat',
|
'author': 'Noviat',
|
||||||
'category': 'Accounting & Finance',
|
'category': 'Accounting & Finance',
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright 2009-2018 Noviat.
|
# Copyright 2009-2020 Noviat.
|
||||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import base64
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openerp import api, fields, models, _
|
from openerp import api, fields, models, _
|
||||||
@ -163,23 +164,61 @@ class EbicsFile(models.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _process_cfonb120(self):
|
def _process_cfonb120(self):
|
||||||
"""
|
|
||||||
TODO:
|
|
||||||
adapt OCA import logic to find correct journal on the basis
|
|
||||||
of both account number and currency.
|
|
||||||
Prompt for journal in case the journal is not found.
|
|
||||||
"""
|
|
||||||
import_module = 'account_bank_statement_import_fr_cfonb'
|
import_module = 'account_bank_statement_import_fr_cfonb'
|
||||||
self._check_import_module(import_module)
|
self._check_import_module(import_module)
|
||||||
wiz_model = 'account.bank.statement.import'
|
wiz_model = 'account.bank.statement.import'
|
||||||
wiz_vals = {'data_file': self.data}
|
data_file = base64.b64decode(self.data)
|
||||||
|
lines = data_file.split('\n')
|
||||||
|
data_files = []
|
||||||
|
st_lines = ''
|
||||||
|
transactions = False
|
||||||
|
for line in lines:
|
||||||
|
rec_type = line[0:2]
|
||||||
|
acc_number = line[21:32]
|
||||||
|
st_lines += line + '\n'
|
||||||
|
if rec_type == '04':
|
||||||
|
transactions = True
|
||||||
|
if rec_type == '07':
|
||||||
|
if transactions:
|
||||||
|
data_files.append({
|
||||||
|
'acc_number': acc_number,
|
||||||
|
'data_file': base64.b64encode(st_lines),
|
||||||
|
})
|
||||||
|
st_lines = ''
|
||||||
|
transactions = False
|
||||||
|
result = {
|
||||||
|
'type': 'ir.actions.client',
|
||||||
|
'tag': 'bank_statement_reconciliation_view',
|
||||||
|
'context': {'statement_ids': [],
|
||||||
|
'notifications': []},
|
||||||
|
}
|
||||||
|
for i, data_file in enumerate(data_files, start=1):
|
||||||
|
acc_number = data_file['acc_number']
|
||||||
|
if not self.env[wiz_model]._find_bank_account_id(acc_number):
|
||||||
|
message = _(
|
||||||
|
"Error detected while importing statement number %s.\n"
|
||||||
|
) % i
|
||||||
|
message += _("No financial journal found.")
|
||||||
|
details = _(
|
||||||
|
'Bank account number: %s'
|
||||||
|
) % acc_number
|
||||||
|
result['context']['notifications'].extend([{
|
||||||
|
'type': 'warning',
|
||||||
|
'message': message,
|
||||||
|
'details': details,
|
||||||
|
}])
|
||||||
|
continue
|
||||||
|
wiz_vals = {'data_file': data_file['data_file']}
|
||||||
wiz = self.env[wiz_model].create(wiz_vals)
|
wiz = self.env[wiz_model].create(wiz_vals)
|
||||||
res = wiz.import_file()
|
res = wiz.import_file()
|
||||||
notifications = []
|
ctx = res.get('context')
|
||||||
statement_ids = []
|
result['context']['statement_ids'].extend(
|
||||||
if res.get('context'):
|
ctx['statement_ids'])
|
||||||
notifications = res['context'].get('notifications', [])
|
result['context']['notifications'].extend(
|
||||||
statement_ids = res['context'].get('statement_ids', [])
|
ctx['notifications'])
|
||||||
|
if result.get('context'):
|
||||||
|
notifications = result['context'].get('notifications', [])
|
||||||
|
statement_ids = result['context'].get('statement_ids', [])
|
||||||
if notifications:
|
if notifications:
|
||||||
for notif in notifications:
|
for notif in notifications:
|
||||||
parts = []
|
parts = []
|
||||||
@ -195,8 +234,8 @@ class EbicsFile(models.Model):
|
|||||||
) % len(statement_ids)
|
) % len(statement_ids)
|
||||||
if statement_ids:
|
if statement_ids:
|
||||||
self.bank_statement_ids = [(6, 0, statement_ids)]
|
self.bank_statement_ids = [(6, 0, statement_ids)]
|
||||||
ctx = dict(self._context, statement_ids=statement_ids)
|
return self._process_result_action(
|
||||||
return self._process_result_action(ctx)
|
dict(self.env.context, statement_ids=statement_ids))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _unlink_cfonb120(self):
|
def _unlink_cfonb120(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user