İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1926 Görünümler

I have seen both used in the code, and I am wondering what the difference is.


This is what I see in the documentation:


https://www.odoo.com/documentation/17.0/developer/reference/backend/orm.html

Avatar
Vazgeç
En İyi Yanıt

self.filtered(func)

self.filtered_domain(domain)

  • Filters a recordset based on a Python function
  • Requires all records to be retrieved from the database so they can be evaluated by the function
  • Used when filtering can't be done with a domain
  • Slower for large datasets, less scalable
  • Filters a recordset based on an ORM domain
  • Filtering done in PostgreSQL, only returning those records that match the domain
  • Faster for large datasets, more scalable


Use self.filtered_domain wherever possible for performance reasons and use self.filtered for cases where you can't leverage the Odoo domain syntax.

Use self.filtered when:

  • You need to filter based on complex conditions that cannot be represented by a domain.
  • You need to filter using Python logic, like checking computed fields or applying custom methods.

Use self.filtered_domain when:

  • The filtering conditions can be expressed as a domain.
  • You are working with large datasets and want to optimize performance by offloading filtering to the database.


Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Nis 24
4279
1
Ağu 25
1800
2
Ağu 25
411
3
Tem 25
4535
0
May 25
983