diff --git a/account_ebics_payment_order/__manifest__.py b/account_ebics_payment_order/__manifest__.py index 1f9a6da..af898a4 100644 --- a/account_ebics_payment_order/__manifest__.py +++ b/account_ebics_payment_order/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Upload Payment Order 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_payment_order/models/account_payment_order.py b/account_ebics_payment_order/models/account_payment_order.py index d61e92a..0da4800 100644 --- a/account_ebics_payment_order/models/account_payment_order.py +++ b/account_ebics_payment_order/models/account_payment_order.py @@ -1,7 +1,7 @@ # 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 @@ -26,12 +26,24 @@ class AccountPaymentOrder(models.Model): "EBICS Processing > EBICS Upload menu")) else: origin = _("Payment Order") + ': ' + 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': attach.datas, - 'default_upload_fname': attach.datas_fname, + 'default_upload_fname': attach.name, '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')