List View Parameters in Odoo 15

List View Parameters in Odoo 15

2 minutes, 15 seconds Read

Views are what define how records should be displayed to end-users. We can make modules more user-friendly by using the views. Odoo consists of several views such as Kanban, form, graph, tree, pivot, search, and calendar.

Through this blog, let us see how to create a list view and execute various operations on the list view.

For example, let us create a model ‘student.student’.

class Student(models.Model):
_name = "student.student"
_description = "Student"
name = fields.Char(string='Name', required=True)
age = fields.Integer(string="Age")
standard = fields.Char(string="Class")
mobile = fields.Char(string='Mobile', required=True)
Father_name = fields.Char(string='Father name')

Now define a record to view the list view as shown below:

<record id="view_student" model="ir.actions.act_window">
   <field name="name">Student</field>
   <field name="type">ir.actions.act_window</field>
   <field name="res_model">student.student</field>
   <field name="view_mode">tree,form</field>
   <field name="help" type="html">
       <p class="o_view_nocontent_smiling_face">
           Create Student
       </p>
   </field>
</record>

List the fields in the list view:

<record id="view_student_tree" model="ir.ui.view">
   <field name="name">student.student.tree</field>
   <field name="model">student.student</field>
   <field name="arch" type="xml">
       <tree string="Students">
           <field name="name"/>
           <field name="age"/>
           <field name="standard"/>
           <field name="mobile"/>
           <field name="Father_name"/>
       </tree>
   </field>
</record>

The list view is shown below:

list-view-parameters-in-odoo-15-cybrosys

We can set various colours to the list-view data.

<tree string="Students" decoration-danger="standard == 'plus one'" decoration-success=" standard == 'plus two'">

list-view-parameters-in-odoo-15-cybrosys

Decorators for adding different colours:

decoration-it – ITALICS

decoration-bf – BOLD

decoration-danger – LIGHT RED

decoration-primary – LIGHT PURPLE

decoration-info – LIGHT BLUE

decoration-warning – LIGHT BROWN

decoration-muted – LIGHT GRAY

decoration-success – LIGHT GREEN

1. editable: Used to make a list view editable.

Example: <tree string=”Student” editable=”top”>

list-view-parameters-in-odoo-15-cybrosys

2) limit: Limiting a number of records in the list view

Example: <tree string=”name” limit=”50″>

3) delete:Disables the action of deleting

Example: <tree string=”Student” delete=”false”>

4) create: Disables creation of  a new record

Example: <tree string=”Student” create=”0″>

5) edit: Declines the option to edit the list view

Example: <tree string=”Student” edit=”0″>

In conclusion, the ListView is one of the best views available in the Odoo platform providing the user’s with the proper insight available in all the menus of operation and can be configured based on the opertsional parameters of the business as per the need.

Similar Posts

Leave a Reply

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