### Features

##### Easy creation of auto-filled documents

There is no need to create a complex HTML template that is difficult to edit and customize. It is enough to take a template in Docx format and insert the necessary values in the right places.

##### Access to all attributes of the model

During the creation of the report, the model to which this report belongs is specified. When creating a report template, we can refer to any attribute of the specified model.

##### Easy template maintenance

There is no need to change the template in the Odoo code; it is enough to upload a new template through the user interface.

##### The amount-to-words methods are available

Thanks to these methods, we can insert numbers and sums with currencies in words and round the numbers to the desired accuracy.

### How to use

##### Step 1: Install the module

Open the Apps menu in your Odoo and install the module "DOCX report".

##### Step 2: Activate the Developer Mode

To create a new report in the user interface, we need to activate the developer mode.

##### Step 3: Open Reports

Now you should go back to the settings. Click "Technical", scroll down the list, and click "Reports".

##### Step 4: Create Docx template

1. To get model attributes like model field values, use the word "docs" + (dot) + model field name.

2. To call a model method that returns a value, use the word "record" + . (dot) + model method name + () to call it.

3. Use double curly braces "{{ }}" to call methods and attributes.

4. Use curly braces with the percentage sign "{% %}" to create local variables and use loops and if conditions.

##### Step 5: Reports list view

When the Reports list view will be opened, click the "New" button to create a new report.

##### Step 6: Create a Report

1. To create a new report, you should fill out the form.

2. "Action name" is the name that will be shown in the Print menu of the model.

3. "Report Type" should be DOCS or DOCX (PDF). The gotenberg service is used to create pdf files. To use it, you need to install the Odoo module to communicate with the service and enter the access details.

4. "Model name" is the name of the model. Fields and methods will be derived from this model.

5. "Report docx template" is the template file that was created at step 4.

6. "Printed report name" is the name of the file after generation.

7. To add this report to the Print menu, you should click on the button "Add in the Print".

##### Step 7: Create a custom field

1. Custom fields are needed to get data that is not in the fields of the model associated with the report. Thanks to them, you can get data from other models, for example, through the reference fields of the current model.

2. To create a custom field you should click "Custom Fields" menu on the form and then click "Add a line"

3. After that, write your Python code for the new variable.

4. In the template, custom fields are available by the name specified in the "tech_name" field of the custom field entry. For exapmle: {{ contract_date }}.

##### Step 8: Print the Report

After printing the report the file will be saved. The information from the model will complete the template.

##### Step 9: Make a report from the Python code

If you want to make the report from the Python code, you should make an ir.action.report record and an ir.attachment record that is connected to the first one. Add the path to the Docx template from step 4.

##### Example of use for tables

The templates use Jinja2 syntax and support table generation.