Configuration#
odl reads its settings from the nearest configuration file, searching from
the first linted path upwards:
odoo-lint.toml, with the settings at the top level;pyproject.toml, with the settings under[tool.odoo-lint].
In each directory odoo-lint.toml wins over pyproject.toml. A
pyproject.toml without a [tool.odoo-lint] table is skipped. Use
odl check --config FILE to skip the search.
Unknown keys are an error, so a typo such as manifest_author instead of
manifest-required-author is reported instead of silently ignored.
Reference#
[tool.odoo-lint]
# Odoo version to lint for; `odl check --version` overrides it.
target-version = "17.0"
# Rules to run and to skip, by code, name or code prefix.
select = ["ALL"]
ignore = ["ODOO001"]
# Extra paths to skip, relative to this file.
exclude = ["setup", "addons/legacy_*"]
# Where the dependencies of your modules are, Odoo's included.
addons-path = ["../odoo/odoo/addons", "../odoo/addons", "../oca/*"]
[tool.odoo-lint.per-file-ignores]
"*/tests/*" = ["missing-depends"]
[tool.odoo-lint.rules.manifest-required-author]
authors = ["Odoo Community Association (OCA)"]
[tool.odoo-lint.rules.manifest-required-author.mapping]
"acme_*" = "Acme Corp"
The same file as odoo-lint.toml:
target-version = "17.0"
select = ["ALL"]
[per-file-ignores]
"*/tests/*" = ["missing-depends"]
[rules.manifest-required-author]
authors = ["Odoo Community Association (OCA)"]
[rules.manifest-required-author.mapping]
"acme_*" = "Acme Corp"
target-version#
Odoo version the code targets, as a string such as "16.0". Rules that only
apply to some Odoo versions are skipped for other versions. Default: "17.0".
select and ignore#
Which rules run. Each entry is one of:
ALL, every rule except the opt-in ones (MOD008, which removes copyright headers);a code such as
C8101, or a name such asmanifest-required-author;a code prefix such as
C81,EorODOO.
A rule runs when it matches an entry in select and none in ignore.
--select on the command line replaces select; --ignore adds to ignore.
Default: select = ["ALL"], no ignore.
Codes and names of rules ported from pylint-odoo are pylint-odoo’s, so a list
copied from a .pylintrc works. Entries for pylint-odoo checks that odoo-lint
does not implement yet produce a warning, not an error.
exclude#
Glob patterns of files and directories to skip, relative to the directory of
the configuration file. A pattern without / also matches a bare file or
directory name anywhere. Directories such as .git, .venv, node_modules
and __pycache__ are always skipped.
addons-path#
Folders with addons, as in Odoo’s addons_path, relative to this file; a
glob such as ../oca/* adds every folder it matches. odl check --addons-path replaces it, relative to the working directory.
Checks across modules use it to look up what a module’s depends reach:
ODOO004 for fields in views,
ODOO005 for XML ids, ODOO006
for models and ODOO007 for fields named in Python. The modules next to
the checked module are found without it. A module whose dependencies cannot
all be found is not checked by these rules, so without addons-path they
stay silent rather than guess.
Only the dependencies of the checked modules are read: with all of Odoo 18.0 in the path, checking every core module takes about two seconds.
per-file-ignores#
A table of glob pattern to rules that are ignored in matching files, with the same pattern and rule syntax as above.
manifest-defaults#
Values that odl check --fix fills in when a manifest lacks a required key
(C8102, C8119) or its author (C8101), per module pattern:
[tool.odoo-lint.manifest-defaults]
"*" = { license = "AGPL-3" }
"acme_*" = { license = "LGPL-3", author = "Acme Corp", website = "https://acme.example" }
An exact module name wins over the longest matching prefix* pattern, which
wins over *, key by key. Values are strings, numbers, booleans or lists of
them. Without a configured value there is no fix: odoo-lint does not guess a
license or an author.
Other rule options#
Rules ported from pylint-odoo take the same options, under
[tool.odoo-lint.rules.<rule name>], with the same defaults. For example:
[tool.odoo-lint.rules.license-allowed]
allowed = ["AGPL-3", "LGPL-3"]
[tool.odoo-lint.rules.manifest-version-format]
valid-odoo-versions = ["17.0"]
Each rule’s page under rules lists its options: C8102, C8103, C8105, C8106, C8111, C8112, C8114, C8115, C8116, C8117, C8118 and C8119.
Suppressing a violation in the code#
Both Ruff and pylint comments work, so existing pylint-odoo suppressions keep working:
Comment |
Scope |
|---|---|
|
every rule, on this line |
|
these rules, on this line |
|
this line |
|
until the end of the enclosing block |
|
until the end of the file |
|
the next line |
|
ends an earlier |
all instead of a rule list disables every rule.