From 3768331ff91d15a0fa4ca6e5d4c5487e0797e105 Mon Sep 17 00:00:00 2001 From: Luc De Meyer Date: Tue, 14 Apr 2026 15:52:51 +0200 Subject: [PATCH] [IMP] batch payment: hide ebics_upload button on non-ebics journals --- .../models/account_batch_payment.py | 26 ++++++++++++------- .../views/account_batch_payment_views.xml | 5 ++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/account_ebics_batch_payment/models/account_batch_payment.py b/account_ebics_batch_payment/models/account_batch_payment.py index dfe271a..07bb8a1 100644 --- a/account_ebics_batch_payment/models/account_batch_payment.py +++ b/account_ebics_batch_payment/models/account_batch_payment.py @@ -1,34 +1,40 @@ # Copyright 2020 Noviat. # License LGPL-3 or later (https://www.gnu.org/licenses/lgpl). -from odoo import models +from odoo import api, fields, models from odoo.exceptions import UserError class AccountBatchPayment(models.Model): _inherit = "account.batch.payment" + hide_ebics_upload = fields.Boolean( + compute="_compute_hide_ebics_upload", default=True + ) + + @api.depends("journal_id.ebics_config_id", "file_generation_enabled", "state") + def _compute_hide_ebics_upload(self): + for rec in self: + rec.hide_ebics_upload = ( + not rec.journal_id.ebics_config_id + or not rec.file_generation_enabled + or rec.state != "sent" + ) + def ebics_upload(self): self.ensure_one() ctx = self.env.context.copy() origin = self.env._("Batch Payment") + ": " + self.name - ebics_config = self.env["ebics.config"].search( - [ - ("journal_ids", "=", self.journal_id.id), - ("state", "=", "confirm"), - ] - ) - if not ebics_config: + if not self.journal_id.ebics_config_id: raise UserError( self.env._( "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_ebics_config_id": self.journal_id.ebics_config_id.id, "default_upload_data": self.export_file, "default_upload_fname": self.export_filename, "origin": origin, diff --git a/account_ebics_batch_payment/views/account_batch_payment_views.xml b/account_ebics_batch_payment/views/account_batch_payment_views.xml index d1df84a..3bdf1fd 100644 --- a/account_ebics_batch_payment/views/account_batch_payment_views.xml +++ b/account_ebics_batch_payment/views/account_batch_payment_views.xml @@ -5,12 +5,13 @@ account.batch.payment -