Skip to content

method-compute (ODOO027)

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 that the method name passed to a field's compute= argument starts with _compute_.

Why is this bad?

The _compute_<field> prefix is the Odoo naming convention for compute methods, making their role obvious at the definition and call sites.

Example

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

Use instead:

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