Odoo Configuration File

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.

                            
                            
// generating the conf file
python odoo.py --save --config odoo.cfg --stop-after-init // save the configuration to a file and stop the server
// running the Odoo with that conf file
python odoo.py -c odoo.cfg

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

Following are the server startup options

                            
                            
// start up options
admin_passwd = admin // admin password for PostgreSQL database
csv_internal_sep = , // default CSV separator for import and export
without_demo = False // disable loading demo data for modules to be installed
import_partial = path to file // enabling the partial import in Odoo
pidfile = path to file // storing the process id of Odoo
addons_path = /full/path/to/addons // specify additional addons paths (separated by commas)
server_wide_modules = web,web_kanban // Comma-separated list of server-wide modules

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 --addons-path.

The option 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.

XML-RPC / HTTP

This group will be all about the xmlrpc configuration like binding the server to an ip and specifying a port to run it.

                            
                            
//XML-RPC / HTTP
xmlrpc = True // disable the xmlrpc protocol
xmlrpc_interface = 127.0.0.1 // Specify the TCP IP address for the XML-RPC protocol.
xmlrpc_port = 8069 // disable loading demo data for modules to be installed.
longpolling_port = 8072 // specify the TCP port for longpolling requests.
proxy_mode = False // Enable correct behavior when behind a reverse proxy

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 False.

                            
                            
//xmlrpc protocol check
import xmlrpclib // importing the xmlrpclib module
common = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/2/common') // Connecting to running Odoo using xmlrpc
print common.version() // if connected it will print the version of Odoo

Option 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 8069.

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 gevent and psycogreen python packages installed. The default port for longpolling_port is 8072.

Option 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.

WEB Interface Options

This group has only one option which is given below.

                            
                            
//web option
dbfilter = .* // Filter listed database REGEXP

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.

Testing Options

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.

                            
                            
//testing options
test_enable = False // Enable YML and unit testing in odoo.
test_file = False // Launch a python or YML test file. test_enable must be True.
test_report_directory = False // Path to the file directory.
test_commit = False // Commit database changes performed by YAML or XML tests.

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.

Logging Options

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.

                            
                            
//logging options
logfile = None // Specify the log file to store the log details.
logrotate = False // True/False. If True, create a daily log file and keep 30 files.
log_handler = :INFO // setup a handler at LEVEL for a given PREFIX.
log_level = info // specify the level of the logging.
log_db_level = warning // Logging database level.
log_db = False // Specify the Logging database.
syslog = False // Send the log to the syslog server.

The option 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 TimedRotatingFileHandler.

                            
                            
//default logging levels
levels = [ 'info', 'debug_rpc', 'warn', 'test', 'critical', 'debug_sql', 'error', 'debug', 'debug_rpc_answer', 'notset' ]

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.

                            
                            
//default logging handlers
DEFAULT_LOG_CONFIGURATION = [ 'openerp.workflow.workitem:WARNING', 'openerp.http.rpc.request:INFO', 'openerp.http.rpc.response:INFO', 'openerp.addons.web.http:INFO', 'openerp.sql_db:INFO', ':INFO', ]

For the syslog and 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.

                            
                            
//defining the path to syslog
if tools.config['syslog']: # SysLog Handler if os.name == 'nt': handler = logging.handlers.NTEventLogHandler("%s %s" % (release.description, release.version)) elif platform.system() == 'Darwin': handler = logging.handlers.SysLogHandler('/var/run/log') else: handler = logging.handlers.SysLogHandler('/dev/log')

SMTP Options

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.

                            
                            
//SMTP configuration
smtp_server = localhost // specify the SMTP server for sending email
smtp_port = 25 // specify the SMTP port
smtp_ssl = False // if true, SMTP connections will be encrypted with SSL (STARTTLS)
smtp_user = False // specify the SMTP username for sending email
smtp_password = False // specify the SMTP password for sending email
email_from = False // specify the SMTP email address for sending email

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.

Database related Options

The following are the database related option in the Odoo configuration file.

                            
                            
//Database options
db_name = False // specify the database name
db_user = odoo // specify the database user name
db_password = False // specify the database password
pg_path = None // specify the psql executable path
db_host = False // specify the database host
db_port = False // sspecify the database port
db_maxconn = 64 // specify the the maximum number of physical connections to posgresql
db_template = template1 // specify a custom database template to create a new database

These options are useful when you have multiple versions of PostgreSQL running. So Odoo can use the above details to connect to the database.

Security-related Options

This group have only one option. Which is used to disable the listing of database in Odoo. This is very useful in production state.

                            
                            
//security options
list_db = True // disable the ability to return the list of databases

Advanced Options

This group of option deals with the memory management and other advanced options that we can use with Odoo configuration.

                            
                            
//advanced options
debug_mode = False // enable debug mode
osv_memory_count_limit = False // Force a limit on the maximum number of records kept in the virtual
osv_memory_age_limit = True // Force a limit on the maximum age of records kept in the virtual
max_cron_threads = 2 // Maximum number of threads processing concurrently cron jobs
unaccent = False // Use the unaccent function provided by the database when available.
geoip_database = /usr/share/GeoIP/GeoLiteCity.dat // Absolute path to the GeoIP database file

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 geoip_database.

Multiprocessing Options

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.

                            
                            
//multiprocessing options
workers = 0 // Specify the number of workers, 0 disable prefork mode.
limit_memory_soft = 629145600 // Maximum allowed virtual memory per worker, when reached the worker be reset after the current request
limit_memory_hard = 1677721600 // Maximum allowed virtual memory per worker, when reached, any memory allocation will fail
limit_request = 8192 // Maximum number of request to be processed per worker
limit_time_cpu = 600 // Maximum allowed CPU time per request
limit_time_real = 1200 // Maximum allowed Real time per request

When running in multiprocessing mode log will look similar to below. Workers split between WorkerHTTP and WorkerCron.

                            
                            
2016-03-10 13:55:09,602 15504 INFO ? openerp.service.server: Worker WorkerHTTP (15504) alive 2016-03-10 13:55:09,606 15503 INFO ? openerp.service.server: Worker WorkerHTTP (15503) alive 2016-03-10 13:55:09,625 15507 INFO ? openerp.service.server: Worker WorkerCron (15507) alive 2016-03-10 13:55:09,628 15506 INFO ? openerp.service.server: Worker WorkerCron (15506) alive 2016-03-10 13:55:09,629 15508 INFO ? openerp.service.server: Worker WorkerCron (15508) alive 2016-03-10 13:55:09,629 15509 INFO ? openerp.service.server: Worker WorkerCron (15509) alive

In previous versions Odoo was using Gunicorn. Even though it uses the same principle, it has been modified to make the Odoo deployment easier.

Other Options

There are two more useful options in Odoo which are as follows

                            
                            
//other options
data_dir = path to dir //Directory where to store Odoo data.
translate_modules = ['all']//specify modules to export for transalation.

In the 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.