refactor(fusion_accounting_ai): route legacy reconcile tools through engine
When fusion_accounting_bank_rec is installed, match_bank_line_to_payments and auto_reconcile_bank_lines now use fusion.reconcile.engine via the BankRecAdapter, gaining precedent recording, AI suggestion superseding, and shared validation. Legacy paths preserved for Enterprise/Community- only installs (engine model absent -> fall back to set_line_bank_statement_line and _try_auto_reconcile_statement_lines). Also wraps engine.reconcile_batch's per-line loop in a savepoint so a single bad line's DB error (e.g. check-constraint violation) no longer poisons the whole batch transaction; the existing per-line try/except now isolates failures as originally intended. Made-with: Cursor
This commit is contained in:
@@ -177,14 +177,19 @@ class FusionReconcileEngine(models.AbstractModel):
|
||||
if line.is_reconciled:
|
||||
skipped += 1
|
||||
continue
|
||||
# Per-line savepoint so a single DB-level failure (e.g. a
|
||||
# check-constraint violation on one bad line) doesn't poison
|
||||
# the whole batch's transaction.
|
||||
try:
|
||||
candidates = self._fetch_candidates(line)
|
||||
picked = self._apply_strategy(line, candidates, strategy)
|
||||
if picked:
|
||||
self.reconcile_one(line, against_lines=picked)
|
||||
reconciled += 1
|
||||
else:
|
||||
skipped += 1
|
||||
with self.env.cr.savepoint():
|
||||
candidates = self._fetch_candidates(line)
|
||||
picked = self._apply_strategy(
|
||||
line, candidates, strategy)
|
||||
if picked:
|
||||
self.reconcile_one(line, against_lines=picked)
|
||||
reconciled += 1
|
||||
else:
|
||||
skipped += 1
|
||||
except Exception as e: # noqa: BLE001
|
||||
errors.append({'line_id': line.id, 'error': str(e)})
|
||||
_logger.warning(
|
||||
|
||||
Reference in New Issue
Block a user