From ccfb1a10ae89166c44376e9db7cbcc5923cb5994 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Fri, 24 Jul 2020 12:44:49 +0200 Subject: [PATCH] [13.0]batch payment ebics.xfer wiz improvements --- account_ebics/wizards/ebics_xfer.xml | 10 ++++++++-- account_ebics_batch_payment/__manifest__.py | 2 +- .../models/account_batch_payment.py | 16 +++++++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/account_ebics/wizards/ebics_xfer.xml b/account_ebics/wizards/ebics_xfer.xml index 594e55e..66b16f6 100644 --- a/account_ebics/wizards/ebics_xfer.xml +++ b/account_ebics/wizards/ebics_xfer.xml @@ -10,7 +10,10 @@ - + @@ -33,7 +36,10 @@ - + diff --git a/account_ebics_batch_payment/__manifest__.py b/account_ebics_batch_payment/__manifest__.py index 4aac5cc..60d98a4 100644 --- a/account_ebics_batch_payment/__manifest__.py +++ b/account_ebics_batch_payment/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Upload Batch Payment via EBICS", - "version": "13.0.1.0.0", + "version": "13.0.1.1.0", "license": "LGPL-3", "author": "Noviat", "category": "Accounting & Finance", diff --git a/account_ebics_batch_payment/models/account_batch_payment.py b/account_ebics_batch_payment/models/account_batch_payment.py index 730c0d8..316c101 100644 --- a/account_ebics_batch_payment/models/account_batch_payment.py +++ b/account_ebics_batch_payment/models/account_batch_payment.py @@ -1,7 +1,8 @@ # Copyright 2009-2020 Noviat. # License LGPL-3 or later (http://www.gnu.org/licenses/lpgl). -from odoo import _, api, models +from odoo import _, models +from odoo.exceptions import UserError class AccountBatchPayment(models.Model): @@ -12,6 +13,17 @@ class AccountBatchPayment(models.Model): ctx = self.env.context.copy() origin = _("Batch Payment") + ": " + self.name + ebics_config = self.env['ebics.config'].search([ + ('journal_ids', '=', self.journal_id.id), + ('state', '=', 'confirm'), + ]) + 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.export_file, @@ -19,7 +31,9 @@ class AccountBatchPayment(models.Model): "origin": origin, } ) + 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")