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,32 +1,35 @@
|
||||
# Copyright 2009-2023 Noviat.
|
||||
# Copyright 2020 Noviat.
|
||||
# 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
|
||||
|
||||
|
||||
class AccountBatchPayment(models.Model):
|
||||
_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):
|
||||
self.ensure_one()
|
||||
ctx = self.env.context.copy()
|
||||
|
||||
origin = _("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(
|
||||
_("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(
|
||||
{
|
||||
"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,
|
||||
|
||||
Reference in New Issue
Block a user