[IMP] core: introduce search_fetch() and fetch()

closes odoo/documentation#3749

Related: odoo/odoo#114551
Signed-off-by: Raphael Collet <rco@odoo.com>
This commit is contained in:
Raphael Collet 2023-03-07 10:52:41 +00:00
parent 8a07f95e43
commit 097c247449
2 changed files with 19 additions and 0 deletions

View File

@ -615,6 +615,12 @@ for partners and one for countries::
country = partner.country_id # first pass prefetches all partners country = partner.country_id # first pass prefetches all partners
countries.add(country.name) # first pass prefetches all countries countries.add(country.name) # first pass prefetches all countries
.. seealso::
The methods :meth:`~odoo.models.Model.search_fetch` and
:meth:`~odoo.models.Model.fetch` can be used to populate the cache of
records, typically in cases where the prefetching mechanism does not work
well.
.. _reference/api/decorators: .. _reference/api/decorators:
@ -845,8 +851,12 @@ Search/Read
.. automethod:: Model.search_count .. automethod:: Model.search_count
.. automethod:: Model.search_fetch
.. automethod:: Model.name_search .. automethod:: Model.name_search
.. automethod:: Model.fetch
.. automethod:: Model.read .. automethod:: Model.read
.. automethod:: Model.read_group .. automethod:: Model.read_group

View File

@ -4,6 +4,15 @@
Changelog Changelog
========= =========
Odoo Online version 16.2
========================
- Refactor the implementation of searching and reading methods to be able to
combine both in a minimal number of SQL queries. We introduce two new methods
`odoo.models.Model.search_fetch` and `odoo.models.Model.fetch` that take
advantage of the combination. More details can be found on the pull request
`#112126 <https://github.com/odoo/odoo/pull/112126>`_.
Odoo version 16.0 Odoo version 16.0
================= =================