MitDesk docs
External AI

Document intelligence

4 min read Odoo 20.0

Document intelligence lets an outside AI program turn a PDF or a photo of a document into a draft record in Odoo. The document must already be attached in Odoo. The draft can be a vendor bill, a sales order or a purchase order. A person always decides before anything is created.

Who this is for: administrators who connect outside AI programs.

You need: Edition: Business (module minddesk_mcp_document). It also needs MitDesk Pro, Accounting (invoicing), Sales and Purchase. See Editions.

Document intelligence: company, vision/OCR model, provider class, allow documents and active

Two tools

Tool What it does
propose_document_record Reads the document and returns the values it would use. It also returns a list of what it could not find. It writes nothing to Odoo.
create_document_draft Creates one draft record from the proposal. It always stops for a person to approve. It never runs alone.

An approval that asks to create a draft record: the exact call, the values and the preview

create_document_draft does not trust the proposal that is sent back to it. It keeps only fields it knows for the target, and drops all others:

  • All targets: partner, document date, reference and lines.
  • Vendor bill only: currency and due date. The type is always a vendor bill.
  • A line has product, description, quantity and unit price. Orders also keep the unit of measure. A purchase order also keeps the planned date.

Every partner, currency, product and unit is checked again. It must still exist, the user must be allowed to read it, and it must belong to the company of the key. Nothing is posted, confirmed or validated. The result is only a draft.

Set it up

  1. Install minddesk_mcp_document.
  2. Open Configuration ▸ MCP ▸ Document intelligence and create the profile for your company. There is one profile for each company.
  3. Pick the Vision / OCR Model. The Provider class is shown from the model.
  4. Leave Allow document data to cloud models off, unless your company has decided otherwise.
  5. Give the key the rights it needs (see below).

Without an active profile, or if its model is archived, propose_document_record says that document intelligence is not configured. create_document_draft does not read the profile.

What a key needs

  • Read scope on ir.attachment, res.partner, res.currency, product.product and uom.uom.
  • The content of attachments must not be blocked on the key. It is blocked under four names: ir.attachment.datas, .raw, .db_datas and .index_content. Blocking any of them keeps the file closed.
  • Create scope on the target model. This is needed already for the proposal, so a key that could never create the draft cannot use the tool to read the document.

See Keys and scopes.

How a document is read

MitDesk accepts PDF files up to 16 MiB, and PNG or JPEG images up to 8 MiB. Other files are refused.

MitDesk first tries to read the text on your own server:

  1. For a PDF, it uses the text inside the PDF. This needs a PDF reader package (pdfplumber or docling) on the server.
  2. If there is no text, it uses OCR (text recognition) on the server. OCR is also used for PNG and JPEG images. No OCR program ships with MitDesk. Install pytesseract (with Tesseract), easyocr or paddleocr on the server.
  3. If the server cannot read a scan, MitDesk uses the Document reader if one is set. You set it in Settings ▸ MitDesk ▸ Document reader. It must be an active model on an OpenAI-compatible endpoint, hosted on your own server or in the EU, with document input.
  4. If nothing can read the scan, the tool answers "unreadable". It says why and what to install. It does not send the scan to the profile's model.

The text is cut after about 100 KB (102,400 characters). It is given to the profile's model as untrusted data, with the order to ignore any instruction inside it.

If the server has no PDF reader package at all, a PDF without a Document reader goes to the profile's model as a whole file. This needs the cloud approval below if the model is not local. The answer says why.

Cloud approval

If the model that reads documents, or the Document reader, is not on your own server, two things must be true:

  1. Allow document data to cloud models is on in the profile. If not, the call is refused with "cloud document analysis is disabled by the company administrator". The ceiling of the document's own company also counts.
  2. The program repeats the call with confirm_cloud_egress: true. Without it, the tool does nothing. It answers cloud_confirmation_required with a warning that the document may hold personal, financial or confidential data, and says what to repeat.

The setting in the profile is only a ceiling. It is not consent for one document. Both steps are needed each time. The routing rules also apply.

Routing allowances: which data class may go to which provider

Exact matches only

MitDesk does not guess. It looks for exactly one match:

  • Partner: the exact VAT number. If there is none, the exact e-mail address (upper and lower case do not matter). The partner must belong to the company or to nobody.
  • Currency: the exact ISO code, among active currencies.
  • Product: the exact internal reference of the line.

If there is no unique match, the field is left out of the proposal. An entry in the list unresolved names the field, the text that was read and the reason. A person fills it in when reviewing the draft. MitDesk creates no new partner and no new product. Only the first 200 lines are proposed. Others are reported in the same list.

MitDesk never proposes taxes, accounts, journals or payment data.

If it does not work

For general problems, see Troubleshooting.