Enable Dark Mode!
list-view-parameters-in-odoo-16.jpg
By: Athul K

List View Parameters in Odoo 16

Technical Odoo 16

Views define how records are presented to end users. You can make your modules more user-friendly by using views. Odoo consists of multiple views such as Kanban, Forms, Charts, Tree, Pivot, Search, and Calendar.

In this blog, you will learn how to create a list view and perform various operations on it.

For example, let's create the model Book.Book.

class Book(models.Model):
_name = "book.book"
      _description = "Book"
name = fields.Char(string='Name', required=True)
price = fields.Integer(string="Price")
author = fields.Char(string="Author")
category = fields.Char(string='Category')
Define the records to display the list view as shown below:
<record id="view_book" model="ir.actions.act_window">
    <field name="name">Books</field>
    <field name="type">ir.actions.act_window</field>
    <field name="res_model">book.book</field>
    <field name="view_mode">tree,form</field>
    <field name="domain">[]</field>
    <field name="help" type="html">
        <p class="o_view_nocontent_smiling_face">
            Create Books
        </p>
    </field>
</record>

List the fields in the list view:

<record id="view_book_tree" model="ir.ui.view">
    <field name="name">book.book.tree</field>
    <field name="model">book.book</field>
    <field name="arch" type="xml">
        <tree string="Books">
            <field name="name"/>
            <field name="author"/>
            <field name="category"/>
            <field name="price"/>
        </tree>
    </field>
</record>

List view is shown below:

list-view-parameters-in-odoo-16

You can assign different colors to list view data.

<tree string="Books" decoration-danger="category == 'Tragedy'" decoration-success=" category == 'Novel'">

list-view-parameters-in-odoo-16

Decorators for adding different colors:

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-16

2) limit: Limiting the 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 the 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 summary, ListView is one of the best views available in the Odoo platform, giving users good insight into all operational menus and can be configured as needed based on company operational parameters.


If you need any assistance in odoo, we are online, please chat with us.



0
Comments



Leave a comment



whatsapp_icon
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message