Use ModelStorage hooks instead of extending create/write/delete

This commit is contained in:
Cédric Krier
2025-04-06 00:14:17 +02:00
parent 45122b77c0
commit 5aeff66acd
142 changed files with 2104 additions and 3189 deletions
+2 -11
View File
@@ -40,18 +40,9 @@ class MoveReconciliation(metaclass=PoolMeta):
__name__ = 'account.move.reconciliation'
@classmethod
def create(cls, vlist):
def on_modification(cls, mode, reconciliations, field_names=None):
pool = Pool()
Payment = pool.get('account.payment')
reconciliations = super().create(vlist)
super().on_modification(mode, reconciliations, field_names=field_names)
Payment.__queue__.update_reconciled(
list(_payments_to_update(reconciliations)))
return reconciliations
@classmethod
def delete(cls, reconciliations):
pool = Pool()
Payment = pool.get('account.payment')
payments = _payments_to_update(reconciliations)
super().delete(reconciliations)
Payment.__queue__.update_reconciled(list(payments))
+2 -1
View File
@@ -76,7 +76,7 @@ def cancel_clearing_move(func):
Line = pool.get('account.move.line')
Reconciliation = pool.get('account.move.reconciliation')
func(cls, payments, *args, **kwargs)
result = func(cls, payments, *args, **kwargs)
to_delete = []
to_reconcile = defaultdict(lambda: defaultdict(list))
@@ -110,6 +110,7 @@ def cancel_clearing_move(func):
for lines in to_reconcile[party].values():
Line.reconcile(lines)
cls.update_reconciled(payments)
return result
return wrapper