Storing the instance configuration in a file
The odoo-bin
script has dozens of options, and it is tedious to remember them all and to remember 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...
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 this:
$ 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 to underscores: --without-demo
becomes without_demo
. This works for most options, but there are a few exceptions listed in the next 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 start up, 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 any value defined in the file overrides the defaults. Finally, the command-line options are analyzed and their values override the configuration obtained from the previous pass.
As 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 to underscores. There are a few exceptions, notably the following:
Command line | Configuration file |
|
|
|
|
|
|
|
|
| Unavailable |
Here's a list of options commonly set through the configuration file:
Option | Format | Usage |
| Comma separated list of module names, or | Prevents module demo data from being loaded. |
| Comma separated list of paths | A list of directory names in which the server will look for addons (refer to Chapter 2, Managing Odoo Server instances). |
| Text | The master password (take a look at the preceding recipe). |
| Path to a directory | A directory in which the server will store session information, addons downloaded from the internet, and documents if you enable the file store. |
| Host name | The name of the server running the PostgreSQL server. Use |
| Database user login | |
| Database user password | This is generally empty if |
| Database name | Used to set the database name on which some commands operate by default. This does not limit the databases on which the server will act. Refer to the following |
| A regular expression | The expression should match the name of the databases considered by the server. If you run the website, it should match a single database, so it will look like |
| IP address of a network interface | Defaults to |
| Port number | The ports on which the Odoo server will listen. You will need to specify both to run multiple Odoo servers on the same host;
|
| Path to a file | The file in which Odoo will write its logs. |
| Log verbosity level | Specify the level of logging. Accepted values (in increasing verbosity order): |
| Integer | The number of worker processes. Refer to Chapter 3, Server Deployment, for more information. |
| True / False | Set to True to disable listing of databases. See Chapter 3, Server Deployment, for more information. |
Note
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.