no-search-all (ODW8163)
Preview (since 0.16.2.2) · Related issues · View source
Derived from the odoo linter.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for search([])/search_read([]) calls with an empty domain and no limit on a
model known to hold a large number of records.
Why is this bad?
An empty domain without a limit loads all records of the model. On the tables that grow without bound in a running Odoo database — journal entries, stock moves, messages, attachments — that is a serious performance problem.
The model the call runs against is resolved from self.env["..."] (directly or through a
local variable) and from the _name/_inherit of the enclosing model class. A class with
no _name extends every model its _inherit names, and one listed model is enough to
report. A call whose model cannot be resolved — self.env[model_name], the comodel of a
relational field — is not reported.
Example
Use instead:
Options
The default is the models that grow without bound in a running Odoo database. Entries are
matched as globs, so account.move* covers account.move and account.move.line.