Files
Odoo-Modules/batch_reconcile.py
gsinghpal c66bdf5089 changes
2026-04-03 15:45:18 -04:00

31 lines
1.1 KiB
Python

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)