diff --git a/account_ebics/README.rst b/account_ebics/README.rst index 170918d..e5e5d5d 100644 --- a/account_ebics/README.rst +++ b/account_ebics/README.rst @@ -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 | diff --git a/account_ebics/__manifest__.py b/account_ebics/__manifest__.py index 2a428e6..9ce48bf 100644 --- a/account_ebics/__manifest__.py +++ b/account_ebics/__manifest__.py @@ -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', diff --git a/account_ebics/models/ebics_file.py b/account_ebics/models/ebics_file.py index 80dabf2..d20bf4c 100644 --- a/account_ebics/models/ebics_file.py +++ b/account_ebics/models/ebics_file.py @@ -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( diff --git a/account_ebics/security/ir.model.access.csv b/account_ebics/security/ir.model.access.csv index 3d71939..9c2ae17 100644 --- a/account_ebics/security/ir.model.access.csv +++ b/account_ebics/security/ir.model.access.csv @@ -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 diff --git a/account_ebics/wizards/__init__.py b/account_ebics/wizards/__init__.py index 944b9c8..b66b034 100644 --- a/account_ebics/wizards/__init__.py +++ b/account_ebics/wizards/__init__.py @@ -1,3 +1,2 @@ -from . import account_bank_statement_import from . import ebics_change_passphrase from . import ebics_xfer diff --git a/account_ebics/wizards/account_bank_statement_import.py b/account_ebics/wizards/account_bank_statement_import.py deleted file mode 100644 index 937f807..0000000 --- a/account_ebics/wizards/account_bank_statement_import.py +++ /dev/null @@ -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) diff --git a/account_ebics/wizards/ebics_xfer.py b/account_ebics/wizards/ebics_xfer.py index f31df5f..dd8173a 100644 --- a/account_ebics/wizards/ebics_xfer.py +++ b/account_ebics/wizards/ebics_xfer.py @@ -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 diff --git a/account_ebics/wizards/ebics_xfer.xml b/account_ebics/wizards/ebics_xfer.xml index 60b5369..091c08b 100644 --- a/account_ebics/wizards/ebics_xfer.xml +++ b/account_ebics/wizards/ebics_xfer.xml @@ -16,8 +16,10 @@ options="{'no_create': True, 'no_open': True}"/> - + +