Preview Attachment : Images, PDFs, Office docs, videos, etc.
by Steven Marp https://apps.odoo.com/apps/browse?repo_maintainer_id=512936$ 71.71
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 617 |
| Technical Name |
sm_preview_attachment |
| License | LGPL-3 |
| Website | https://apps.odoo.com/apps/browse?repo_maintainer_id=512936 |
| Versions | 17.0 18.0 19.0 |
| Availability |
Odoo Online
Odoo.sh
On Premise
|
| Lines of code | 617 |
| Technical Name |
sm_preview_attachment |
| License | LGPL-3 |
| Website | https://apps.odoo.com/apps/browse?repo_maintainer_id=512936 |
| Versions | 17.0 18.0 19.0 |
Preview Attachment
Preview Images, PDFs, Office Documents, Excel Reports & More â Directly in Odoo
Watch It In Action
See how Preview Attachment transforms your Odoo experience â no more unnecessary downloads.
Key Features
Binary Field PreviewOne-click Preview button (eye icon) on every Binary field â form view and list view. Works on all widgets including custom ones. |
Attachment PreviewPreview button on Many2Many attachment fields. Quick preview without downloading â images, PDFs, documents all viewable inline. |
PDF Report PreviewIntercepts PDF report printing â preview the report in a modal before downloading or printing. Works on all QWeb PDF reports. |
Excel Preview (SheetJS)Preview Excel files client-side using SheetJS â rendered as interactive HTML tables. No Office Online or public URL required. Works on localhost! |
Office Document SupportPreview Word, Excel, and PowerPoint via Office Online or Google Docs Viewer. Automatic fallback with download option on localhost. |
Excel Preview MixinEasy-to-use Python mixin for wizard Excel reports. Inherit the mixin, implement 2 methods, and get Preview + Download buttons automatically! |
Supported File Formats
| Type | Extensions | Preview Method |
|---|---|---|
| Images | PNG, JPG, JPEG, GIF, BMP, SVG, WEBP, ICO, TIFF | Native <img> tag â fast and reliable |
| Browser PDF viewer (iframe) | ||
| Excel | XLS, XLSX, ODS | SheetJS client-side rendering (even on localhost!) |
| Word | DOC, DOCX, ODT, RTF | Office Online / Google Docs Viewer |
| PowerPoint | PPT, PPTX, ODP | Office Online / Google Docs Viewer |
| Video | MP4, WEBM, OGG, MOV, AVI | HTML5 video player |
| Audio | MP3, WAV, OGG, FLAC, AAC, M4A | HTML5 audio player |
| Text | TXT, CSV, JSON, XML, HTML, CSS, JS, PY, LOG | Text viewer (iframe) |
| Unknown | Any file without extension | Auto-detect via Content-Type header |
How It Works
Install ModuleInstall the module â no configuration needed. Preview buttons appear automatically on all Binary fields. |
Click PreviewClick the eye icon next to any file field or attachment. A preview modal opens instantly. |
Print ReportsPDF and Excel reports are intercepted â preview first, then download or print from the modal. |
Done!Close with ESC or click backdrop. Download anytime from the modal header. Zero configuration required. |
Excel Preview Mixin for Developers
Build wizard Excel reports with built-in Preview + Download buttons
Python â Inherit the Mixinclass MyWizard(models.TransientModel):
_name = 'my.wizard'
_inherit = ['sm.excel.preview.mixin']
@property
def _excel_filename(self):
return 'my_report.xlsx'
def _generate_excel_data(self):
output = io.BytesIO()
# ... generate Excel with openpyxl ...
return output
|
XML â Add Buttons<footer>
<button name="action_preview_excel"
type="object"
string="Preview"
class="btn-primary"/>
<button name="action_download_excel"
type="object"
string="Download"
class="btn-secondary"/>
<button string="Close"
special="cancel"/>
</footer>
|
That's it! Just inherit the mixin and implement 2 methods. The mixin handles Preview modal, SheetJS rendering, and file download.
Why This Module?
Zero ConfigurationInstall and it just works. No settings, no setup. Preview buttons appear automatically on every Binary field and attachment across all models. |
Works on All Binary WidgetsNot just standard Binary fields â works on custom widgets too (work_permit_upload, etc.) thanks to smart JS DOM fallback when OWL patches don't apply. |
Community & EnterpriseWorks on both Odoo Community and Enterprise editions. Only depends on the |
Auto-Detect File TypesFiles without extensions? No problem. The module auto-detects file type via Content-Type header and renders the correct preview automatically. |
Lightweight & FastPure frontend JavaScript using OWL 2 patches. No heavy backend processing, no extra API calls, no database writes. Zero performance impact. |
Excel on LocalhostUnlike other modules that need Office Online (public URL), our Excel preview uses SheetJS client-side rendering â works perfectly on localhost and private servers. |
Technical Details
Module Info
|
Components Patched
|
Please log in to comment on this module