[14.0][MIG]account_ebics

This commit is contained in:
Luc De Meyer 2020-12-14 09:32:49 -08:00
parent eba176dea8
commit a575cdb657
20 changed files with 163 additions and 27 deletions

View File

@ -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
|

View File

@ -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',

View File

@ -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(

View File

@ -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 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
7 access_ebics_file_format_user ebics_file_format user model_ebics_file_format account.group_account_invoice 1 0 0 0
8 access_ebics_file_manager ebics_file manager model_ebics_file group_ebics_manager 1 1 1 1
9 access_ebics_file_user ebics_file user model_ebics_file account.group_account_invoice 1 1 1 0
10 access_ebics_change_passphrase access_ebics_change_passphrase model_ebics_change_passphrase group_ebics_manager 1 1 1 0
11 access_ebics_xfer access_ebics_xfer model_ebics_xfer account.group_account_invoice 1 1 1 0
12

View File

@ -1,3 +1,2 @@
from . import account_bank_statement_import
from . import ebics_change_passphrase
from . import ebics_xfer

View File

@ -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

View File

@ -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"/>

View File

@ -0,0 +1,17 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3
==========================================================
Deploy account_ebics module with OCA Bank Statement Import
==========================================================
This module makes it possible to use OCA account_statement_import
in combination with 'account_ebics'.
This module will be installed automatically when following modules are activated
on your odoo database :
- account_ebics
- account_statement_import

View File

@ -0,0 +1 @@
from . import wizards

View File

@ -0,0 +1,17 @@
# Copyright 2020 Noviat.
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
{
'name': 'account_ebics with OCA Bank Statement Imoort',
'summary': "Use OCA Bank Statement Import with account_ebics",
'version': '14.0.1.0.0',
'author': 'Noviat',
'category': 'Hidden',
'license': 'LGPL-3',
'depends': [
'account_ebics',
'account_statement_import',
],
'installable': True,
'auto_install': True,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1 @@
from . import account_statement_import

View File

@ -0,0 +1,62 @@
# 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 AccountStatementImport(models.TransientModel):
_inherit = 'account.statement.import'
def _check_parsed_data(self, stmts_vals):
""" 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)
def _create_bank_statements(self, stmts_vals, result):
"""
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.')
statement_ids = []
notifications = {
'type': 'warning',
'message': message,
'details': ''
}
return st_line_ids, [notifications]
return super()._create_bank_statements(stmts_vals, result)

View File

@ -4,7 +4,7 @@
{
'name': 'account_ebics on Odoo Enterprise',
'summary': "Deploy account_ebics module on Odoo Enterprise",
'version': '13.0.1.0.0',
'version': '14.0.1.0.0',
'author': 'Noviat',
'category': 'Hidden',
'license': 'LGPL-3',

View File

@ -0,0 +1,17 @@
.. image:: https://img.shields.io/badge/license-LGPL--3-blue.png
:target: https://www.gnu.org/licenses/lgpl
:alt: License: LGPL-3
======================================================================
Deploy account_ebics module with Odoo Enterprise Bank Statement Import
======================================================================
This module makes it possible to use Odoo Enterprise account_bank_statement_import
in combination with 'account_ebics'.
This module will be installed automatically when following modules are activated
on your odoo database :
- account_ebics_oe
- account_bank_statement_import

View File

@ -0,0 +1 @@
from . import wizards

View File

@ -0,0 +1,17 @@
# Copyright 2020 Noviat.
# License LGPL-3 or later (http://www.gnu.org/licenses/lpgl).
{
'name': 'account_ebics with Odoo Enterprise Bank Statement Import',
'summary': "Use Odoo Enterprise Bank Statement Import with account_ebics",
'version': '14.0.1.0.0',
'author': 'Noviat',
'category': 'Hidden',
'license': 'LGPL-3',
'depends': [
'account_ebics_oe',
'account_bank_statement_import',
],
'installable': True,
'auto_install': True,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1 @@
from . import account_bank_statement_import