In Odoo 16, how can I configure my model so that newly created records appear at the top of tree views by default?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Бухоблік
- Склад
- PoS
- Проект
- MRP
Це запитання позначене
Hi
add in your model python file add _order attribute
_order = 'create_date desc'
example,

Its working file and newly created record first
Thanks
In your model's Python file, set the _order attribute to 'id desc' as shown below:
from odoo import models, fields
class YourModel(models.Model):
_name = 'your.model'
_description = 'Your Model Description'
_order = 'id desc'
Alternative: Use the create_date Field:
_order = 'create_date desc'
Note: The _order attribute sets the default sorting for all views associated with the model. If you need different sorting orders for different views, you can specify the default_order attribute directly in the view's XML definition.
For example:
<tree default_order="create_date desc, id desc">
<!-- Field definitions -->
</tree>
Best Regards,
NIZAMUDHEEN MJ
Accurates
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Реєстрація| Related Posts | Відповіді | Переглядів | Дія | |
|---|---|---|---|---|
|
|
1
лист. 25
|
252 | ||
|
|
1
лип. 25
|
1043 | ||
|
|
3
квіт. 25
|
5935 | ||
|
|
0
черв. 24
|
2200 | ||
|
|
1
січ. 24
|
2986 |