In this tutorial we will be going through one of the important files in Odoo
odoo.conf(any name). Configuration files are used for specifying the configuration parameters for running the Odoo. There is also another important file in Odoo
__openerp__.py, also called manifest or descriptor files. In case Odoo10 and above this file is renamed as
__manifest__.py but the content will be same.
We will be using the
Odoo9 as an example and will explain all the parameters used in configuration file.
As we know Odoo runs with some default configurations, but can be changed according to our need. As i mentioned in the previous tutorial about Odoo CLI commands, we can run Odoo with simply specifying the config file path thus eliminating the long cli commands. Both contains same parameters but
hyphens are replaced by
underscore. Odoo loads the configuration in 3 steps.First loading the default configuration and second from the configuration file then last from the cli configuration that we supplied each time it will overwrite the previous one. Odoo configuration handeled by the python
ConfigParser module. If you want to know what Odoo is doing with the configuration parameters from both cli and configuration file, i would suggest you to refer this link.
As configuration parameters can be supplied using the cli commands or configuration file. The basic package
optparse has been modified to cope with this issue. The
default parameter in the
optparse is changed to
my_default. You can see this change in the above mentioned link for every
group.add_option functions. For generating a sample configuration file we can use the following cli code. This will have the default values that hardcoded in the code.
This would generate the configuration file in the same directory and it will look like this. For explaining each parameter and what they do, i have grouped into several type as follows. This groups can be found in the optparse definition file that i previously mentioned.
- Server startup Options
- XML-RPC / HTTP
- WEB Interface Options
- Testing Options
- Logging Options
- SMTP Options
- Database related Options
- Security-related Options
- Advanced Options
- Multiprocessing Options
- Other Options
Following are the server startup options
For the parameter
without_demo, is really a database-creation flag. It does work when installing things into a completely empty database (just created with createdb).Other cases aren't supported, in the best cases the option is essentially ignored and in the worst cases it can leave the database in a state requiring manual intervention. You can set
without_demo=WITHOUT_DEMO for disabling all demo data. You can also specify different modules by seperated by commas. This is usually a command line option so that you have to specify the correct database to use.
import_partial this option is used in situations like big data importing, where you have large quantity of data to be imported. When you import data using normal settings, Odoo will check if any errors in the list. And if no errors encountered the whole data is imported at once. But when we enable the
import_partial in conf file which accept a path to a file, Odoo will import data line by line and if any error occurs Odoo will copy that to the file specified. So that you can correct the errors in the unsuccessful list and import it again. No need to import the whole data again as in the first case.
pidfile is used to store the process id of Odoo. So we can start or stop the Odoo server process by using the pid.
addons_path stores absolute path of all addons folders. As default this will have the path to Odoo basic addons, but can provide additional absolute path by seperated by commas. There is also a check whether the supplied addons path is correct or not using
_check_addons_path function. This function can be seen in the
optparse option callback for
server_wide_modules is used to define those modules that need to be loaded at first when Odoo starts, using that option you could be sure that your module is loaded. It doesn't matter if the module is installed or not. Default to "web" to ensure the controllers and webciient resources are properly loaded before anything else.
This group will be all about the xmlrpc configuration like binding the server to an ip and specifying a port to run it.
The first option
xmlrpc enable us to connect to Odoo if it is set as
True. You can check this by simply using the following code and switching xmlrpc to
xmlrpc_interface is used to supply the TCP IP address which can be used to bind the server. By default it is
0.0.0.0 that is it will listen on any interface.
When running multiple instances of Odoo in one machine, we have to specify different
xmlrpc_port for each one. Default xmlrpc port is
longpolling_port is specifically used only when
workers are non zero which is relates to Multiprocessing. For this to work correctly we need to have
psycogreen python packages installed. The default port for
longpolling_port is 8072.
proxy_mode accepts True/False values. For security reasons, it's important for Odoo to make sure the proxy_mode parameter is set to True. The reason for this is that, when Nginx acts as a proxy, all request will appear to come from the server itself instead of the remote IP address. Setting the
X-Forwarded-For header in the proxy and enabling
proxy_mode solves that. But enabling
proxy_mode without forcing this header at the proxy level would allow anyone to spoof their remote address.and also enables when sending any email it will leave the internal port number from the link if
proxy_mode is on.
This group has only one option which is given below.
This option is for filtering out database. Useful for the production and also we can supply any regular expressions, if we want match the db with the sub domain.
The following options are used for testing Odoo module wise. These test are mainly run in demo database so that we can avoid any errors.
The result of the test can be stored in a file specified by the
test_report_directory. If i would start to explain all the testing option it will take time. So I will leave this to another blog.
This group describes all the options that can be used to handle the logging property in Odoo. For more information on how Odoo handles logging you can check this file.
log_level can be used to specify the log level which can take any values from the below list.
logrotate is for creating daily log file and it uses python-logging
log_handler can be a list of ‘module:log_level’ pairs. The default value is ‘:INFO’ – it means the default logging level is ‘INFO’ for all modules. The following are the rest of the logging options.
logfile are exclusive in nature .That is only one works at a time. The
syslog files can be stored in the following paths defined as follows for different operating system. This code can be found in the above mentioned link. And for more information on the python logging you can check this docs.
As know we can set the Odoo SMTP configuration for outgoing email in the gui we can also add that in the odoo configuration by following parameters.
This is similar as the option that we set in Odoo outgoing email server configuration. For example for gmail these settings can be found in the following link.
The following are the database related option in the Odoo configuration file.
These options are useful when you have multiple versions of
PostgreSQL running. So Odoo can use the above details to connect to the database.
This group have only one option. Which is used to disable the listing of database in Odoo. This is very useful in production state.
This group of option deals with the memory management and other advanced options that we can use with Odoo configuration.
Odoo as a server application needs memory to work properly. For that we can use above options for setting memory parameters. For example
osv_memory_count_limit handles the max count of records that is kept in the osv_memory tables and
osv_memory_age_limit marks how much long it has to be stored in the memory. Default for that is 1 hour.
max_cron_threads option is for Maximum number of threads processing concurrently cron jobs (default 2). You may set it to zero for the cron jobs to disturb your other work/processes. Setting bigger values will cause to run the Odoo cron for several times. Usually these option are used in conjunction with multiprocessing options.
unaccent option is for distinguishing between the café (with accent) and cafe (without accent) data. This is part of the database and you can see this link on how to implementing it.
geoip_database points to the path where your geoip database is stored. This database can be used to identify Origin of User in case of Website. This will matches the each users who are logged in as with the
geoip_database and determine the location.this is also useful for website to convert to the user language using the country code from the
Odoo provides its own configuration for multiprocessing. As default Odoo uses only one process. But in production states the number users and quantity of data will be large. So Odoo need to handle significant workload, to enable the multiprocessing we can set
workers option greater than one. Some of the other options are given below. You can visit the Odoo site for more detailed explanation. Multiprocessing option currently not available on Windows.
When running in multiprocessing mode log will look similar to below. Workers split between
In previous versions Odoo was using
Gunicorn. Even though it uses the same principle, it has been modified to make the Odoo deployment easier.
There are two more useful options in Odoo which are as follows
odoo v7 and older, the attachments are stored in the database but we can move that to a directory by setting ir.config_parameter in Odoo to the folder path with key as ir_attachment.location. But in
odoo 8 and onwards there is a configuration parameter called
data_dir which stores data in local storage and adds link to that data from the db. When we have bigger database we start thinking about moving that data out of database.
These are the main configuration options that we can use with Odoo. Try running with this options.