mirror of
https://github.com/brain-tec/account_ebics.git
synced 2026-04-26 07:36:51 +00:00
[IMP] batch payment: hide ebics_upload button on non-ebics journals
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from . import fintech_ebics_register
|
from . import fintech_ebics_register
|
||||||
from . import account_bank_statement
|
from . import account_bank_statement
|
||||||
|
from . import account_journal
|
||||||
from . import ebics_config
|
from . import ebics_config
|
||||||
from . import ebics_file
|
from . import ebics_file
|
||||||
from . import ebics_file_format
|
from . import ebics_file_format
|
||||||
|
|||||||
26
account_ebics/models/account_journal.py
Normal file
26
account_ebics/models/account_journal.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Copyright 2026 Noviat.
|
||||||
|
# License LGPL-3 or later (https://www.gnu.org/licenses/lgpl).
|
||||||
|
|
||||||
|
from odoo import api, fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class AccountJournal(models.Model):
|
||||||
|
_inherit = "account.journal"
|
||||||
|
|
||||||
|
ebics_config_ids = fields.Many2many(
|
||||||
|
comodel_name="ebics.config",
|
||||||
|
relation="account_journal_ebics_config_rel",
|
||||||
|
readonly=True,
|
||||||
|
)
|
||||||
|
ebics_config_id = fields.Many2one(
|
||||||
|
comodel_name="ebics.config",
|
||||||
|
compute="_compute_ebics_config_id",
|
||||||
|
compute_sudo=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
@api.depends("ebics_config_ids")
|
||||||
|
def _compute_ebics_config_id(self):
|
||||||
|
for rec in self:
|
||||||
|
rec.ebics_config_id = rec.ebics_config_ids.filtered(
|
||||||
|
lambda r: r.state == "confirm"
|
||||||
|
)[:1]
|
||||||
@@ -1,34 +1,37 @@
|
|||||||
# Copyright 2009-2024 Noviat.
|
# Copyright 2020 Noviat.
|
||||||
# License LGPL-3 or later (http://www.gnu.org/licenses/lgpl).
|
# License LGPL-3 or later (http://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 AccountBatchPayment(models.Model):
|
class AccountBatchPayment(models.Model):
|
||||||
_inherit = "account.batch.payment"
|
_inherit = "account.batch.payment"
|
||||||
|
|
||||||
|
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 not rec.file_generation_enabled
|
||||||
|
or rec.state != "sent"
|
||||||
|
)
|
||||||
|
|
||||||
def ebics_upload(self):
|
def ebics_upload(self):
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
ctx = self.env.context.copy()
|
ctx = self.env.context.copy()
|
||||||
|
|
||||||
origin = self.env._("Batch Payment") + ": " + self.name
|
origin = self.env._("Batch Payment") + ": " + 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(
|
||||||
self.env._(
|
self.env._(
|
||||||
"No active EBICS configuration available for the selected bank."
|
"No active EBICS configuration available 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": self.export_file,
|
"default_upload_data": self.export_file,
|
||||||
"default_upload_fname": self.export_filename,
|
"default_upload_fname": self.export_filename,
|
||||||
"origin": origin,
|
"origin": origin,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<button
|
<button
|
||||||
name="ebics_upload"
|
name="ebics_upload"
|
||||||
type="object"
|
type="object"
|
||||||
invisible="not file_generation_enabled or state != 'sent'"
|
invisible="hide_ebics_upload"
|
||||||
string="EBICS Upload"
|
string="EBICS Upload"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user