Skip to content

inheritable-method-lambda (ODOO033)

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 default=/domain= field arguments that pass a direct method reference instead of a lambda.

Why is this bad?

A direct reference binds the field to that exact function object, so a subclass overriding the method is silently ignored. A lambda dispatches through self and preserves inheritability.

Example

company_id = fields.Many2one("res.company", default=_default_company)

Use instead:

company_id = fields.Many2one(
    "res.company", default=lambda self: self._default_company()
)