Learn – How to create a Form View in Odoo 8

Greetings Everyone,

In this blog-post, you will learn how to create a Form View in an Odoo 8 module.

What is Form View in Odoo?

  • Form views are used to display the data from a single record.
  • Forms are used to create and edit single records.
  • The root element of a form view is <form>.
  • It consists  of regular HTML with additional structural and semantic components.
  • It is composed of high-level structure elements (groups, notebooks) and interactive elements (buttons and fields)

Example of a Form View :-

Earlier in my previous blog-post, I had created a Model to collect student’s information. Now I will create a Form View for the student model which will give it a User Interface from where entry can be created or edited.

Code for creating a Form View

 

Steps for creating Form View in Odoo

  • All views are stored in the database, in the ir.model.view model. To add a view in a module, we declare a <record> element describing the view in an XML file that will be loaded into the database when the module is installed.
  • The root element of a Form View is <form>
  • <sheet> tag is used to give the form a responsive layout
  • <group> is used to define column layouts in forms. By default, groups define 2 columns and most direct children of groups take a single column.
  • <field> direct children of groups display a label by default, and the label and the field itself have a colspan of 1 each.
  • <notebook> defines a tabbed section. Each tab is defined through a page child element.

SnapShot of Eclipse IDE:-

form view odoo module
Form View – Editable mode – Click on the image to enlarge
Form View - Editable mode - Click on the image to enlarge
Form View – Read-only Mode – Click on the image to enlarge

form view odoo module

form view odoo module

Hope you learnt how to create a Form View in Odoo module, your reviews/comments/suggestions/doubts are most welcomed, please comment in the section below, and subscribe to the newsletter to receive timely future updates of this blog.

Now next, Learn how to create a Tree View in Odoo 8.

Thank You

Myself, Burhan Vakharia, am an Odoo developer, CS Lover living in Gandhinagar, Gujarat, India. I have a degree in Computer Science and Engineering from Babaria Institute of Technology. I am currently working as Odoo Developer. Apart from Odoo Framework, I have worked on C# .Net and Android Platforms. You can contact me via my social profiles shown below.

Post Author: Burhan Vakharia

Myself, Burhan Vakharia, am an Odoo developer, CS Lover living in Gandhinagar, Gujarat, India. I have a degree in Computer Science and Engineering from Babaria Institute of Technology. I am currently working as Odoo Developer. Apart from Odoo Framework, I have worked on C# .Net and Android Platforms. You can contact me via my social profiles shown below.

2 thoughts on “Learn – How to create a Form View in Odoo 8

    Mauricioo

    (February 28, 2018 - 7:05 pm)

    Hi man, i have a question about how create a form in odoo with two models, it is possible ang how did it ?

      Burhan Vakharia

      (February 28, 2018 - 7:16 pm)

      Hello Mauricioo, You cannot create a form view in Odoo with two models. It means you cannot add fields from two different models in one form view. You cannot do this unless they have a ‘_inherits’ relationship like res.partner and res.users.

Leave a Reply

Your email address will not be published. Required fields are marked *