""
Home Blog How To Add A New Page Inside A Notebook In Odoo
How To Add A New Page Inside A Notebook In Odoo

How To Add a New Page Inside a Notebook In Odoo?

Views in Odoo are used for creating the user interface to display all the fields created in the backend through python. View objects expose the number of fields; they are optional unless specified otherwise.

Structural components of the views provide visual features with little logic. They are used as elements or sets of elements in form views. Some of the basic structural elements used in the form view in Odoo are:

   Groups

   Separator

   Sheet

   Header

   Notebook & Pages

Notebook refers to a tabbed section. Each tab is defined through a child element called pages. These pages can be used to keep less-used data out of sight until needed or to organize a large number of fields by topic.

In this blog, we’ll be discussing “How to Add a Notebook & Pages to the form views in Odoo. We can add single or multiple pages to a predefined notebook, or we can create a new notebook in our form.

 Subscribe for Odoo tips, technical insights, and more!


First, let’s see how to create a new notebook and add it to a form view in Odoo.

The main function of the notebook is to give a tabbed section in the form view, so we must make all the changes inside the form view.

So, let’s edit the form view of our custom module.

Edit the form view of our custom module

We have a form view like this in our custom module, which displays basic student information.

Suppose we want to add a new field to display teacher information. We add a new notebook to this form view to separately display this teacher information. We’ll add a notebook to this form view.

Edit the form view of our custom module

In the above code, the <notebook> tag specifies the start of the notebook, the notebook content ends with </notebook> tag. Inside this notebook tag, we can specify any number of tabbed sections or “pages”.

A page start with <page> tag. You can create groups by using <group> tag or add a separator string by using <separator> tag.

Inside the <page> tag, mention all the fields that must be displayed inside this page.

Adding this code to your form view(xml file) will give you a notebook with a page like this.

Edit the form view of our custom module

Now, let’s see how to add a new page to an existing notebook in a form view in Odoo.

You can add any number of pages inside a notebook using the inheritance or “xpath” property of the Odoo. <xpath> is a special tag used to add fields to an existing form view by inheriting the form view.

Let’s see an example to add a new page to the form view of the Sales module in Odoo.

A typical Sales form view looks like this in Odoo 12.

Edit the form view of our custom module

Now suppose we want to add a new page to this notebook. We can do this easily through <xpath> tag.

First of all, we need to add the custom field that we want to display inside the pages in the notebook.

In this example, we are adding a simple “Text” field to our model to display it inside our notebook.

Edit the form view of our custom module

In the above code, we have inherited the ‘sale.order’ model of sales and added a new text field to this model. Now we need to add this field to our view file (form view) to create a new page inside the sale order form view notebook.

Edit the form view of our custom module

In the above code, we have inherited the sale order form view.

The basic syntax involved is:

          id = “Id of the custom record”

          name = “Name of the custom record”

          model = “Name of the model to be inherited”

          <xpath> = “Html tag used to add custom fields to inherited view”

xpath involves mentioning the name of the field present originally inside that inherited form view and mentioning the position of your custom field in accordance with that field.

          <page string> = “name of the page to be added”

          <field name> = “fields to be displayed inside this page” (only those field which are present inside your model can be added to the form view)

Now after adding the code to the xml file, make sure to add the ‘sale’ module to the dependency of your module like this:

Edit the form view of our custom module

After this, we need to restart the server and upgrade our module. After that, our sale order form view will look like this:

Edit the form view of our custom module

If you want to add this page to a particular position inside a notebook, you can do so by inheriting the page of the notebook & mentioning the position of the new page in accordance to this page like this:

Edit the form view of our custom module

Here, we have inherited the ‘order_lines’ page of the sale order form view and added our new page after this page like this.

Edit the form view of our custom module

WATCH THE VIDEO FOR MORE:-

 
 

I hope you found this post helpful. If you have any queries related to Odoo Development feel free to ask in the comment section, or you can also write us at [email protected]

Get in touch wit​h us!

Protected by reCAPTCHA, Privacy Policy & Terms of Service apply.
Leave a Comment

Your email address will not be published.

Submit
Your comment is under review by our moderation team.