Vendor invoices: OCR, AI and human validation, a pipeline that holds up
From email intake to pre-entry in Odoo: how OCR, language models and three-way matching automate vendor invoice processing without losing control over what gets paid.
By Sudo System Team
AI Agents & Automation Team
September. The holidays are over, and August's invoices are piling up on the accounts payable team's desks: PDFs received by email, crooked scans, a few handwritten invoices from tradespeople, documents in Arabic, credit notes nobody can match to an invoice anymore. Every back-to-work season brings the same reminder: manual data entry does not scale. The good news is that combining OCR, language models and well-placed human validation now makes it possible to automate most of the processing without losing control. Here is how we build this pipeline, step by step.
Why OCR alone was never enough
Character recognition tools have been around for a long time. Many companies tried them and came away disappointed. The reason: classic OCR reads characters, it does not understand a document. You have to teach it, supplier by supplier, where the invoice number and the total including tax are. As soon as the supplier changes its layout, everything breaks.
What has changed is the arrival of large language models able to read a document the way an accountant would. You give them the text extracted by OCR, or the image directly, and ask them to return structured fields: supplier, ICE (Moroccan company identifier), number, date, net amount, VAT and gross total, line items. They adapt to a new layout without configuration. They are not infallible, though, which is why everything that comes after extraction matters so much.
The pipeline, step by step
A robust process looks like a six-step chain. Each step has a precise role and can pause to ask for a human opinion.
- Intake: a dedicated email address, a shared scan folder or a supplier portal. Everything flows into a single queue.
- Extraction: OCR produces the text, then an LLM structures the data and assigns a confidence score to each field.
- Consistency checks: calculations, supplier identity, duplicates and, above all, matching against the purchase order and the goods receipt.
- Pre-entry in Odoo: the vendor bill is created as a draft, linked to the order, with the original document attached.
- Human validation of exceptions: only invoices that fail a check reach an accountant, with the exact reason.
- Scheduled payment: validated invoices feed the payment plan according to their due dates.
Orchestration can rely on n8n, a custom Odoo module, or a combination of both. The choice of tool matters less than the clarity of the rules.
Three-way matching, the heart of the system
Extracting data from an invoice is useful. Checking that it matches what was ordered and received is where the real value lies. Three-way matching compares three documents: the purchase order (what was requested, at what price), the goods receipt (what actually arrived) and the invoice (what the supplier is claiming).
Odoo handles these three objects natively. When quantities and prices agree within a defined tolerance, the invoice can go through without intervention. When they diverge, the system knows exactly why: 100 units invoiced for 90 received, a unit price 4% above the order, an unplanned freight line.

| Automatic check | What is verified | Action on failure |
|---|---|---|
| Arithmetic consistency | Net + VAT = gross, sum of lines | Sent back for validation with the quantified gap |
| Supplier identity | ICE, tax ID and bank details known in Odoo | Blocked, alert if bank details have changed |
| Duplicate | Same supplier, same number or same amount at a close date | Automatic block |
| Purchase order | Exists, correct status, same supplier | Manual matching by the buyer |
| Quantities received | Invoiced quantity less than or equal to received quantity | Wait for receipt or warehouse validation |
| Unit prices | Gap with the order within tolerance (e.g. 1 to 2%) | Validation by the buyer |
| VAT rate | Rate consistent with the item and supplier | Accounting validation |
| Confidence score | Every key field above the defined threshold | Visual check of the field concerned |
The bank details check deserves a special mention. Fraud based on changed bank details is one of the most widespread. An invoice whose bank details differ from those on file must never go through automatically, whatever the model's confidence.
Handwritten, bilingual, credit notes: the awkward cases
Handwritten invoices
They remain common among small suppliers: tradespeople, local carriers, maintenance providers. Today's models read them far better than a few years ago, but confidence stays lower. Our approach: treat them like the others, with stricter thresholds that send them to review more often. The gain is still real, because the accountant checks pre-filled fields instead of typing everything.
French and Arabic on the same document
In Morocco, many invoices mix both languages, sometimes with Western and Eastern Arabic numerals, and right-to-left text on part of the document. You need an OCR engine that handles Arabic properly, and you must ask the model to normalise its outputs: dates in a single format, amounts in Western digits, company name as registered in Odoo. Tests on a real sample of your invoices are essential before committing.
Credit notes
A misidentified credit note becomes an invoice, and you pay instead of deducting. The model must detect the document type (the word "credit note", negative amounts, reference to an original invoice) and the pipeline must link it to the relevant invoice. Without a clear reference, it is an exception, full stop.
"At first, the team checked everything, even what passed the controls. After three weeks, they started trusting the matching. Today they spend their mornings on real supplier disputes, the ones that need a phone call." — A consultant from Sudo System's AI Agents & Automation team
Measuring what matters
Without indicators, there is no way to know whether the system is improving. We track three as a priority.
The touchless automation rate: the share of invoices that go from intake to a ready-to-validate draft without any human changing a field. At the start it is often around a third; a realistic target after a few months of tuning is more like 60 to 80%, depending on the quality of upstream purchase orders. A company that buys a lot without purchase orders will plateau lower, and that is a signal about its purchasing processes, not about the tool.
Processing time: the time between receiving an invoice and validating it. It determines your ability to meet payment deadlines, take advantage of any early-payment discounts and preserve supplier relationships.
Errors avoided: duplicates blocked, price gaps detected, suspicious bank details. These are concrete amounts, and often the most compelling argument for the finance department.
Key takeaway — The goal is not zero humans, it is zero pointless data entry. Accountants validate the exceptions; automation absorbs the rest.
Bringing the accounts payable team on board
This is often the most underestimated part. For an accountant who has been keying in invoices for fifteen years, the announcement of an "AI" project sounds like a threat. It needs to be said clearly: the job changes, it does not disappear. Data entry disappears. Control, variance analysis and relationships with suppliers and buyers take centre stage.
Three practices work well. Involve the team from the moment controls are defined: they know the problem suppliers and the recurring pitfalls. Start with a few high-volume suppliers rather than everyone. And make visible what the team gains: less month-end rush, fewer calls from unhappy suppliers.
Take a trading SME receiving a few hundred invoices a month. Working this way, it can switch its first ten suppliers over in a few weeks, then gradually extend the system without rushing anyone.
Your first step
Before choosing a tool, gather a sample of around a hundred recent invoices that reflects your reality: clean PDFs, scans, handwritten, bilingual, credit notes. For each one, note whether a purchase order and a goods receipt exist in your system. This sample will tell you two things: your real automation potential, and the state of your upstream purchasing process. If you would like it analysed, Sudo System's AI Agents & Automation team can help you make the most of it.