Odoo in one of the most commonly used business applications at the moment. It can be configured to use sub-domain filtering so the users can run different Odoo databases on different sub-domains. This means you can have different Odoo website/application for different branch of your company. The Odoo sub-domain filtering is simple to configure, so if you have a Linux VPS with Odoo installed on it, you can follow this guide.
The first step is to install mod_wsgi on your server. If you have a CentOS VPS, you can run the command:
yum install mod_wsgi
Vagy, if you have an Ubuntu VPS, you can run these commands to install and enable the same Apache module:
apt-get install libapache2-mod-wsgi a2enmod wsgi
Next step is to add the ‘dbfilter = ^%d$’ to your Odoo configuration file. Open your Odoo configuration file using your favorite text editor and add the following line:
dbfilter = ^%d$
We assume that your Odoo configuration file is saved in your /etc directory, so to edit the file using the ‘nano’ text editor you need to run:
Következő, open the ‘/opt/odoo/openerp/tools/config.py’ file
"--db-filter", dest="dbfilter", my_default='.*'
"--db-filter", dest="dbfilter", my_default='%d'
We assume that your Odoo is installed in your /opt directory. If Odoo is installed in another directory, you should find and edit the corresponding file.
One of the last things you need to do is to create an Apache virtual host. The Apache virtual host should contain the following lines:
<VirtualHost *: 80> ServerName example.com ServerAlias *.example.com WSGIScriptAlias / /opt/odoo/openerp-wsgi.py WSGIDaemonProcess oe user=odoo group=odoo processes=2 python-path=/opt/odoo/ display-name=apache-odoo WSGIProcessGroup oe ErrorLog /var/log/odoo/odoo-error.log CustomLog /var/log/odoo/odoo-access.log combined <Directory /opt/odoo> #Order allow,deny #Allow from all Options All AllowOverride All Require all granted </Könyvtár> </VirtualHost>
Újra, you can edit the virtual host to match your needs. természetesen, you need to use a valid domain name which should be pointed to your server IP address.
In order to get the Odoo sub-domain filter to work, you need to create sub-domains and point them to your Linux VPS IP-cím. To complete this task, you need to edit the zone file of your domain name.
Végül, de nem utolsósorban, you need to create separate databases for your sub-domains. Open your favorite web browser and navigate to:
Change example.com with your domain name. itt, you need to create new databases to match your sub-domains. Például, if you like to have a separate database for your sales department and your sales.example.com sub-domain, you need to create a ‘sales’ database. After you complete this step, you need to restart your Apache web server and your Odoo. You should be able to access your new Odoo database and test the sub-domain filtering at: