Storing the instance configuration in a file
The odoo-bin
script has dozens of options, and it is tedious to remember them all, as well as remembering to set them properly when starting the server. Fortunately, it is possible to store them all in a configuration file and to only specify by hand the ones you want to alter, for example, for development.
How to do it...
For this recipe, perform the following steps:
- To generate a configuration file for your Odoo instance, run the following command:
$ ./odoo-bin --save --config myodoo.cfg --stop-after-init
- You can add additional options, and their values will be saved in the generated file. All the unset options will be saved with their default value set. To get a list of possible options, use the following command:
$ ./odoo-bin --help | less
This will provide you with some help about what the various options perform.
- To convert from the command-line form to the configuration form, use the long option name, remove the leading dashes, and convert the dashes in the middle into underscores.
--without-demo
then becomeswithout_demo
. This works for most options, but there are a few exceptions, which are listed in the following section. - Edit the
myodoo.cfg
file (use the table in the following section for some parameters you may want to change). Then, to start the server with the saved options, run the following command:$ ./odoo-bin -c myodoo.cfg
Note
The
--config
option is commonly abbreviated as-c
.
How it works...
At startup, Odoo loads its configuration in three passes. First, a set of default values for all options is initialized from the source code, then the configuration is parsed, and then any value that's defined in the file overrides the defaults. Finally, the command-line options are analyzed, and their values override the configuration that was obtained from the previous pass.
As we mentioned earlier, the names of the configuration variables can be found from the names of the command-line options by removing the leading dashes and converting the middle dashes into underscores. There are a few exceptions to this, notably the following:

Table 1.2
Here is a list of options that are commonly set through the configuration file:

Table 1.3
Here is a list of configuration options related to the database:

Table 1.4
The parsing of the configuration file by Odoo is now using the Python ConfigParser
module. However, the implementation in Odoo 11.0 has changed, and it is no longer possible to use variable interpolation. So, if you are used to defining values for variables from the values of other variables using the %(section.variable)s
notation, you will need to change your habits and revert to explicit values.
Some options are not used in config files, but they are widely used during development:

Table 1.5