The _order attribute is used to set a specific default sort order for the records when they are retrieved from the database, this allows us to control the order in which they appear on views such as a list or kanban.
Size: 596.69 KB
Language: en
Added: Sep 09, 2024
Slides: 9 pages
Slide Content
_order attribute in Odoo 17 Enterprise
Introduction Enterpr ise In this slide we will discuss about _order attribute in odoo 17. The _order attribute is used to set a specific default sort order for the records when they are retrieved from the database, this allows us to control the order in which they appear on views such as a list or kanban.
Enterprise Now let's see how this will works in Odoo, I have created a module, now let's check how this will work without using order attribute.
Enterprise Then install the module and after that let's create some records. Here we can see records are displayed based on record id, default order sort is by record id
Enterprise We can change the default order of displaying records by setting the _order attribute inside the model, we are setting the records based on the order date.
Enterprise Thereafter let's refresh the code and refresh order, we can see the order has been changed on the based on order of order date. By default it is in the Ascending order.
Enterprise We can change the display order of records by adding keyword 'desc' in the _order attribute.
Enterprise After adding the keyword we need to refresh the code and order. Now we can see the display order will be changed into descending order.
For More Info. Check our company website for related blogs and Odoo book. Check our YouTube channel for functional and technical videos in Odoo. Enterprise www.cybrosys.com