Use ModelStorage hooks instead of extending create/write/delete
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user