auto validate when creating payments from batch payments
This commit is contained in:
parent
261821dd80
commit
26524fbab9
BIN
__pycache__/__init__.cpython-310.pyc
Normal file
BIN
__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
data/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
data/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
doc/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
doc/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
models/__pycache__/__init__.cpython-310.pyc
Normal file
BIN
models/__pycache__/__init__.cpython-310.pyc
Normal file
Binary file not shown.
BIN
models/__pycache__/account_batch_payment.cpython-310.pyc
Normal file
BIN
models/__pycache__/account_batch_payment.cpython-310.pyc
Normal file
Binary file not shown.
BIN
models/__pycache__/account_payment.cpython-310.pyc
Normal file
BIN
models/__pycache__/account_payment.cpython-310.pyc
Normal file
Binary file not shown.
BIN
models/__pycache__/account_payment_register.cpython-310.pyc
Normal file
BIN
models/__pycache__/account_payment_register.cpython-310.pyc
Normal file
Binary file not shown.
@ -1,7 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AccountBatchPayment(models.Model):
|
class AccountBatchPayment(models.Model):
|
||||||
_inherit = "account.batch.payment"
|
_inherit = "account.batch.payment"
|
||||||
@ -95,6 +98,14 @@ class AccountBatchPayment(models.Model):
|
|||||||
'payment_ids': [(4, payment_id) for payment_id in payment_ids]
|
'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):
|
class AccountBatchPaymentLine(models.Model):
|
||||||
_name = "account.batch.payment.line"
|
_name = "account.batch.payment.line"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user