From e8a538bf227c0806b9fc93eec8386b8513eaaf7c Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Mon, 27 Jul 2020 15:16:17 +0200 Subject: [PATCH] [8.0]support multiple EBICS connections --- account_ebics_oca_cct/__openerp__.py | 4 ++-- .../wizard/banking_export_sepa_wizard.py | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/account_ebics_oca_cct/__openerp__.py b/account_ebics_oca_cct/__openerp__.py index d727cfb..30140ea 100644 --- a/account_ebics_oca_cct/__openerp__.py +++ b/account_ebics_oca_cct/__openerp__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -# Copyright 2009-2018 Noviat. +# Copyright 2009-2020 Noviat. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Upload Payment Order via EBICS', - 'version': '8.0.1.1.0', + 'version': '8.0.1.2.0', 'license': 'AGPL-3', 'author': 'Noviat', 'category': 'Accounting & Finance', diff --git a/account_ebics_oca_cct/wizard/banking_export_sepa_wizard.py b/account_ebics_oca_cct/wizard/banking_export_sepa_wizard.py index 1d32531..2110cd7 100644 --- a/account_ebics_oca_cct/wizard/banking_export_sepa_wizard.py +++ b/account_ebics_oca_cct/wizard/banking_export_sepa_wizard.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -# Copyright 2009-2017 Noviat. +# Copyright 2009-2020 Noviat. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import api, models, _ +from openerp import _, api, models +from openerp.exceptions import Warning as UserError class BankingExportSepaWizard(models.TransientModel): @@ -14,6 +15,17 @@ class BankingExportSepaWizard(models.TransientModel): ctx = self._context.copy() payment_order = self.payment_order_ids[0] origin = _("Payment Order") + ': ' + payment_order.reference + ebics_config = self.env['ebics.config'].search([ + ('bank_id', '=', payment_order.mode.bank_id.id), + ('state', '=', 'active'), + ]) + if not ebics_config: + raise UserError(_( + "No active EBICS configuration available " + "for the selected bank." + )) + if len(ebics_config) == 1: + ctx["default_ebics_config_id"] = ebics_config.id ctx.update({ 'default_upload_data': self.file, 'default_upload_fname': self.filename, @@ -21,6 +33,7 @@ class BankingExportSepaWizard(models.TransientModel): 'payment_order_id': payment_order.id, }) ebics_xfer = self.env['ebics.xfer'].with_context(ctx).create({}) + ebics_xfer._onchange_ebics_config_id() ebics_xfer._onchange_upload_data() ebics_xfer._onchange_format_id() view = self.env.ref('account_ebics.ebics_xfer_view_form_upload')