Command-line interface (CLI)
The CLI command-line interface offers several functionalities related to Odoo. You can use it to run the server <reference/cmdline/server>, launch Odoo as a Python console environment <reference/cmdline/shell>, scaffold an Odoo module <reference/cmdline/scaffold>, populate a database <reference/cmdline/populate> or count the number of lines of code <reference/cmdline/cloc>.
Version
help - Show available commands
This command shows all the available commands for Odoo.
It has no options.
server - Run the Server
This command is the default one: you can omit it, and it will be chosen anyway.
Teste
Base de dados
Emails
Internationalisation
Advanced Options
Developer features
HTTP
Registros
By default, Odoo displays all logging of level INFO, WARNING and ERROR. All logs independently of the level are output on stderr. Various options are available to redirect logging to other destinations and to customize the verbosity.
Multiprocessing
Configuration file
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 - removed and other - are replaced by _ e.g. --db-template becomes db_template.
Some conversions don't match the pattern:
--db-filter becomes dbfilter
--no-http corresponds to the http_enable boolean
logging presets (all options starting with --log- except for --log-handler and --log-db) just add content to log_handler, use that directly in the configuration file
--smtp is stored as smtp_server
--database is stored as db_name
The default configuration file is {$HOME}/.odoorc which can be overridden using --config <odoo-bin -c>. Specifying --save <odoo-bin -s> will save the current configuration state back to that file. The configuration items relative to the command-line are to be specified in the section [options].
Here is a sample file:
[options]
db_user=odoo
dbfilter=odooshell - Open a Shell
The Odoo command line also allows launching Odoo as a Python console environment, enabling direct interaction with the orm <reference/orm> and its functionalities. Since running a shell involves starting the server, the configuration file options do apply.
$ odoo-bin shellreference/orm/environment
db - Manage a Database
This command lets you manage databases through a command-line interface. The operations are specified using subcommands.
For all subcommands, these options to configure your environment are available:
--addons-path <odoo-bin --addons-path>
--config <odoo-bin -c>
--data-dir <odoo-bin -d>
--db_user <odoo-bin --db_user>
--db_password <odoo-bin --db_password>
--db_host <odoo-bin --db_host>
--db_port <odoo-bin --db_port>
--db_sslmode <odoo-bin --db_sslmode>
--pg_path <odoo-bin --pg_path>
db init - Initialize a Database
This command creates a new database and installs the base module. You can specify the language and country of the main company.
$ odoo-bin db init <database>db dump - Save a Database Dump
Creates a dump file.
$ odoo-bin db dump <database> <dump_path>db load - Load a Database Dump
Loads a dump file into an Odoo database, the dump file can be a URL.
$ odoo-bin db load <database> <dump_file>db duplicate - Duplicate a Database
Duplicate a database including filestore.
$ odoo-bin db duplicate <source> <target>db rename - Rename a Database
Rename a database from an old name to a new one.
$ odoo-bin db rename <source> <target>db drop - Delete a Database
$ odoo-bin db drop <database>i18n - Internationalization
This command has subcommands that enable you to import or export internationalization files and setup languages on the Odoo instance.
For all subcommands, these options to configure your environment are available:
--addons-path <odoo-bin --addons-path>
--config <odoo-bin -c>
--database <odoo-bin --database>
i18n import - Import i18n files
This command imports provided translation files in the .po or .csv formats. By default, only new entries will be added, but you can choose to overwrite existing terms. All the files must refer to the specified language.
$ odoo-bin i18n import <files> --overwrite --language <language_code>i18n export - Export i18n files
This command exports existing translation terms for modules in the Odoo database to a range of formats: .po, .pot, .tgz, .csv. In case of .po and .pot files, they will be created under the i18n/ folder of the module they belong to. If you specify an output parameter, only one language can be selected, and all the output will refer to that language. The .tgz output format makes all output be archived in a single file.
$ odoo-bin i18n export <modules> --languages <language_codes>i18n loadlang - Load language
This command loads one of the available languages into the Odoo database and activates it.
$ odoo-bin i18n loadlang <languages>module - Manage modules
This command has subcommands that enable you to install, uninstall and upgrade modules on the Odoo instance. There's also a command to force install the demo data into the database.
For all subcommands, these options are available:
--addons-path <odoo-bin --addons-path>
--config <odoo-bin -c>
--database <odoo-bin --database>
module install - Install modules
This command installs all selected modules straight away.
Before installing modules, the Odoo database needs to be created and initialized on your PostgreSQL instance, e.g. using the reference/cmdline/db/init command.
$ odoo-bin module install <modules>module uninstall - Uninstall modules
This command uninstalls all selected modules straight away.
$ odoo-bin module uninstall <modules>module upgrade - Upgrade modules
This command upgrades all selected modules straight away.
$ odoo-bin module upgrade <modules>module forcedemo - Force demo data install
This command forces the installation of Demo Data <tutorials/define_module_data/demo_data>
There are no additional options to this command.
neutralize - Neutralize a Database
The Odoo command line allows for neutralizing a database as well. The command must be run with a database option.
$ odoo-bin --addons-path <PATH,...> neutralize -d <database>scaffold - Scaffold a Module
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.
$ odoo-bin scaffold my_module /addons/This will create module my_module in directory /addons/.
populate - Populate a Database
Odoo Populate allows to duplicate existing data in a given database. This can be used for testing and benchmarking when large tables are needed. The duplication process introduces variation for some fields to respect UNIQUE constraints, among other things. It also follows x2Many relationships.
$ odoo-bin populate -d my_database --models res.partner,account.move --factors 1000cloc - Count Lines of Code
Odoo Cloc is a tool to count the number of relevant lines of code written in Python, Javascript, CSS, SCSS, or XML. This can be used as a rough metric for pricing maintenance of extra modules.
$ odoo-bin cloc -c config.conf -d my_database$ odoo-bin cloc --addons-path=addons -d my_databasereference/cmdline/cloc/database-option
$ odoo-bin cloc -p addons/accountMultiple paths can be provided by repeating the option.
$ odoo-bin cloc -p addons/account -p addons/salereference/cmdline/cloc/path-option
Specify a configuration file to use in place of the --addons-path option.
Show the details of lines counted for each file.
Processed files
With the --database option
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. Finally, it counts the lines of code of Javascript, CSS, and SCSS files, and of QWeb views from imported modules.
Some files are excluded from the count by default:
The manifest (__manifest__.py or __openerp__.py)
The contents of the folder static/lib
The tests defined in the folder tests and static/tests
The migrations scripts defined in the folder migrations and upgrades
The XML files declared in the demo or demo_xml sections 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
"**/*.scss", # exclude all scss file from the module
]With the --path option
This method works the same as with the --database option <reference/cmdline/cloc/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 base, web or web_enterprise standard modules are considered standard. Other modules are treated as extra modules.
Error Handling
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.
A JavaScript library that should be placed in the static/lib folder.
Syntax Error
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 cloc_exclude.
obfuscate - Obfuscate database
This command provides a quick and easy way to obfuscate some of the data in the Odoo instance, mainly used for instructional purposes or to make quick videos for the support team helping technicians avoid leaking sensitive information.
Obfuscation is symmetric, so content can be unobfuscated using the same password.
All the configurations available for the server <reference/cmdline/server> command are available here too.
$ odoo-bin obfuscate --pwd=<password>deploy - Deploy module remotely
This command uploads a module to a remote Odoo server and installs it. It's simpler than manually connecting to the remote server, and it does not require full access to the machine that hosts the Odoo instance, only the Odoo administrative credentials.
$ odoo-bin deploy <path> <url> --db <dbname> --login <login> --password <password>
upgrade_code - Rewrite source code
This command rewrites the entire source code using the scripts found in the odoo/upgrade_code folder. It is used for doing the heavy-lifting when dealing with big code migrations and forward ports.
It accepts the --addons-path <odoo-bin --addons-path> option.
$ odoo-bin upgrade_code --from 18.0 --to 19.0 --dry-runCode upgrade scripts
The scripts must be named {version}-{name}.py, and must expose an upgrade function that takes a single file_manager argument and have no return.
The file_manager argument is a sequence of files, which have 3 attributes and some helper methods:
path: the pathlib.Path where the file is on the file system.
addon: the addon the file belongs to.
content: the re-writtable content of the file (lazy).
print_progress(current, total): outputs the current progress.