Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Lines of code | 530 |
Technical Name |
alnas_docx |
License | LGPL-3 |
Website | https://github.com/alienyst |
Versions | 14.0 16.0 17.0 18.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Odoo Apps Dependencies |
Discuss (mail)
|
Lines of code | 530 |
Technical Name |
alnas_docx |
License | LGPL-3 |
Website | https://github.com/alienyst |
Versions | 14.0 16.0 17.0 18.0 |
Docx Report Generator
The Docx Report Generator is a module that helps you create reports using only a .docx template and Jinja syntax.
This module inspired from Report Xlsx.
Prerequisites
Before installing this module, make sure to install the following libraries:
pip install docxtpl htmldocx beautifulsoup4
Usage
For usage instructions, you can refer to the following video: Link

Example template used for a sales order: https://github.com/alienyst/alnas-docx/raw/16.0/alnas_docx/static/description/example/example.docx
Documentation on writing syntax in the document: https://docxtpl.readthedocs.io/en/stable/
Field Naming Convention
To call and write the field name, use the following format: {{docs.field_name}}
, starting with the word "docs".
Useful Functions (Indonesian Language by default)
{{spelled_out(docs.numeric_field)}}
: Spell out numbers{{formatdate(docs.date_field)}}
: Format dates{{parsehtml(docs.html_field)}}
or{{html2docx(docs.html_field)}}
: Parse HTML fields{{convert_currency(docs.monetary_field, docs.currency_id)}}
: Show monetary field{{render_image(docs.image_field)}}
or{{render_image(docs.image_field, width=10, height=10)}}
: Render image in millimeters
Note: These functions will be updated as needed.
The default language is lang='id_ID'
, but it can be changed. For example: {{spelled_out(docs.numeric_field, lang='en_US')}}
{{formatdate(docs.numeric_field, locale='en_US')}}
{{convert_currency(docs.numeric_field, locale='en_US')}}
for format_date and convert_currency, you can use all parameter from babel function Babel Documentation
Docx Output Modes
There are three modes for generating docx reports:
- composer => Generate a docx file
- zip => Generate a zip containing the docx file
- pdf => Convert the docx file to PDF using LibreOffice
If you want to use the 'pdf' option, ensure you have installed LibreOffice. Then set the LibreOffice path in Settings => Technical => Parameters => System Parameters, and search for the key default_libreoffice_path
. Set the value according to the LibreOffice installation path:
- Linux:
/usr/bin/libreoffice
- Windows:
C:\Program Files\LibreOffice\program\soffice.exe
Credit
Special thanks to Salvo (salvorapi) for helping to update the code from Odoo 16 to Odoo 17.
Feedback
We welcome any feedback and suggestions to improve this module. Thank you!
Please log in to comment on this module