Skip to main content
iVentureTeam

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.

Siddharth JambukiyaSiddharth JambukiyaOdoo Techno-Functional Consultant
August 27, 2026Updated August 27, 20265 min read
Technical namepdf_viewer
Field typesbinary
Viewsform
Moduleweb, present in every Odoo database
Used in coreUsed where a stored PDF should be read rather than downloaded
VersionsOdoo 20.0, Odoo 19.0, Odoo 18.0, Odoo 17.0, Odoo 16.0
No-code setupNo. Studio offers a file field; this preview is set in view XML
Alternativesbinary, many2many_binary, iframe_wrapper, image

What the PDF viewer field does

A PDF attached to a record is usually offered as a download, which means leaving Odoo, opening a viewer and coming back. For a document people read rather than keep, that is three steps too many.

This widget renders the PDF where it sits. The file is displayed through the browser's own PDF viewer inside the form, with the surrounding record still visible, so a contract, a specification or a scanned invoice can be read without going anywhere.

Two of the viewer's own controls are deliberately removed: download and print. The intent is clear from the code, and it makes the widget a reading surface rather than a distribution point.

What this means for your team

Inline document preview changes how a record is used. Approving a supplier document, checking a specification against an order line, or reading a scanned bill while coding it are all faster when the document and the data are on one screen.

Hiding download and print is worth understanding rather than working around. It does not secure the file, since anyone who can see the record can still reach the attachment through other routes; it removes the affordance from this particular surface, which keeps the preview a preview. If controlled distribution matters, that belongs in access rights rather than in a widget.

Supported options in Odoo 19

One option is declared, and it is never read. What actually configures the widget is the standard file name attribute. Read from pdf_viewer_field.js, Odoo 19.0.

OptionTypeWhat it does
filenamestring (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_imagefield<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

The usual usage

<field name="document" widget="pdf_viewer"
       filename="document_filename"/>

The companion field holds the uploaded file's name, exactly as for a plain binary field.

Read-only preview

<field name="document" widget="pdf_viewer"
       readonly="1"/>

Removes the upload path and leaves the preview. The widget also clears its temporary object URL when the field becomes read-only.

What does nothing

<!-- declared but never extracted -->
<field name="document" widget="pdf_viewer"
       options="{'preview_image': 'thumbnail'}"/>

The extractor returns only the file name attribute, so this key is ignored.

Reaching into the viewer to remove its buttons

The button hiding is the part worth knowing about. After the frame is available, the widget calls a shared helper that reaches into the embedded viewer and removes the download and print controls, with both explicitly requested. That helper exists precisely because the viewer's own interface is not otherwise configurable from Odoo.

The second detail is cleanup. When the field becomes read-only, an update hook clears the object URL the widget built for a freshly uploaded file. Object URLs stay alive until released, so clearing it avoids holding the file in memory once editing stops.

Failure is handled rather than ignored: a PDF the browser cannot render marks the widget invalid and raises a notification saying so, which is more useful than an empty frame.

And the declared option is worth repeating because it is easy to trust. The supported options list announces a preview image field, but the extractor returns a single property built from the file name attribute. Anything passed under that option name is discarded, and no warning is issued.

Version compatibility

VersionStatusNotes
Odoo 20.0In developmentNot released. Behavior unchanged on the development branch.
Odoo 19.0VerifiedVerified against the shipped source.
Odoo 18.0VerifiedSame behavior, with internal differences in how the viewer is prepared.
Odoo 17.0VerifiedSame behavior with older component conventions.
Odoo 16.0VerifiedSame 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

Odoo 20 is expected at Odoo Experience in Brussels, 24 to 26 September 2026. The development branch is unstable and this may still change; we re-verify this page after the release.

Behavior is unchanged. The inline preview, the hidden download and print controls and the file name handling all behave the same. The differences follow the wider component migration and affect patches rather than views.

Common problems and fixes

SymptomCause and fix
The download button is missingIntended. 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 displayedThe 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 nothingIt is declared but never read by the extractor. Nothing to fix; the option cannot work.
The file name is emptyThe companion field named by the filename attribute is missing from the view. Add it, invisible is enough.
The preview disappears when the form locksThe 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 allThe 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

WidgetBest forKey difference
pdf_viewerReading a stored PDF without leaving the recordInline preview with the viewer's download and print controls removed
binaryFiles meant to be downloadedA download link rather than a preview
many2many_binarySeveral attached filesA list rather than one previewed document
iframe_wrapperPreviewing an HTML documentRenders markup rather than a PDF
imagePictures stored on the recordImage rendering with zoom and sizing options

Use the plain binary widget where the file is meant to be downloaded, and the attachments widgets where there are several files rather than one. For an HTML document rather than a PDF, the iframe wrapper is the equivalent preview.

Frequently asked questions

Why is there no download button?+
The widget calls a shared helper that removes the download and print controls from the embedded viewer. It makes the field a reading surface rather than a distribution point.
Does that secure the file?+
No. Anyone who can see the record can still reach the attachment by other routes. If distribution matters, control it with access rights.
Why does the preview_image option do nothing?+
It is declared in the supported options but the extractor never reads it, returning only the file name attribute. It appears in tooling and has no effect.
How does it know the file name?+
From the companion field named by the filename attribute, exactly as for a plain binary field.
Why does the preview vanish when the form becomes read-only?+
The widget clears the temporary object URL it built for a freshly uploaded file. A saved document still renders from the record.

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

How this page was produced

The hidden download and print controls, the object URL cleanup on becoming read-only, the failure notification and the declared-but-unread option were read from pdf_viewer_field.js on the Odoo 19.0 branch. Version coverage comes from comparing the file across the 16.0, 17.0 and 18.0 branches and against the public development branch. Spotted an error? Tell us and we will correct the page.