.. _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/help: Help & version ============== .. program:: odoo-bin .. option:: -h, --help shows help text with all available options .. option:: --version shows Odoo version e.g. "Odoo Server {BRANCH}" .. tip:: You can enable auto-completion in your shell by running .. code-block:: bash echo "complete -W '`./odoo-bin --help | \ sed -e 's/[^a-z_-]\(-\+[a-z0-9_-]\+\)/\n\1\n/' | \ grep -- '^-' | sort | uniq | tr '\n' ' '`' odoo-bin" >> ~/.bash_completion .. _reference/cmdline/server: Running the server ================== .. program:: odoo-bin .. 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:: --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 specify an additional upgrade path. .. 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:: --without-demo disables demo data loading for modules installed comma-separated, use ``all`` for all modules. Requires :option:`-d` and :option:`-i`. .. 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-db Absolute path to the GeoIP database file. .. _reference/cmdline/testing: Testing Configuration ===================== .. 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-filter hides databases that do not match ````. 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 .. option:: --db-template