2014-09-17 21:54:48 +02:00
|
|
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
|
|
|
|
# this repository contains the full copyright notices and license terms.
|
2022-04-11 20:51:41 +02:00
|
|
|
from trytond.pool import Pool, PoolMeta
|
2014-09-17 21:54:48 +02:00
|
|
|
|
|
|
|
|
|
2018-06-26 19:11:43 +02:00
|
|
|
class Move(metaclass=PoolMeta):
|
2014-09-17 21:54:48 +02:00
|
|
|
__name__ = 'account.move'
|
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def _get_origin(cls):
|
2025-04-04 00:45:18 +02:00
|
|
|
models = super()._get_origin()
|
2014-09-17 21:54:48 +02:00
|
|
|
return models + ['account.payment']
|
2022-04-11 20:51:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def _payments_to_update(reconciliations):
|
|
|
|
|
pool = Pool()
|
|
|
|
|
Payment = pool.get('account.payment')
|
|
|
|
|
Reconciliation = pool.get('account.move.reconciliation')
|
|
|
|
|
|
|
|
|
|
moves = set()
|
|
|
|
|
others = set()
|
|
|
|
|
for reconciliation in reconciliations:
|
|
|
|
|
for line in reconciliation.lines:
|
|
|
|
|
moves.add(line.move)
|
|
|
|
|
others.update(line.reconciliations_delegated)
|
|
|
|
|
|
2026-03-22 21:05:26 +01:00
|
|
|
payments = set(Payment.search([
|
|
|
|
|
('clearing_move', 'in', moves),
|
|
|
|
|
], order=[]))
|
2022-04-11 20:51:41 +02:00
|
|
|
if others:
|
|
|
|
|
payments.update(_payments_to_update(Reconciliation.browse(others)))
|
|
|
|
|
|
|
|
|
|
return payments
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MoveReconciliation(metaclass=PoolMeta):
|
|
|
|
|
__name__ = 'account.move.reconciliation'
|
|
|
|
|
|
|
|
|
|
@classmethod
|
2025-04-06 00:14:17 +02:00
|
|
|
def on_modification(cls, mode, reconciliations, field_names=None):
|
2022-04-11 20:51:41 +02:00
|
|
|
pool = Pool()
|
|
|
|
|
Payment = pool.get('account.payment')
|
2025-04-06 00:14:17 +02:00
|
|
|
super().on_modification(mode, reconciliations, field_names=field_names)
|
2022-04-11 20:51:41 +02:00
|
|
|
Payment.__queue__.update_reconciled(
|
|
|
|
|
list(_payments_to_update(reconciliations)))
|