There are distinctive varieties of view types in odoo. They are:
- Form view
- Tree view
- Kanban view
- Graph view
- Pivot view
Form view:
The 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 the 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 the 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, the 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 from view. As given, there were two fields. The name field appears blue, which we gave as required. That means the field must be filled.
Tree view:
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.
Kanban view:
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 also included respective details of the records are in the boxes.
Graph view:
In this view, the use of graphs represents details in the record. 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:
-
Bar chart
-
Line chart
-
Pie chart
-
Stacked
-
Descending
-
Ascending
We could make the chart consistent with our requirements.
Pivot view:
The 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.