Skip to content

OD314 unknown-function-method

A <function> of a data file calls a method its model does not have.

Category Severity Series Needs the index
Correctness Error all yes

What it reports

A <function model="m" name="x"/> in a data file the manifest loads, where neither the classes of m, those of the models it inherits, nor BaseModel define x, or where only a module missing from depends adds it. A module that Odoo always installs with base, such as web, counts as in depends. A method of a model reached through _inherits or delegate=True does not count, and a BaseModel method counts in every series, whichever series has it, but one BaseModel lost before saas~11.5, such as create_workflow, counts only in the series that have it, and in none for a module of unknown series. OD312 says what defines a method.

A private method is fine here: the loader calls the method directly, so _ names are allowed.

Why it matters

Odoo calls the method when it loads the file, so a misspelled name stops the install or the upgrade of the module with an AttributeError. A demo file differs: see load failures.

The rule stays silent when it cannot see every class: a module whose dependencies include one that is not indexed, such as an Enterprise module, a module that builds model names at runtime, a model that is unknown or outside depends, and a class of the model, or of a model it inherits, with a plain Python base or an _inherit no indexed module defines, or in a file that does not parse, which counts as one the scan cannot read. Such a class of a model reached through _inherits or delegate=True does not count, since those methods stay on that model. A <function> on an unknown model is not reported at all.

Example

data/stock_data.xml
<odoo>
    <function model="stock.warehouse" name="_update_routes"/>
</odoo>

stock.warehouse has no _update_routes, so the module fails to install.

data/stock_data.xml
<odoo>
    <function model="stock.warehouse" name="_update_location_reception" eval="[[], 'two_steps']"/>
</odoo>

The first item of eval is the ids of the records, and the rest are the method's arguments.

Suppressing

<!-- odooscan: ignore[OD314] -->

See suppressing a finding.