Skip to content

Odoo Bank Statement Duplicate Import — 'Statement Line Already Exists' Fix

DeployMonkey Team · March 24, 2026 9 min read

Duplicate Bank Statement Errors

When importing bank statements (OFX, CSV, CAMT.053, MT940), Odoo may report:

UserError: A bank statement with the same reference already exists.

Warning: The following transactions are duplicates and were skipped:
  - Transaction 2026-03-15 - $500.00
  - Transaction 2026-03-16 - $1,200.00

ValidationError: Statement line with unique_import_id 'TXN-2026-001' already exists.

How Odoo Detects Duplicates

Odoo uses the unique_import_id field on bank statement lines to detect duplicates. When importing, if a line with the same unique_import_id already exists in the journal, Odoo skips it.

# The unique_import_id typically combines:
# - Bank account number
# - Transaction reference
# - Date and amount

# Check existing import IDs
sudo -u postgres psql -d mydb -c "
  SELECT id, date, amount, unique_import_id, statement_id
  FROM account_bank_statement_line
  WHERE unique_import_id IS NOT NULL
  ORDER BY date DESC LIMIT 20;
"

Fix 1: Overlapping Date Ranges

The most common cause — you imported a statement for March 1-31, then imported another for March 15-April 15:

# Check for overlapping statements
sudo -u postgres psql -d mydb -c "
  SELECT id, name, date, 
    (SELECT MIN(date) FROM account_bank_statement_line WHERE statement_id = s.id) as min_date,
    (SELECT MAX(date) FROM account_bank_statement_line WHERE statement_id = s.id) as max_date
  FROM account_bank_statement s
  WHERE journal_id = YOUR_JOURNAL_ID
  ORDER BY date DESC;
"

# Solution: Import only the non-overlapping period
# Or let Odoo's deduplication handle it — duplicates are skipped automatically

Fix 2: Same Statement Imported Twice

# If the entire statement was imported twice:
# Option 1: Delete the duplicate statement (if not reconciled)
# Accounting > Bank > Statements > find the duplicate > Delete

# Option 2: If reconciled, reverse the duplicate
# Open the duplicate statement > Revert > then delete

# Check for duplicate statements
sudo -u postgres psql -d mydb -c "
  SELECT name, date, COUNT(*) 
  FROM account_bank_statement
  WHERE journal_id = YOUR_JOURNAL_ID
  GROUP BY name, date
  HAVING COUNT(*) > 1;
"

Fix 3: unique_import_id Missing or Wrong

Some bank formats do not include unique transaction IDs, causing Odoo to not detect duplicates:

# Check if imported lines have unique IDs
sudo -u postgres psql -d mydb -c "
  SELECT COUNT(*) as total,
    SUM(CASE WHEN unique_import_id IS NULL THEN 1 ELSE 0 END) as no_import_id
  FROM account_bank_statement_line
  WHERE journal_id = YOUR_JOURNAL_ID;
"

# If no_import_id is high, your bank format doesn't provide unique IDs
# Odoo cannot detect duplicates for these lines

# Fix: Switch to a format that includes transaction IDs
# OFX and CAMT.053 typically include unique transaction references
# CSV imports usually do NOT include unique IDs

Fix 4: Manual Duplicate Removal

# Find duplicate transaction lines (same date, amount, reference)
sudo -u postgres psql -d mydb -c "
  SELECT date, amount, payment_ref, COUNT(*), array_agg(id) as line_ids
  FROM account_bank_statement_line
  WHERE journal_id = YOUR_JOURNAL_ID
  AND date >= '2026-03-01'
  GROUP BY date, amount, payment_ref
  HAVING COUNT(*) > 1;
"

# Before deleting duplicates:
# 1. Check if any are reconciled
sudo -u postgres psql -d mydb -c "
  SELECT id, date, amount, is_reconciled
  FROM account_bank_statement_line
  WHERE id IN (DUPLICATE_IDS);
"

# 2. Unreconcile if needed, then delete the duplicate
# Via UI: Accounting > Bank > find the line > Unreconcile > Delete

Fix 5: CSV Import Deduplication

For CSV bank imports, add your own deduplication logic:

# Before importing CSV:
# 1. Sort by date
# 2. Remove rows that overlap with previously imported periods
# 3. Add a unique reference column if possible

# In Odoo import settings:
# - Check "Test Import" first to preview which lines will be created
# - Use the reference/label field as an additional identifier

Fix 6: Resetting Bank Statement State

# If a statement is stuck in "Processing" state:
# Accounting > Bank > Statements > find the statement
# If it has no reconciled lines, you can delete and reimport

# If it has reconciled lines but some are duplicates:
# Manually unreconcile the duplicate lines
# Delete only the unreconciled duplicates
# Keep the correctly reconciled lines

Prevention

DeployMonkey's AI agent manages bank statement imports with automatic deduplication. The agent tracks import date ranges per journal and prevents overlapping imports before they create duplicates.