mirror of
https://github.com/brain-tec/account_ebics.git
synced 2024-11-23 20:52:04 +00:00
[14.0][MIG]account_ebics
This commit is contained in:
parent
f097880a32
commit
488517b6b3
@ -51,11 +51,11 @@ We also recommend to consider the installation of the following modules:
|
||||
|
||||
|
|
||||
|
||||
- account_bank_statement_import_fr_cfonb
|
||||
- account_statement_import_fr_cfonb
|
||||
|
||||
Required to handle french CFONB files.
|
||||
|
||||
Cf. https://github.com/OCA/l10n_fr
|
||||
Cf. https://github.com/OCA/l10n_france
|
||||
|
||||
|
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
'name': 'EBICS banking protocol',
|
||||
'version': '13.0.1.3.0',
|
||||
'version': '14.0.1.0.0',
|
||||
'license': 'LGPL-3',
|
||||
'author': 'Noviat',
|
||||
'website': 'www.noviat.com',
|
||||
|
@ -103,8 +103,8 @@ class EbicsFile(models.Model):
|
||||
|
||||
def action_open_bank_statements(self):
|
||||
self.ensure_one()
|
||||
action = self.env['ir.actions.act_window'].for_xml_id(
|
||||
'account', 'action_bank_statement_tree')
|
||||
action = self.env['ir.actions.act_window']._for_xml_id(
|
||||
'account.action_bank_statement_tree')
|
||||
domain = eval(action.get('domain') or '[]')
|
||||
domain += [('id', 'in', self._context.get('statement_ids'))]
|
||||
action.update({'domain': domain})
|
||||
@ -220,12 +220,12 @@ class EbicsFile(models.Model):
|
||||
We do not support the standard _journal_creation_wizard since a single
|
||||
cfonb120 file may contain statements from different legal entities.
|
||||
"""
|
||||
import_module = 'account_bank_statement_import_fr_cfonb'
|
||||
import_module = 'account_statement_import_fr_cfonb'
|
||||
self._check_import_module(import_module)
|
||||
wiz_model = 'account.bank.statement.import'
|
||||
wiz_model = 'account.statement.import'
|
||||
data_file = base64.b64decode(self.data)
|
||||
lines = data_file.split(b'\n')
|
||||
attachments_vals = []
|
||||
wiz_vals_list = []
|
||||
st_lines = b''
|
||||
transactions = False
|
||||
for line in lines:
|
||||
@ -237,10 +237,9 @@ class EbicsFile(models.Model):
|
||||
if rec_type == b'07':
|
||||
if transactions:
|
||||
fn = '_'.join([acc_number.decode(), self.name])
|
||||
attachments_vals.append({
|
||||
'name': fn,
|
||||
'store_fname': fn,
|
||||
'datas': base64.b64encode(st_lines)
|
||||
wiz_vals_list.append({
|
||||
'statement_filename': fn,
|
||||
'statement_file': base64.b64encode(st_lines)
|
||||
})
|
||||
st_lines = b''
|
||||
transactions = False
|
||||
@ -252,10 +251,9 @@ class EbicsFile(models.Model):
|
||||
'notifications': []},
|
||||
}
|
||||
wiz_ctx = dict(self.env.context, active_model='ebics.file')
|
||||
for i, attachment_vals in enumerate(attachments_vals, start=1):
|
||||
wiz_vals = {'attachment_ids': [(0, 0, attachment_vals)]}
|
||||
for i, wiz_vals in enumerate(wiz_vals_list, start=1):
|
||||
wiz = self.env[wiz_model].with_context(wiz_ctx).create(wiz_vals)
|
||||
res = wiz.import_file()
|
||||
res = wiz.import_file_button()
|
||||
ctx = res.get('context')
|
||||
if (res.get('res_model')
|
||||
== 'account.bank.statement.import.journal.creation'):
|
||||
@ -272,6 +270,7 @@ class EbicsFile(models.Model):
|
||||
'details': details,
|
||||
}])
|
||||
continue
|
||||
import pdb; pdb.set_trace()
|
||||
result['context']['statement_line_ids'].extend(
|
||||
ctx['statement_line_ids'])
|
||||
result['context']['notifications'].extend(
|
||||
|
@ -7,3 +7,6 @@ access_ebics_file_format_manager,ebics_file_format manager,model_ebics_file_form
|
||||
access_ebics_file_format_user,ebics_file_format user,model_ebics_file_format,account.group_account_invoice,1,0,0,0
|
||||
access_ebics_file_manager,ebics_file manager,model_ebics_file,group_ebics_manager,1,1,1,1
|
||||
access_ebics_file_user,ebics_file user,model_ebics_file,account.group_account_invoice,1,1,1,0
|
||||
|
||||
access_ebics_change_passphrase,access_ebics_change_passphrase,model_ebics_change_passphrase,group_ebics_manager,1,1,1,0
|
||||
access_ebics_xfer,access_ebics_xfer,model_ebics_xfer,account.group_account_invoice,1,1,1,0
|
||||
|
|
@ -1,3 +1,2 @@
|
||||
from . import account_bank_statement_import
|
||||
from . import ebics_change_passphrase
|
||||
from . import ebics_xfer
|
||||
|
@ -1,62 +0,0 @@
|
||||
# Copyright 2009-2020 Noviat.
|
||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import models, _
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AccountBankStatementImport(models.TransientModel):
|
||||
_inherit = 'account.bank.statement.import'
|
||||
|
||||
def _check_parsed_data(self, stmts_vals, account_number):
|
||||
""" Basic and structural verifications """
|
||||
if self.env.context.get('active_model') == 'ebics.file':
|
||||
message = False
|
||||
if len(stmts_vals) == 0:
|
||||
message = _("This file doesn't contain any statement.")
|
||||
if not message:
|
||||
no_st_line = True
|
||||
for vals in stmts_vals:
|
||||
if vals['transactions'] and len(vals['transactions']) > 0:
|
||||
no_st_line = False
|
||||
break
|
||||
if no_st_line:
|
||||
message = _('This file doesn\'t contain any transaction.')
|
||||
if message:
|
||||
log_msg = _(
|
||||
"Error detected while processing and EBICS File"
|
||||
) + ':\n' + message
|
||||
_logger.warn(log_msg)
|
||||
return
|
||||
super()._check_parsed_data(stmts_vals, account_number)
|
||||
|
||||
def _create_bank_statements(self, stmts_vals):
|
||||
"""
|
||||
Return error message to ebics.file when handling empty camt.
|
||||
|
||||
Remarks/TODO:
|
||||
We could add more info to the message (e.g. date, balance, ...)
|
||||
and write this to the ebics.file, note field.
|
||||
We could also create empty bank statement (in state done) to clearly
|
||||
show days without transactions via the bank statement list view.
|
||||
"""
|
||||
if self.env.context.get('active_model') == 'ebics.file':
|
||||
transactions = False
|
||||
for st_vals in stmts_vals:
|
||||
if st_vals.get('transactions'):
|
||||
transactions = True
|
||||
break
|
||||
if not transactions:
|
||||
message = _('This file doesn\'t contain any transaction.')
|
||||
st_line_ids = []
|
||||
notifications = {
|
||||
'type': 'warning',
|
||||
'message': message,
|
||||
'details': ''
|
||||
}
|
||||
return st_line_ids, [notifications]
|
||||
|
||||
return super()._create_bank_statements(stmts_vals)
|
@ -66,6 +66,9 @@ class EbicsXfer(models.TransientModel):
|
||||
string='EBICS File Format',
|
||||
help="Select EBICS File Format to upload/download."
|
||||
"\nLeave blank to download all available files.")
|
||||
allowed_format_ids = fields.Many2many(
|
||||
related='ebics_config_id.ebics_file_format_ids',
|
||||
string='Allowed EBICS File Formats')
|
||||
order_type = fields.Char(
|
||||
related='format_id.order_type',
|
||||
string='Order Type',
|
||||
@ -94,14 +97,11 @@ class EbicsXfer(models.TransientModel):
|
||||
@api.onchange('ebics_config_id')
|
||||
def _onchange_ebics_config_id(self):
|
||||
ebics_userids = self.ebics_config_id.ebics_userid_ids
|
||||
domain = {'ebics_userid_id': [('id', 'in', ebics_userids.ids)]}
|
||||
if self._context.get('ebics_download'):
|
||||
download_formats = self.ebics_config_id.ebics_file_format_ids\
|
||||
.filtered(lambda r: r.type == 'down')
|
||||
if len(download_formats) == 1:
|
||||
self.format_id = download_formats
|
||||
domain['format_id'] = [('type', '=', 'down'),
|
||||
('id', 'in', download_formats.ids)]
|
||||
if len(ebics_userids) == 1:
|
||||
self.ebics_userid_id = ebics_userids
|
||||
else:
|
||||
@ -114,11 +114,8 @@ class EbicsXfer(models.TransientModel):
|
||||
.filtered(lambda r: r.type == 'up')
|
||||
if len(upload_formats) == 1:
|
||||
self.format_id = upload_formats
|
||||
domain['format_id'] = [('type', '=', 'up'),
|
||||
('id', 'in', upload_formats.ids)]
|
||||
if len(ebics_userids) == 1:
|
||||
self.ebics_userid_id = ebics_userids
|
||||
return {'domain': domain}
|
||||
|
||||
@api.onchange('upload_data')
|
||||
def _onchange_upload_data(self):
|
||||
@ -262,8 +259,8 @@ class EbicsXfer(models.TransientModel):
|
||||
def view_ebics_file(self):
|
||||
self.ensure_one()
|
||||
module = __name__.split('addons.')[1].split('.')[0]
|
||||
act = self.env['ir.actions.act_window'].for_xml_id(
|
||||
module, 'ebics_file_action_download')
|
||||
act = self.env['ir.actions.act_window']._for_xml_id(
|
||||
'{}.ebics_file_action_download'.format(module))
|
||||
act['domain'] = [('id', 'in', self._context['ebics_file_ids'])]
|
||||
return act
|
||||
|
||||
|
@ -16,8 +16,10 @@
|
||||
options="{'no_create': True, 'no_open': True}"/>
|
||||
<field name="date_from"/>
|
||||
<field name="date_to"/>
|
||||
<field name="format_id"/>
|
||||
<field name="format_id"
|
||||
domain="[('type', '=', 'down'), ('id', 'in', allowed_format_ids)]"/>
|
||||
<field name="order_type"/>
|
||||
<field name="allowed_format_ids" invisible="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="ebics_download" string="Download Files" type="object" class="oe_highlight"/>
|
||||
@ -45,9 +47,11 @@
|
||||
<field name="upload_data" filename="upload_fname" required="1"/>
|
||||
<field name="upload_fname" invisible="1"/>
|
||||
<field name="upload_fname_dummy"/>
|
||||
<field name="format_id" required="1"/>
|
||||
<field name="format_id" required="1"
|
||||
domain="[('type', '=', 'up'), ('id', 'in', allowed_format_ids)]"/>
|
||||
<field name="order_type"/>
|
||||
<field name="test_mode" attrs="{'invisible': [('order_type', '!=', 'FUL')]}"/>
|
||||
<field name="allowed_format_ids" invisible="1"/>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="ebics_upload" string="Upload File" type="object" class="oe_highlight"/>
|
||||
|
Loading…
Reference in New Issue
Block a user