mirror of
https://github.com/brain-tec/account_ebics.git
synced 2025-08-13 22:25:35 +00:00
[14.0][MIG]account_ebics
This commit is contained in:
@@ -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"/>
|
||||
|
Reference in New Issue
Block a user