.. _reference/cmdline: ============================ Command-line interface (CLI) ============================ The CLI :dfn:`command-line interface` offers several functionalities related to Odoo. You can use it to :ref:`run the server `, :ref:`launch Odoo as a Python console environment `, :ref:`scaffold an Odoo module `, :ref:`populate a database ` or :ref:`count the number of lines of code `. .. important:: The command to use to call the CLI depends on how you installed Odoo. In the examples below, we assume that you are :doc:`running Odoo from source ` with the :file:`odoo-bin` file. If you installed Odoo :doc:`from a distribution package ` or with `Docker `_, you must adapt the command. .. tabs:: .. tab:: Run Odoo from source #. Navigate to the root of the directory where you downloaded the source files of Odoo Community. #. Run all CLI commands with :command:`./odoo-bin` .. tab:: Odoo was installed from a distribution package When Odoo was installed, an executable named `odoo` was added to your user's PATH. Replace all occurrences of :command:`odoo-bin` with :command:`odoo` in the examples below. .. tab:: Odoo was installed with Docker Please refer to the `documentation of the official Docker image of Odoo `_. .. _reference/cmdline/extra: Version ======= .. program:: odoo-bin .. option:: -h, --help it can be used in combination with any command available, and it displays the options of the current command. If no command is used, it will act as per the `help` command :ref:`below `. .. option:: --version shows Odoo version e.g. "Odoo Server {BRANCH}" .. tip:: You can enable auto-completion in your shell by running .. code-block:: bash COMMANDS=$(odoo-bin --help | sed -e "s/^ \([^ ]\+\).*$/ \1/gp;d" | xargs) echo "complete -W '$COMMANDS' odoo-bin" >> ~/.bash_completion .. _reference/cmdline/help: `help` - Show available commands ================================ .. program:: odoo-bin help This command shows all the available commands for Odoo. It has no options. .. _reference/cmdline/server: `server` - Run the Server ========================= .. program:: odoo-bin This command is the default one: you can omit it, and it will be chosen anyway. .. option:: -d , --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 :ref:`below `. .. option:: -i , --init comma-separated list of modules to install before running the server (requires :option:`-d`). .. option:: -u , --update comma-separated list of modules to update before running the server. Use ``all`` for all modules. (requires :option:`-d`). .. option:: --reinit A comma-separated list of modules to reinitialize before starting the server. (requires :option:`-d`). The reinitialization is similar to a simple upgrade without executing any upgrade script. It loads data in ``init`` mode instead of ``update`` mode, primarily affecting records marked as ``'noupdate'``. All modules that depend directly or indirectly on the specified ones will also be reinitialized. This option is intended for debugging or development purposes only. **Do not use it with a production database.** .. option:: --addons-path comma-separated list of directories in which modules are stored. These directories are scanned for modules. .. (nb: when and why?) .. option:: --upgrade-path comma-separated list of directories from which additional upgrade scripts are loaded. .. option:: --pre-upgrade-scripts comma-separated list of paths to upgrade scripts. The scripts are run before loading base module when an upgrade of any module is requested. This is useful to perform some actions during custom modules upgrade after a major upgrade. .. option:: --load list of server-wide modules to load. Those modules are supposed to provide features not necessarily tied to a particular database. This is in contrast to modules that are always bound to a specific database when they are installed (i.e. the majority of Odoo addons). Default is ``base,web``. .. option:: -c , --config path to an alternate :ref:`configuration file `. If not defined, Odoo checks ``ODOO_RC`` environmental variable and default location :file:`{$HOME}/.odoorc`. See configuration file section :ref:`below `. .. option:: -D , --data-dir directory path where to store Odoo data (eg. filestore, sessions). If not specified, Odoo will fallback to a predefined path. On Unix systems its one defined in ``$XDG_DATA_HOME`` environmental variable or :file:`~/.local/share/Odoo` or :file:`/var/lib/Odoo`. .. option:: -s, --save saves the server configuration to the current configuration file (:file:`{$HOME}/.odoorc` by default, and can be overridden using :option:`-c`). .. option:: --with-demo install demo data in new databases. .. option:: --without-demo don't install demo data nor in new databases nor when installing new modules in a database that uses demo data, this is the default. .. option:: --pidfile= path to a file where the server pid will be stored .. option:: --stop-after-init stops the server after its initialization. .. option:: --geoip-city-db Absolute path to the GeoIP City database file. .. option:: --geoip-country-db Absolute path to the GeoIP Country database file. .. _reference/cmdline/testing: Testing ------- .. option:: --test-enable runs tests after module installation .. option:: --test-file runs a python test file .. option:: --test-tags [-][tag][/module][:class][.method] Comma-separated list of specs to filter which tests to execute. Enable unit tests if set. Example: `--test-tags :TestClass.test_func,/test_module,external` * The `-` specifies if we want to include or exclude tests matching this spec. * The tag will match tags added on a class with a :func:`~odoo.tests.common.tagged` decorator (all :ref:`test classes ` have `standard` and `at_install` tags until explicitly removed, see the decorator documentation). * `*` will match all tags. * If tag is omitted on include mode, its value is `standard`. * If tag is omitted on exclude mode, its value is `*`. * The module, class, and method will respectively match the module name, test class name and test method name. Filtering and executing the tests happens twice: right after each module installation/update and at the end of the modules loading. At each stage tests are filtered by `--test-tags` specs and additionally by dynamic specs `at_install` and `post_install` correspondingly. .. option:: --screenshots Specify directory where to write screenshots when an HttpCase.browser_js test fails. It defaults to :file:`/tmp/odoo_tests/{db_name}/screenshots` .. option:: --screencasts Enable screencasts and specify directory where to write screencasts files. The ``ffmpeg`` utility needs to be installed to encode frames into a video file. Otherwise frames will be kept instead of the video file. .. _reference/cmdline/server/database: Database -------- .. option:: -r , --db_user database username, used to connect to PostgreSQL. .. option:: -w , --db_password database password, if using `password authentication`_. .. option:: --db_host host for the database server * ``localhost`` on Windows * UNIX socket otherwise .. option:: --db_port port the database listens on, defaults to 5432 .. option:: --db_replica_host host for the replica database server, disabled when not set / empty .. option:: --db_replica_port the port the replica database listens on, defaults to :option:`--db_port` .. option:: --db-filter hides databases that do not match ```` for the Web UI. The filter is a `regular expression`_, with the additions that: - ``%h`` is replaced by the whole hostname the request is made on. - ``%d`` is replaced by the subdomain the request is made on, with the exception of ``www`` (so domain ``odoo.com`` and ``www.odoo.com`` both match the database ``odoo``). These operations are case sensitive. Add option ``(?i)`` to match all databases (so domain ``odoo.com`` using ``(?i)%d`` matches the database ``Odoo``). 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. .. code-block:: bash $ odoo-bin --db-filter ^11.*$ Restrict access to databases whose name starts with 11 .. code-block:: bash $ odoo-bin --database 11firstdatabase,11seconddatabase Restrict access to only two databases, 11firstdatabase and 11seconddatabase .. code-block:: bash $ 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 .. code-block:: bash $ 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 .. warning:: This option does not affect cron workers, if no --database is given, cron workers will run on every available database .. option:: --db-template