Skip to Content
Menu

Docx Report Generator

by
Odoo
v 17.0 Third Party 469
Download for v 17.0 Deploy on Odoo.sh
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies Discuss (mail)
Lines of code 530
Technical Name alnas_docx
LicenseLGPL-3
Websitehttps://github.com/alienyst
Versions 14.0 16.0 17.0 18.0
You bought this module and need support? Click here!
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies Discuss (mail)
Lines of code 530
Technical Name alnas_docx
LicenseLGPL-3
Websitehttps://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

Video Preview

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:

  1. composer => Generate a docx file
  2. zip => Generate a zip containing the docx file
  3. 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

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author, please use the developer contact information. They can usually be found in the description.
Please choose a rating from 1 to 5 for this module.