Skip to content

Commit

Permalink
T1448 FIX PDF generation skip on account bank statement validation
Browse files Browse the repository at this point in the history
  • Loading branch information
NoeBerdoz authored and ecino committed Jun 20, 2024
1 parent b08f80c commit c4fe553
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion account_reconcile_compassion/models/bank_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# Releasing children from poverty in Jesus' name
# @author: Emanuel Cino <ecino@compassion.ch>
# @author: Nicolas Badoux <n.badoux@hotmail.com>
# @author: Noé Berdoz <nberdoz@compassion.ch>
#
# The licence is in the file __manifest__.py
#
##############################################################################

from odoo import fields, models
from odoo import _, fields, models
from odoo.exceptions import UserError


class AccountStatement(models.Model):
Expand Down Expand Up @@ -74,6 +76,31 @@ def button_post(self):
super().button_post()
self.with_delay()._auto_reconcile()

def button_validate(self):
"""
Override to skip PDF generation for bank statements.
PDF generation was producing excessively large files.
To re-enable account bank statements PDF generation, this logic should be
refactored and implemented as needed.
"""
if any(
statement.state != "posted" or not statement.all_lines_reconciled
for statement in self
):
raise UserError(
_(
"All the account entries lines must be processed in order to "
"validate the statement."
)
)

for statement in self:
# Chatter.
statement.message_post(body=_("Statement %s confirmed.", statement.name))

self._check_balance_end_real_same_as_computed()
self.write({"state": "confirm", "date_done": fields.Datetime.now()})

def auto_reconcile(self):
"""Auto reconcile matching invoices through jobs to avoid timeouts"""
if self.env.context.get("async_mode", True):
Expand Down

0 comments on commit c4fe553

Please sign in to comment.