changes
This commit is contained in:
30
batch_reconcile.py
Normal file
30
batch_reconcile.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import logging
|
||||
|
||||
RecModel = env['account.reconcile.model']
|
||||
StLine = env['account.bank.statement.line']
|
||||
|
||||
models = RecModel.search([('trigger', '=', 'auto_reconcile'), ('can_be_proposed', '=', True)])
|
||||
print(f'Auto-reconcile models: {len(models)}', flush=True)
|
||||
|
||||
# Run on ALL 4 journals
|
||||
for jid, name in [(53, 'RBC Chequing'), (28, 'RBC Visa'), (50, 'Scotia Current'), (51, 'Scotia Passport Visa')]:
|
||||
lines = StLine.search([('journal_id', '=', jid), ('is_reconciled', '=', False)])
|
||||
count_before = len(lines)
|
||||
if not count_before:
|
||||
continue
|
||||
|
||||
batch_size = 100
|
||||
for i in range(0, count_before, batch_size):
|
||||
batch = lines[i:i+batch_size]
|
||||
try:
|
||||
models._apply_reconcile_models(batch)
|
||||
except Exception as e:
|
||||
print(f' Error: {e}', flush=True)
|
||||
env.cr.commit()
|
||||
|
||||
remaining = StLine.search_count([('journal_id', '=', jid), ('is_reconciled', '=', False)])
|
||||
reconciled = count_before - remaining
|
||||
if reconciled > 0:
|
||||
print(f'{name}: reconciled {reconciled}/{count_before}, remaining {remaining}', flush=True)
|
||||
else:
|
||||
print(f'{name}: no new matches ({count_before} remaining)', flush=True)
|
||||
Reference in New Issue
Block a user