How to auto-print Odoo delivery slips
Render an Odoo delivery-slip PDF on the server and print it with the API. No Odoo plugin is included; call POST /v1/print-jobs from a server action.
For Odoo warehouses printing the delivery slip at validation
Overview
Odoo's delivery slip is a QWeb report. The unattended path is to render that report to PDF inside the server action that validates the picking, then send the bytes to the printer at the dock. PrintBase does not install an Odoo module and does not replace the report engine.
Use content_type pdf and the printer_code of the dock printer. Keep ZPL product labels as a separate raw job if you print those too. The slip and the label are different paper and often different queues.
Idempotency-Key odoo-slip-{pickingId} covers a double click on Validate. A corrected slip after you change quantities needs a new key.
Integration steps
- 01
Render the existing report
Call the delivery slip report's render to get PDF bytes in the same transaction path you trust. Do not screenshot the form.
- 02
Select the dock printer
Map printer_code on the warehouse or the picking type. GET /v1/printers is how you learn the code, not the Odoo printer dialog.
- 03
POST the PDF
content is base64 of the PDF, content_type pdf. The API key is a system parameter.
- 04
Do not mark printed on HTTP 201 alone
Store the job id. Background-check GET /v1/print-jobs/{id} or a paid webhook before you show a printed badge.
- 05
Reprint with a new key
A damaged slip is a new Idempotency-Key. Reusing the old key returns the original job record and does not print again.
Python
# Odoo delivery slip PDF from the report renderer
import json, os, urllib.request
body = json.dumps({
"printer_code": int(os.environ["PRINTER_CODE"]),
"content_type": "pdf",
"content": base64.b64encode(pdf_bytes).decode(),,
"copies": 1,
}).encode()
req = urllib.request.Request(
"https://api.printbase.cloud/v1/print-jobs",
data=body,
method="POST",
headers={
"Authorization": f"Bearer {os.environ['PRINTBASE_API_KEY']}",
"Content-Type": "application/json",
"Idempotency-Key": f'odoo-slip-{picking.id}',
},
)
with urllib.request.urlopen(req) as res:
job = json.load(res) # {"id": "job_abc", "status": "queued"}
Details for this setup
PDF path for an Odoo delivery slip
Use content_type pdf and exactly one of content (standard base64) or content_url (an http or https URL the agent can download). A private file must be fetched by your server and sent as base64, or exposed as a short-lived URL. On Windows the agent asks a PDF app to print to the named queue; if none is registered, the failure text names Adobe Reader or SumatraPDF as examples. macOS and Linux use lp.
Report paper format
Set the QWeb paper format to the tray you actually have. The print API does not switch A4 to letter.
Questions
Can the IoT Box and this API coexist?
Yes. Use the agent for printers it is installed beside, and leave other printers on whatever you use today.
The PDF is blank.
That is the report render, not the transport. Open the PDF before you base64 it.
Multi-company printers?
Use a different API key per company if they are different PrintBase organizations, or different printer_code values inside one organization. Keys are scoped to the organization that created them.
Does Validate have to wait for the printer?
No. POST returns when the job is queued. Do the HTTP call after you have the PDF, and do not hold the database transaction open for the physical print.
Free plan: 100 jobs a month on one computer, no card.