تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
1924 أدوات العرض

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

الصورة الرمزية
إهمال
أفضل إجابة

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.


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
أبريل 24
4277
1
أغسطس 25
1799
2
أغسطس 25
411
naked domain set up تم الحل
3
يوليو 25
4535
0
مايو 25
983