How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Originally published at: How to create a new ONLYOFFICE form template for Odoo: a detailed guide | ONLYOFFICE Blog


The newly released ONLYOFFICE Templates app allows you to automate the process of form creation using data and fields available in Odoo. Although there are ready-to-use templates, such as invoices and bills of sale, creating new ones from scratch might be challenging, especially for new users. In this step-by-step guide, you will learn to create new ONLYOFFICE templates for various Odoo modules.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

What you need to get started

To get started with form creation, you need to have a running Odoo instance, an ONLYOFFICE Docs instance and the ONLYOFFICE Templates app installed. This article gives you a detailed overview of this integration and explains how it works.

If you have ONLYOFFICE Templates integrated with your Odoo platform, you can create new form templates, edit the existing ones and print already completed form templates based on the data and fields available in Odoo.

Let’s find out how you can create a new form template for one of the Odoo modules. For example, a two-week notice template for the HR department to make it easier for employees to resign.

Step 1. Switch to the developer mode

To create new form templates, it is recommended that the developer mode in Odoo be enabled. To do so, click the Settings icon in the Home menu, find the Developer tools section in General Settings and click the Activate the developer mode button. You will be automatically redirected to the Home menu after the developer mode is on.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Step 2. Create a new ONLYOFFICE template

The next step implies the creation of a new ONLYOFFICE template in the Templates module. Launch the ONLYOFFICE Templates app from the Home menu and click the New button in the upper left corner of the module.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

The app allows you to create new templates from scratch if you click the New button. Alternatively, you can upload a file from your local drive using the Upload your file button. The newly created form template will appear in the module.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

When creating a new template, it’s vitally important to select the required Odoo model. Your choice depends on what you are going to create. If you choose the wrong model, your template won’t work as expected.

To determine the model name you need to select, you can take a look at the URL address of the corresponding record in Odoo. To do this, go to the required Odoo module, open any record that has the Print with ONLYOFFICE button and look at the URL address to find the hint.

In our case, we want to create a two-week notice template. That’s why we go to the Employees module, select one of the available records and look at its URL address. The required value is hr.employee.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Now copy this value and get back to the template creation window. Enter the copied value in the Select Model field and click Enter. The hr.employee value corresponds to the Employee model so this model will be chosen automatically for our new template. Don’t forget to enter the template name and either create a new template from scratch or upload a new file from your device using one of the available options. Your template will appear in the Templates module.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Step 4. Edit your new ONLYOFFICE template

Now that your template is created, open it from the Templates module and edit its contents using the functionality of the ONLYOFFICE editor. You can enter text, add headers and footers, insert objects and use various formatting tools.

When the final version of your PDF template is ready, you can proceed with the next step and insert fillable fields based on the Odoo data.

Step 4. Insert fillable fields with the ONLYOFFICE Templates app

Now you need to insert fillable fields in your template so that the ONLYOFFICE app can use the Odoo data when you print the template. This process might seem complicated at first sight but don’t worry. When you understand the main principle, it will be a piece of cake.

With the ONLYOFFICE app, you can automatically add the required fields based on certain Odoo parameters. Since the developer mode is on, all fields in each Odoo module will have a question mark to help you find the required parameters. Particularly, you need information from the Field and Model parameters.

In our template, there will be information about one of our employees. That’s why you need to go to the Employees module and open one of the records. The first field in your template can be Manager which will show the name of the employee’s manager in your two-week notice. So point your mouse cursor at the question mark next to Manager, and you will see some parameters.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

The ones you need are:

  • Field: parent_id
  • Model: hr.employee

You need to know these parameters to insert the correct field in your template. Get back to your template and click where you want to add the first field. On the left-side panel, insert parent_id and find it in the list. It belongs to the Employee section which has a lot of available fields.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Now find Manager in the Employee section. This is the required field. When you click on it, the field will be automatically added to your template with a certain Odoo key.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Congratulations! Now you have just inserted your first field. Using the same algorithm, add as many fields as you need.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Now you can get it completed with the Odoo data when you choose this template after clicking the Print with ONLYOFFICE button in the Action menu.

Tips on how to find Odoo fields in the ONLYOFFICE app

Finding the desired Odoo fields will be easier if you take into consideration the following tips:

Tip 1. When you are going to add an Odoo field in the ONLYOFFICE editor, you need to know its type first. You can see the type under the Model parameter in the developer mode.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Tip 2. If a field’s type is one2many / many2many / many2many /many2one, it means that the value in this field is a separate entity with its own fields. Such a field will be displayed as a separate section on the left-side panel of the ONLYOFFICE Editor. When you open this section, all the related fields of this entity will be displayed as well.

For example, imagine that you need to add an employee’s address to your template. Using the developer mode, you will find out that the name of this field is address_id and its type is many2one. This is a separate entity with its own properties (fields), which you can also view and find in the ONLYOFFICE editor.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Click the Internal link button (arrow) to access all the related fields in the Odoo section.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

In this Address record, you can view the fields of the Address entity and then find them in the ONLYOFFICE editor using their names. For example, let’s find and insert the Tax ID field. Its name is vat and it belongs to the address_id section. On the left-side panel of the ONLYOFFICE Editor, find the address_id section, open this section and find the field called vat.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Using the same algorithm, you can easily find and add Odoo fields with the one2many / many2many / many2many /many2one type.

Tip 3. If the Model value of a field specifies a model not from the URL address, then you need to look for a subsection. In this case, the key in the section will have the same name as the model.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

How to create tables in ONLYOFFICE Templates

The ONLYOFFICE app has a useful feature that makes it easier to work with tables. If you want to create a template that will contain a table (e.g. an invoice with a list of items to be sold), you won’t have to insert fields for all rows. You just need to create a table in the ONLYOFFICE editor and insert the fields that correspond to the main Odoo fields using their IDs, such as Description, Quantity, Unit Price, Taxes, Amount, etc.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

To find out which field should be inserted in a certain column of your table, you can place the mouse cursor in the developer mode on the corresponding column header in the Odoo section and there you will see the name of the field.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

When you print the template, you will see that each item has a separate row. This way, the ONLYOFFICE app can add as many items as needed depending on the data available in the corresponding Odoo module.

How to create a new ONLYOFFICE form template for Odoo: a detailed guide

Get the ONLYOFFICE Templates app

Get the ONLYOFFICE app from Odoo Apps Store and improve electronic document workflows in your team using ONLYOFFICE templates for different Odoo modules:

GET NOW

Important note: you need to obtain a special ONLYOFFICE Docs license with the Odoo Template app support. To learn more, please, contact our sales team at sales@onlyoffice.com.

Useful links

ONLYFFOCE for Odoo

Get ONLYOFFICE Docs for Odoo

Main ONLYOFFICE connector for Odoo

ONLYOFFICE Templates app

How to work with ONLYOFFICE templates in Odoo

Updated ONLYOFFICE connectors for Odoo

Guides in Help Center

1 Like