[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 e7df306161
commit e464383077
4 changed files with 21 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
# Copyright 2009-2024 Noviat. # Copyright 2015 Noviat.
# License LGPL-3 or later (http://www.gnu.org/licenses/lgpl). # License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
{ {
"name": "Upload Payment Order via EBICS", "name": "Upload Payment Order via EBICS",

View File

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

View File

@@ -1,13 +1,21 @@
# Copyright 2009-2024 Noviat. # Copyright 2015 Noviat.
# License LGPL-3 or later (http://www.gnu.org/licenses/lgpl). # 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 from odoo.exceptions import UserError
class AccountPaymentOrder(models.Model): class AccountPaymentOrder(models.Model):
_inherit = "account.payment.order" _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): def ebics_upload(self):
self.ensure_one() self.ensure_one()
ctx = self.env.context.copy() ctx = self.env.context.copy()
@@ -28,8 +36,8 @@ class AccountPaymentOrder(models.Model):
if not attach: if not attach:
raise UserError( raise UserError(
_( _(
"This payment order doesn't contains attachements." "This payment order doesn't contains attachments."
"\nPlease generate first the Payment Order file first." "\nPlease generate first the Payment Order file."
) )
) )
elif len(attach) > 1: elif len(attach) > 1:
@@ -43,23 +51,16 @@ class AccountPaymentOrder(models.Model):
) )
else: else:
origin = _("Payment Order") + ": " + self.name origin = _("Payment Order") + ": " + self.name
ebics_config = self.env["ebics.config"].search( if not self.journal_id.ebics_config_id:
[
("journal_ids", "=", self.journal_id.id),
("state", "=", "confirm"),
]
)
if not ebics_config:
raise UserError( raise UserError(
_( _(
"No active EBICS configuration available " "No active EBICS configuration available "
"for the selected bank." "for the selected bank."
) )
) )
if len(ebics_config) == 1:
ctx["default_ebics_config_id"] = ebics_config.id
ctx.update( ctx.update(
{ {
"default_ebics_config_id": self.journal_id.ebics_config_id.id,
"default_upload_data": attach.datas, "default_upload_data": attach.datas,
"default_upload_fname": attach.name, "default_upload_fname": attach.name,
"origin": origin, "origin": origin,

View File

@@ -7,10 +7,11 @@
<field name="inherit_id" ref="account_payment_order.account_payment_order_form" /> <field name="inherit_id" ref="account_payment_order.account_payment_order_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<button name="open2generated" position="after"> <button name="open2generated" position="after">
<field name="hide_ebics_upload" invisible="1" />
<button <button
name="ebics_upload" name="ebics_upload"
type="object" type="object"
invisible="state != 'generated'" invisible="hide_ebics_upload"
string="EBICS Upload" string="EBICS Upload"
class="oe_highlight" class="oe_highlight"
/> />