How to add document OCR to ERPNext
Short answer
Attach each scanned document to ERPNext through the File DocType, run OCR and field extraction outside the transaction, and create draft Purchase Invoices, Purchase Receipts or attachments with confidence scores. Anything below your threshold goes to a person before it touches the ledger.
ERPNext stores documents well but does not read them. Supplier invoices arrive as PDFs and photographs, packing slips as scans, and quality certificates as stamped pages. Accounts staff key header fields and lines into a Purchase Invoice, then attach the file so an auditor can find it later.
OCR changes the keying work, not the controls. The bar is not 'read the page', it is 'produce a draft that already matches a Purchase Order and Purchase Receipt, and tell me which fields to doubt'. That depends on how well the extraction is joined to ERPNext master data, much more than on the OCR engine you choose.
What teams use it for
Supplier invoice to draft Purchase Invoice
Extract supplier, invoice number, date, tax and line amounts, match the supplier by name or tax ID, and propose a Purchase Invoice linked to the matching Purchase Receipt.
Packing slip to Purchase Receipt
A scanned packing slip becomes a draft Purchase Receipt against the Purchase Order, with received quantities and batch or lot numbers filled in for the receiving clerk to confirm.
Certificates of conformance and material certs
Capture heat numbers and lot IDs from mill certificates and attach them to the Batch record, so traceability does not rely on a folder of PDFs.
Expense Claim receipts
Receipt photos from a phone feed an Expense Claim draft with date, vendor, amount and tax, ready for approval under the existing Workflow.
Customer documents on Sales Orders
Scanned customer drawings and signed POs are indexed against the Sales Order, with text made searchable for later questions.
ERPNext integration surface
- File DocType and the upload API: attach files to any document with attached_to_doctype and attached_to_name, public or private, stored in the site's private files folder or an S3-compatible backend if configured.
- Purchase Invoice, Purchase Receipt and Expense Claim DocTypes created as drafts through /api/resource, with docstatus 0 until submit.
- Item Supplier and Supplier fields (including tax ID) for matching, and Purchase Order Item for three-way matching against ordered and received quantities.
- Bank Statement Import and Data Import tools in the Desk for bulk-structured data, which are different from document capture but useful to know about.
- doc_events on File after_insert, plus RQ background jobs, to trigger extraction without slowing the upload.
How it works
- 1
Define document types and landing places
Decide which documents you will capture first, usually supplier invoices. Give each a landing route, such as an upload page or an invoices@ mailbox, and a target DocType.
- 2
Ingest through File
Create the File record with the document attached to a placeholder or a custom 'Document Intake' DocType. Keep the original untouched for audit.
- 3
Extract with OCR and a layout-aware model
Use OCR for scans and read text directly from digital PDFs. Pull header fields and lines with per-field confidence, preferring tools that handle tables and multiple languages.
- 4
Validate against ERPNext
Check the supplier exists, the PO number is open, quantities do not exceed the receipt, currency matches, and tax totals reconcile. Fail loudly rather than patching numbers.
- 5
Create a draft and flag low confidence
Insert the draft document, highlight uncertain fields in a Comment or a custom status, and assign it to accounts through ToDo.
- 6
Review, correct, learn
Record what reviewers change. Frequent corrections on a supplier become a template or mapping rule, which raises straight-through rates over time.
Example flows
Invoice against a received PO
Trigger: PDF invoice lands in the invoices mailbox and is attached as a File.
- Extraction yields supplier, number, date, three lines and a total with confidence scores.
- Validation finds an open PO and matching receipt; line prices differ by two percent on one line.
- A draft Purchase Invoice is created, with the price variance noted.
- Accounts accepts the variance or contacts the supplier, then submits.
Result: Three-way match is largely done before a person opens the invoice, and exceptions are visible.
Mill cert to Batch
Trigger: Scanned certificate is uploaded against a Purchase Receipt.
- OCR extracts heat number, specification and quantity.
- A match is attempted to the Batch created on receipt.
- The File is attached to the Batch and the heat number is added to a custom field after confirmation.
Result: Traceability queries find the certificate by heat or lot number in seconds.
Keeping data on-prem
OCR and extraction can run entirely inside your network. Open-source OCR engines and layout-aware open-weight models run on a modest GPU server, and ERPNext's private files never leave your storage. This matters for drawings, regulated customer documents and export-controlled data. Keep the extraction service on an internal address, call ERPNext only through its API with a scoped user, and store confidence scores and the original file together. Expect to evaluate accuracy on your own scans, since fax-quality pages, stamps and handwriting reduce results, and plan a review queue rather than assuming perfect reads.
Security checklist
- Store originals in private files and restrict File access by DocType permissions, not by obscure URLs.
- Never let extraction submit a document or release payment; drafts only until accuracy is proven.
- Reconcile extracted totals with line sums and tax, and alert on bank detail changes in invoices.
- Scan uploads for malware and limit file types and sizes.
- Keep audit evidence: original file, extracted values, reviewer and final values.
Ways to get it done
Manual keying with ERPNext attachments
Effort: None, but ongoing labor.
Low invoice volume where review time already fits the day.
Commercial OCR service or invoice-capture product through the API
Effort: One to three weeks to integrate and tune matching.
Teams comfortable sending documents to a cloud processor and wanting speed to value.
Self-hosted OCR with a partner such as Netray
Effort: Pilot on one document type, then extend to receipts and certificates.
Sensitive documents, mixed languages, or customer-specific formats that need local control.
Pitfalls
- !Trusting header totals without checking line sums lets one misread digit reach the ledger.
- !Matching suppliers by fuzzy name alone creates duplicates; use tax ID or bank details as a second signal.
- !Not keeping the original file breaks audit; always attach the source.
- !Multi-page invoices with continuation pages are commonly split wrongly; test them early.
- !Tuning on clean samples overstates accuracy; use a random month of real documents.
Frequently asked questions
Does ERPNext include OCR for invoices?
Not in the core product as far as I know. ERPNext stores files and has data import tools, but reading a scanned invoice into a Purchase Invoice is usually done with an external OCR service or a Frappe app, which creates drafts through the API.
What confidence threshold should we use?
Start with human review of everything, then relax by supplier and field once measured accuracy is consistently high. Amounts, dates and PO numbers deserve stricter thresholds than descriptive text, and bank details should always be reviewed.
Can OCR run without sending documents to the cloud?
Yes. Open-source OCR and open-weight document models can run on your own servers. Quality varies with scan quality and layout, so test them against your real documents before deciding.
How do I connect extracted data to Purchase Orders?
Use the PO number if present, otherwise supplier plus item and quantity to find open Purchase Order Items. Present candidates instead of auto-selecting when more than one fits, and link the invoice items to the PO through the standard reference fields.
What about handwritten documents?
Handwriting is much less reliable than print. Treat handwritten fields as suggestions, route them to review, and where possible replace the paper step with a mobile form so the data starts out structured.
Want Document OCR working on your ERPNext?
A free 30 minute assessment: we map the integration path for your version and setup, and where it should run.
Get a free assessment