diff --git a/__pycache__/__init__.cpython-310.pyc b/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..d59cc21 Binary files /dev/null and b/__pycache__/__init__.cpython-310.pyc differ diff --git a/data/__pycache__/__init__.cpython-310.pyc b/data/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..c86d5b6 Binary files /dev/null and b/data/__pycache__/__init__.cpython-310.pyc differ diff --git a/doc/__pycache__/__init__.cpython-310.pyc b/doc/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..af9c410 Binary files /dev/null and b/doc/__pycache__/__init__.cpython-310.pyc differ diff --git a/models/__pycache__/__init__.cpython-310.pyc b/models/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..373f0db Binary files /dev/null and b/models/__pycache__/__init__.cpython-310.pyc differ diff --git a/models/__pycache__/account_batch_payment.cpython-310.pyc b/models/__pycache__/account_batch_payment.cpython-310.pyc new file mode 100644 index 0000000..69f853b Binary files /dev/null and b/models/__pycache__/account_batch_payment.cpython-310.pyc differ diff --git a/models/__pycache__/account_payment.cpython-310.pyc b/models/__pycache__/account_payment.cpython-310.pyc new file mode 100644 index 0000000..dffa725 Binary files /dev/null and b/models/__pycache__/account_payment.cpython-310.pyc differ diff --git a/models/__pycache__/account_payment_register.cpython-310.pyc b/models/__pycache__/account_payment_register.cpython-310.pyc new file mode 100644 index 0000000..005a295 Binary files /dev/null and b/models/__pycache__/account_payment_register.cpython-310.pyc differ diff --git a/models/account_batch_payment.py b/models/account_batch_payment.py index 361f827..116962c 100644 --- a/models/account_batch_payment.py +++ b/models/account_batch_payment.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- +import logging from odoo import models, fields, api, _ from odoo.exceptions import ValidationError +_logger = logging.getLogger(__name__) + class AccountBatchPayment(models.Model): _inherit = "account.batch.payment" @@ -94,6 +97,14 @@ class AccountBatchPayment(models.Model): self.write({ 'payment_ids': [(4, payment_id) for payment_id in payment_ids] }) + + # Automatically validate the batch payment after generating payments + if self.state == 'draft': + try: + self.validate_batch() + except Exception as e: + # If validation fails, log the error but don't prevent payment creation + _logger.warning(f"Failed to automatically validate batch payment {self.id}: {str(e)}") class AccountBatchPaymentLine(models.Model):