[IMP] payment order: hide ebics_upload button on non-ebics journals

This commit is contained in:
Luc De Meyer
2026-04-14 19:16:57 +02:00
parent 747e5a81c8
commit c6e2660128
4 changed files with 23 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
# Copyright 2009-2024 Noviat.
# Copyright 2015 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
{

View File

@@ -1,4 +1,4 @@
# Copyright 2009-2024 Noviat.
# Copyright 2015 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lpgl).
from odoo import fields, models

View File

@@ -1,20 +1,28 @@
# Copyright 2009-2024 Noviat.
# Copyright 2015 Noviat.
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
from odoo import _, models
from odoo import fields, models
from odoo.exceptions import UserError
class AccountPaymentOrder(models.Model):
_inherit = "account.payment.order"
hide_ebics_upload = fields.Boolean(compute="_compute_hide_ebics_upload")
def _compute_hide_ebics_upload(self):
for rec in self:
rec.hide_ebics_upload = (
not rec.journal_id.ebics_config_id or rec.state != "generated"
)
def ebics_upload(self):
self.ensure_one()
ctx = self.env.context.copy()
ebics_format_id = self.payment_mode_id.ebics_format_id
if not ebics_format_id:
raise UserError(
_("Missing EBICS File Format setting on your Payment Mode.")
self.env._("Missing EBICS File Format setting on your Payment Mode.")
)
ctx.update(
{
@@ -27,14 +35,14 @@ class AccountPaymentOrder(models.Model):
)
if not attach:
raise UserError(
_(
"This payment order doesn't contains attachements."
"\nPlease generate first the Payment Order file first."
self.env._(
"This payment order doesn't contains attachments."
"\nPlease generate first the Payment Order file."
)
)
elif len(attach) > 1:
raise UserError(
_(
self.env._(
"This payment order contains multiple attachments."
"\nPlease remove the obsolete attachments or upload "
"the payment order file via the "
@@ -42,24 +50,17 @@ class AccountPaymentOrder(models.Model):
)
)
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:
origin = self.env._("Payment Order") + ": " + self.name
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": attach.datas,
"default_upload_fname": attach.name,
"origin": origin,
@@ -75,7 +76,7 @@ class AccountPaymentOrder(models.Model):
ebics_xfer._onchange_upload_data()
view = self.env.ref("account_ebics.ebics_xfer_view_form_upload")
act = {
"name": _("EBICS Upload"),
"name": self.env._("EBICS Upload"),
"view_mode": "form",
"res_model": "ebics.xfer",
"view_id": view.id,

View File

@@ -12,7 +12,7 @@
<button
name="ebics_upload"
type="object"
invisible="state != 'generated'"
invisible="hide_ebics_upload"
string="EBICS Upload"
class="oe_highlight"
/>