Command-line interface (CLI)¶
The CLI command-line interface offers several functionalities related to Odoo. You can use it to run the server, launch Odoo as a Python console environment, scaffold an Odoo module, or count the number of lines of code.
The command to use to call the CLI depends on how you installed Odoo. In the examples below, we
assume that you are running Odoo from source with the
odoo-bin file. If you installed Odoo from a distribution package or with Docker, you must adapt the
Navigate to the root of the directory where you downloaded the source files of Odoo Community.
Run all CLI commands with ./odoo-bin
When Odoo was installed, an executable named
odoo was added to your user’s PATH. Replace
all occurrences of odoo-bin with odoo in the examples below.
Please refer to the documentation of the official Docker image of Odoo.
Running the server¶
- -d <database>, --database <database>¶
database(s) used when installing or updating modules. Providing a comma-separated list restrict access to databases provided in list.
For advanced database options, take a look below.
- -i <modules>, --init <modules>¶
comma-separated list of modules to install before running the server (requires
- -u <modules>, --update <modules>¶
comma-separated list of modules to update before running the server (requires
- --addons-path <directories>¶
comma-separated list of directories in which modules are stored. These directories are scanned for modules.
- -s, --save¶
saves the server configuration to the current configuration file (
$HOME/.odoorcby default, and can be overridden using
disables demo data loading for modules installed comma-separated, use
allfor all modules.
runs tests after installing modules
select the tests to run by using tags.
Specify directory where to write screenshots when an HttpCase.browser_js test fails. It defaults to
Enable screencasts and specify directory where to write screencasts files. The
ffmpegutility needs to be installed to encode frames into a video file. Otherwise frames will be kept instead of the video file.
- -r <user>, --db_user <user>¶
database username, used to connect to PostgreSQL.
- --db_host <hostname>¶
host for the database server
UNIX socket otherwise
- --db_port <port>¶
port the database listens on, defaults to 5432
- --db-filter <filter>¶
hides databases that do not match
<filter>. The filter is a regular expression, with the additions that:
%his replaced by the whole hostname the request is made on.
%dis replaced by the subdomain the request is made on, with the exception of
www.odoo.comboth match the database
These operations are case sensitive. Add option
(?i)to match all databases (so domain
(?i)%dmatches the database
Since version 11, it’s also possible to restrict access to a given database listen by using the –database parameter and specifying a comma-separated list of databases
When combining the two parameters, db-filter supersedes the comma-separated database list for restricting database list, while the comma-separated list is used for performing requested operations like upgrade of modules.
$ odoo-bin --db-filter ^11.*$
Restrict access to databases whose name starts with 11
$ odoo-bin --database 11firstdatabase,11seconddatabase
Restrict access to only two databases, 11firstdatabase and 11seconddatabase
$ odoo-bin --database 11firstdatabase,11seconddatabase -u base
Restrict access to only two databases, 11firstdatabase and 11seconddatabase, and update base module on one database: 11firstdatabase. If database 11seconddatabase doesn’t exist, the database is created and base modules is installed
$ odoo-bin --db-filter ^11.*$ --database 11firstdatabase,11seconddatabase -u base
Restrict access to databases whose name starts with 11, and update base module on one database: 11firstdatabase. If database 11seconddatabase doesn’t exist, the database is created and base modules is installed
- --db-template <template>¶
when creating new databases from the database-management screens, use the specified template database. Defaults to
- --pg_path </path/to/postgresql/binaries>¶
Path to the PostgreSQL binaries that are used by the database manager to dump and restore databases. You have to specify this option only if these binaries are located in a non-standard directory.
Suppresses the ability to list databases available on the system
Control the SSL security of the connection between Odoo and PostgreSQL. Value should be one of ‘disable’, ‘allow’, ‘prefer’, ‘require’, ‘verify-ca’ or ‘verify-full’ Default value is ‘prefer’
- --email-from <address>¶
Email address used as <FROM> when Odoo needs to send mails
- --smtp <server>¶
Address of the SMTP server to connect to in order to send mails
- --smtp-port <port>¶
If set, odoo should use SSL/STARTSSL SMTP connections
- --smtp-user <name>¶
Username to connect to the SMTP server
- --smtp-password <password>¶
Password to connect to the SMTP server
Use these options to translate Odoo to another language. See i18n section of the user manual. Option ‘-d’ is mandatory. Option ‘-l’ is mandatory in case of importation
- --load-language <languages>¶
specifies the languages (separated by commas) for the translations you want to be loaded
- -l, --language <language>¶
specify the language of the translation file. Use it with –i18n-export or –i18n-import
- --i18n-export <filename>¶
export all sentences to be translated to a CSV file, a PO file or a TGZ archive and exit.
- --i18n-import <filename>¶
import a CSV or a PO file with translations and exit. The ‘-l’ option is required.
overwrites existing translation terms on updating a module or importing a CSV or a PO file.
specify modules to export. Use in combination with –i18n-export
- --dev <feature,feature,...,feature>¶
all: all the features below are activated
xml: read template qweb from xml file directly instead of database. Once a template has been modified in database, it will be not be read from the xml file until the next update/init.
reload: restart server when python file are updated (may not be detected depending on the text editor used)
qweb: break in the evaluation of qweb template when a node contains
(i)p(u)db: start the chosen python debugger in the code when an unexpected error is raised before logging and returning the error.
do not start the HTTP or long-polling workers (may still start cron workers)
has no effect if
--test-enableis set, as tests require an accessible HTTP server
- --http-interface <interface>¶
TCP/IP address on which the HTTP server listens, defaults to
- --http-port <port>¶
Port on which the HTTP server listens, defaults to 8069.
- --longpolling-port <port>¶
TCP port for long-polling connections in multiprocessing or gevent mode, defaults to 8072. Not used in default (threaded) mode.
By default, Odoo displays all logging of level
info except for workflow
warning only), and log output is sent to
options are available to redirect logging to other destinations and to
customize the amount of logging output.
- --logfile <file>¶
sends logging output to the specified file instead of stdout. On Unix, the file can be managed by external log rotation programs and will automatically be reopened when replaced
Neither is configurable
- --log-db <dbname>¶
logs to the
ir_loggingtable) of the specified database. The database can be the name of a database in the “current” PostgreSQL, or a PostgreSQL URI for e.g. log aggregation.
- --log-handler <handler-spec>¶
LOGGERat the provided
odoo.models:DEBUGwill enable all logging messages at or above
DEBUGlevel in the models.
The logger can be omitted to configure the root (default) handler
If the level is omitted, the logger is set to
The option can be repeated to configure multiple loggers e.g.
$ odoo-bin --log-handler :DEBUG --log-handler werkzeug:CRITICAL --log-handler odoo.fields:WARNING
enable DEBUG logging for RPC requests, equivalent to
enable DEBUG logging for RPC responses, equivalent to
enables DEBUG logging of HTTP requests and responses, equivalent to
enables DEBUG logging of SQL querying, equivalent to
- --log-level <level>¶
Shortcut to more easily set predefined levels on specific loggers. “real” levels (
debug) are set on the
werkzeugloggers (except for
debugwhich is only set on
Odoo also provides debugging pseudo-levels which apply to different sets of loggers:
sets the SQL logger to
odooand HTTP request loggers to
--log-level debug --log-request
odooand HTTP request and response loggers to
--log-level debug --log-request --log-response
- --workers <count>¶
countis not 0 (the default), enables multiprocessing and sets up the specified number of HTTP workers (sub-processes processing HTTP and RPC requests).
multiprocessing mode is only available on Unix-based systems
A number of options allow limiting and recycling workers:
- --limit-request <limit>¶
Number of requests a worker will process before being recycled and restarted.
Defaults to 8196.
- --limit-memory-soft <limit>¶
Maximum allowed virtual memory per worker. If the limit is exceeded, the worker is killed and recycled at the end of the current request.
Defaults to 2048MiB.
- --limit-memory-hard <limit>¶
Hard limit on virtual memory, any worker exceeding the limit will be immediately killed without waiting for the end of the current request processing.
Defaults to 2560MiB.
- --limit-time-cpu <limit>¶
Prevents the worker from using more than <limit> CPU seconds for each request. If the limit is exceeded, the worker is killed.
Defaults to 60.
Most of the command-line options can also be specified via a configuration
file. Most of the time, they use similar names with the prefix
- are replaced by
Some conversions don’t match the pattern:
--no-httpcorresponds to the
--smtpis stored as
--databaseis stored as
Odoo command-line also allows to launch odoo as a python console environment. This enables direct interaction with the orm and its functionalities.
$ odoo_bin shell
- --shell-interface (ipython|ptpython|bpython|python)¶
Specify a preferred REPL to use in shell mode.
Scaffolding is the automated creation of a skeleton structure to simplify bootstrapping (of new modules, in the case of Odoo). While not necessary it avoids the tedium of setting up basic structures and looking up what all starting requirements are.
Scaffolding is available via the odoo-bin scaffold subcommand.
- name (required)¶
the name of the module to create, may munged in various manners to generate programmatic names (e.g. module directory name, model names, …)
- destination (default=current directory)¶
directory in which to create the new module, defaults to the current directory
- -t <template>¶
a template directory, files are passed through jinja2 then copied to the
$ odoo_bin scaffold my_module /addons/
This will create module my_module in directory /addons/.
- -d <database>, --database <database>¶
--addons-pathoption is required to specify the path(s) to the module folder(s).
--path, the count will be that of the sum of both options’ results (with possible overlaps). At least one of these two options is required to specify which code to process.
$ odoo-bin cloc --addons-path=addons -d my_database
- -p <path>, --path <path>¶
--database, the count will be that of the sum of both options’ results (with possible overlaps). At least one of these two options is required to specify which code to process.
$ odoo-bin cloc -p addons/account
Multiple paths can be provided by repeating the option.
$ odoo-bin cloc -p addons/account -p addons/sale
- --addons-path <directories>¶
--databaseoption is used.
- -c <directories>¶
Specify a configuration file to use in place of the
$ odoo-bin cloc -c config.conf -d my_database
- -v, --verbose¶
Show the details of lines counted for each file.
Odoo Cloc counts the lines in each file of extra installed modules in a given database. In addition, it counts the Python lines of server actions and custom computed fields that have been directly created in the database or imported.
Some files are excluded from the count by default:
The manifest (
The contents of the folder
The tests defined in the folder
The migrations scripts defined in the folder
The XML files declared in the
demo_xmlsections of the manifest
For special cases, a list of files that should be ignored by Odoo Cloc can be defined
per module. This is specified by the
cloc_exclude entry of the manifest:
"cloc_exclude": [ "lib/common.py", # exclude a single file "data/*.xml", # exclude all XML files in a specific folder "example/**/*", # exclude all files in a folder hierarchy recursively ]
**/*can be used to ignore an entire module. This can be useful to exclude a module from maintenance service costs.
This method works the same as with the –database option if a manifest file is present in the given folder. Otherwise, it counts all files.
Identifying Extra Modules¶
To distinguish between standard and extra modules, Odoo Cloc uses the following heuristic:
modules that are located (real file system path, after following symbolic links)
in the same parent directory as the
standard modules are considered standard. Other modules are treated as extra modules.
Some file cannot be counted by Odoo Cloc. Those file are reported at the end of the output.
Max file size exceeded¶
Odoo Cloc rejects any file larger than 25MB. Usually, source files are smaller than 1 MB. If a file is rejected, it may be:
A generated XML file that contains lots of data. It should be excluded in the manifest.
Odoo Cloc cannot count the lines of code of a Python file with a syntax problem.
If an extra module contains such files, they should be fixed to allow the module to
load. If the module works despite the presence of those files, they are probably
not loaded and should therefore be removed from the module, or at least excluded
in the manifest via