Skip to content

inheritable-method-string (ODOO032)

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 compute=/search=/inverse= field arguments that pass a direct method reference instead of the method's name as a string.

Why is this bad?

A direct reference binds the field to that exact function object, so a subclass overriding the method is silently ignored. Passing the name as a string preserves inheritability.

Example

total = fields.Float(compute=_compute_total)

Use instead:

total = fields.Float(compute="_compute_total")