pdf_viewer
A stored PDF rendered inline instead of offered as a download. It hides the viewer's own download and print buttons, and it declares an option the code never actually reads.
| Technical name | pdf_viewer |
|---|---|
| Field types | binary |
| Views | form |
| Module | web, present in every Odoo database |
| Used in core | Used where a stored PDF should be read rather than downloaded |
| Versions | Odoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0, Odoo 16.0 |
| No-code setup | No. Studio offers a file field; this preview is set in view XML |
| Alternatives | binary, many2many_binary, iframe_wrapper, image |
What the PDF viewer field does
What this means for your team
Supported options in Odoo 19
| Option | Type | What it does |
|---|---|---|
filename | string (attribute) | Names the companion field holding the uploaded file's name. This is the widget's real configuration, and it is an attribute rather than an option. |
preview_image | field | <strong>Declared and never read.</strong> The extractor returns only the file name, so this option has no effect despite appearing in developer tooling. |
The declared option is dead. The descriptor announces a preview image option, but the extractor returns only the file name attribute, so the option never reaches the component. It shows up in developer tooling and does nothing, which is the same declared-but-unread pattern seen on a few other Odoo widgets.
Working examples
Reaching into the viewer to remove its buttons
Version compatibility
| Version | Status | Notes |
|---|---|---|
| Odoo 20.0 | In development | Not released. Behavior unchanged on the development branch. |
| Odoo 19.0 | Verified | Verified against the shipped source. |
| Odoo 18.0 | Verified | Same behavior, with internal differences in how the viewer is prepared. |
| Odoo 17.0 | Verified | Same behavior with older component conventions. |
| Odoo 16.0 | Verified | Same behavior with older component conventions. |
Upgrade note. The widget has existed since Odoo 16 and its usage in views is unchanged. The internals have moved between versions, including how the viewer's buttons are hidden, so a customization that reached into the frame itself is more likely to need attention than a view.
What is changing in Odoo 20
Common problems and fixes
| Symptom | Cause and fix |
|---|---|
| The download button is missing | Intended. The widget removes the download and print controls from the embedded viewer. Use a plain binary field if the file should be downloadable from that screen. |
| A notification says the PDF could not be displayed | The browser could not render the file, usually because it is not a valid PDF. Check what was uploaded; the field accepts any binary. |
| The preview_image option does nothing | It is declared but never read by the extractor. Nothing to fix; the option cannot work. |
| The file name is empty | The companion field named by the filename attribute is missing from the view. Add it, invisible is enough. |
| The preview disappears when the form locks | The widget clears its temporary object URL when the field becomes read-only. Expected for a freshly uploaded file; a saved one still renders from the record. |
| Nothing renders at all | The field is empty or the browser blocked the embedded viewer. Check the field's content and the browser's PDF settings. |
PDF viewer field vs the alternatives
| Widget | Best for | Key difference |
|---|---|---|
pdf_viewer | Reading a stored PDF without leaving the record | Inline preview with the viewer's download and print controls removed |
| binary | Files meant to be downloaded | A download link rather than a preview |
| many2many_binary | Several attached files | A list rather than one previewed document |
| iframe_wrapper | Previewing an HTML document | Renders markup rather than a PDF |
| image | Pictures stored on the record | Image rendering with zoom and sizing options |
Frequently asked questions
Why is there no download button?+
Does that secure the file?+
Why does the preview_image option do nothing?+
How does it know the file name?+
Why does the preview vanish when the form becomes read-only?+
Documents read where the work happens
Inline previews, document capture and the approval flows around them turn an ERP into the only screen your team needs open. We build that into Odoo on versions 16 through 19.
Book a free consultation