There are distinctive varieties of view types in odoo. They are:
- Form view
- Tree view
- Kanban view
- Graph view
- Pivot view
Form view type is one of the major view types in Odoo. Forms play an important part and are mainly used for inputting some records into certain fields and showing the information of a few specific persons or employers or products.
Let us create a form view of students:
Here we need to create a module “bi_school” using scaffold. Then we have to create the py and xml document for the requirement.
First, we are creating a py file named student.py on this screenshot. Here we should outline the class ‘Student’ and model of the class’ student. Student’. Then we have to define the fields inside the class. Here two fields were declared. They were: name and age.
The name should be in the character field, and age also should be in the character field. Then we declare the name field as required. That means the field must be filled.
Next, we should create an xml file for this student form.
Here we need to add the name of the model as given in the py file to display the form view. Then inside the first group, add the two fields required.
Then give the action for viewing the form view. We have to list the views in the order in which we wish to display them in the view mode.
Also, add the menu item to the form. School is given as the parent menu for students.
Thus we’ve created py and xml documents. We need to add the name of the py file in init, model name in the security, and xml files and security in the manifest. Add the xml files in the views. For example, ‘views/student.xml’
In case of inheriting any model from the base, we have to add dependencies also in the manifest.
Then after that, we have to install the module and run it. Then it will appear:
This is the student form view. As given, there were two fields. The name field appears blue in color, which we gave as required. That means the field must be filled.
Another one of the view types is a tree. Let us look at the manner it is created:
Fields are entered the same as in the form view, but it has to be entered inside the <tree>.
We created a tree view for the form in the xml file. Let’s look at how it will appear.
Here the fields are given inside the templates. First, let us look at the way we created the kanban view type.
Here each record is displayed in a kanban box. So here in the xml file, a kanban-box is used. So let us look at how it appears on the screen.
Records are displayed in separate boxes, and it also included respective details of the records in the boxes.
In this view, details in the record are represented by the use of graphs. Field names are added like in other view types in xml. After running the code for graph view type, we get output like this:
This is a line chart. At the top left of the chart, there display different charts for which it is displayed. They are:
We could make the chart consistent with our requirements.
Pivot view is like a table containing rows and columns. Field names and values will appear in rows and columns of the table.
Here a separate action for the pivot view has been covered. After running the code, the output of the view kind will be:
Here we can see a table of contents. This is the pivot view. At the right end of the top of the pivot view, we can see the view types in odoo. This is in the order that we are given in the action of the xml file.