PerformanceHighlight of Weekly #004

Batch computes survive forbidden records in prefetch

When the prefetch set held records the user can't read, non-stored computes fell back to one query per record. They now stay batched, which matters for portal and public pages.

Versions20.0
AppFramework & technical

Pull requests and commits

BranchPull requestCommit
20.0odoo/odoo#293541 ↗2401b31a7c ↗

Commit message

[FIX] orm: keep batch computation when prefetch has forbidden records

A non-stored computed field read on the visible records of a one2many is
computed in batch on the whole prefetch set, which can include records
the user cannot read. When the compute reads an uncached stored field on
one of them, fetch() raises an AccessError.

The AccessError is caught and goes to the single-record fallback in
Field.__get__, so the compute runs once per record. When the compute
makes queries (for instance _compute_is_reminder_on on event tracks for
public users), this costs one query per record instead of one per batch.

Fix this issue by introducing an intermediate step, where we restrict
the batch to existing and accessible records. When that one fails, we
eventually fall back on the single record case.

Related: odoo/enterprise#134688

My stack

Pick the versions and apps you run. Weekly digests, this week's table and All changes then show only what concerns you. Saved in this browser.

Versions
Apps
Modules