Odoo Installation

From Indie IT Wiki

OpenERP is an open source enterprise resource planning (ERP) software manufactured by OpenERP s.a..

The following installation guide has been taken from here: The Open Sourcer, and covers the installation of OpenERP version 7.

After completing a basic Ubuntu 13.04 server installation:

Ensure the following are installed:

Linux Terminal:~$

sudo apt-get install openssh-server denyhosts

Create the OpenERP user:

The following creates the user 'openerp' that will own and run the OpenERP application:

Linux Terminal:~$

sudo adduser --system --home=/opt/openerp --group openerp

Install and configure the database server, PostgreSQL

Linux Terminal:~$

 sudo apt-get install postgresql

Installing PostgreSQL unlike OpenERP creates a user 'postgres'. However the postgres user requires configuration and the addition of a password (in this example the password is 'openerp' shown at the end of the second line):

Linux Terminal:~$

sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp
exit

Install the Python libraries required:

Linux Terminal:~$

sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata \
python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid \
python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing \
python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject \
python-webdav python-werkzeug python-xlwt python-yaml python-zsi

There are some additional packages for installation that have been suggested here:

Linux Terminal:~$

sudo apt-get install graphviz ghostscript postgresql-client python-matplotlib python-imaging \
gcc python-dev mc bzr python-setuptools python-babel \
python-feedparser python-reportlab-accel python-zsi python-openssl \
python-egenix-mxdatetime python-jinja2 python-unittest2 python-mock \
python-docutils lptools make python-psutil python-paramiko poppler-utils \
python-pdftools antiword postgresql

Install the OpenERP server

Linux Terminal:~$

wget http://nightly.openerp.com/7.0/nightly/src/openerp-7.0-latest.tar.gz
cd /opt/openerp
sudo tar xvf ~/openerp-7.0-latest.tar.gz

Change the ownership of all the the files to the OpenERP user and group we created earlier.

Linux Terminal:~$

sudo chown -R openerp: *

Copy the server directory to something with a simpler name so that the configuration files and boot scripts don’t need constant editing, for instance 'server' (without the speech marks). When it comes to upgrading, it is easier to just keep a copy of the files in place and then overwrite them with the new code. This way you keep any custom or user-installed modules and reports etc. all in the right place.

Linux Terminal:~$

sudo cp -a openerp-7.0-name-of-nightly-source server

Configuring the OpenERP application

The default configuration file for the server (located in /opt/openerp/server/install/) is very minimal and with only minor changes will work fine. It needs to be copied to the /etc/ folder and when this has been done make the alterations then change it’s ownership and permissions:

Linux Terminal:~$

sudo cp /opt/openerp/server/install/openerp-server.conf /etc/
sudo chown openerp: /etc/openerp-server.conf
sudo chmod 640 /etc/openerp-server.conf

The 'chown' and 'chmod' commands make the file owned and writeable only by the openerp user and group and only readable by openerp and root.

Next edit the file:

Linux Terminal:~$

sudo nano /etc/openerp-server.conf

Find and alter the following line:

db_password = False

Change 'False' to the password selected earlier:

db_password = openerp

At the end of the same file add the following line:

logfile = /var/log/openerp/openerp-server.log

Save and close the file.

Check the openerp server will run:

Linux Terminal:~$

sudo su - openerp -s /bin/bash

/opt/openerp/server/openerp-server

If all works you should see something similar to the following:

2013-06-06 09:05:33,631 12446 INFO ? openerp: OpenERP version 7.0-20130604-231058
2013-06-06 09:05:33,632 12446 INFO ? openerp: addons paths: /opt/openerp/server/openerp/addons
2013-06-06 09:05:33,633 12446 INFO ? openerp: database hostname: localhost
2013-06-06 09:05:33,633 12446 INFO ? openerp: database port: 5432
2013-06-06 09:05:33,634 12446 INFO ? openerp: database user: openerp
2013-06-06 09:05:34,494 12446 INFO ? openerp.addons.google_docs.google_docs: GData lib version `%s GData-Python/2.0.17` detected
2013-06-06 09:05:35,235 12446 INFO ? openerp.service.wsgi_server: HTTP service (werkzeug) running on 0.0.0.0:8069
2013-06-06 09:05:35,236 12446 INFO ? openerp: OpenERP server is running, waiting for connections...

Enter CTL+C to stop the server and then type 'exit' to leave the openerp user account and go back to your own shell.

Installing the boot script

The last step in installation is adding the automatic start-up and shut down of the OpenERP server as well as also running the application as the correct user. As this requires the alteration of the default script first make a backup:

Linux Terminal:~$

sudo cp /opt/openerp/server/install/openerp-server.init openerp-server.init.old

Then clear the original file's contents and open for editing:

Linux Terminal:~$

sudo echo " " > /opt/openerp/server/install/openerp-server.init
sudo nano /opt/openerp/server/install/openerp-server.init

Open the following page Openerp_boot_script and copy the text in to openerp-server.init file, then save and close.

The openerp-server.init file needs to be copied to /etc/init.d/ then renamed:

Linux Terminal:~$

sudo cp /opt/openerp/server/install/openerp-server.init /etc/init.d/
sudo mv /etc/init.d/openerp-server.init openerp-server

Once copied & renamed change the permissions:

Linux Terminal:~$

sudo chmod 755 /etc/init.d/openerp-server
sudo chown root: /etc/init.d/openerp-server

The configuration file includes an entry for where the server’s log file will be written. As as yet the location does not exist the directory needs to be created and also must be made writeable by the openerp user:

Linux Terminal:~$

sudo mkdir /var/log/openerp
sudo chown openerp:root /var/log/openerp

Testing The Server

Start the server and the view the log file:

Linux Terminal:~$

sudo /etc/init.d/openerp-server start
less /var/log/openerp/openerp-server.log

If there appears to be no issues in the log file point your web browser at the domain or IP address of your OpenERP server (or localhost if you are on the same machine) and use port 8069. The URL will look something like this:

http://domain.com:8069
http://localhost:8069
http://192.168.0.2:8069

The default password is 'admin', which should be changed to something more complex. This password is stored in plain text in the /etc/openerp-server.conf file; hence why access is restricted to just openerp and root. When the password is changed and saved it will be written along with a lot more options to /etc/openerp-server.conf.

Check the server can be stopped:

Linux Terminal:~$

sudo /etc/init.d/openerp-server stop

Automating OpenERP Startup and Shutdown

The final step is make the script start and stop automatically with the Ubuntu Server, to do this:

Linux Terminal:~$

sudo update-rc.d openerp-server defaults

Reboot the server, when rebooted log back in and test OpenERP is running:

Linux Terminal:~$

ps aux | grep openerp

Which should return something similar to:

openerp 1121 8.1 3.7 474296 76980 ? Sl 13:26 0:03 python /opt/openerp/server/openerp-server -c /etc/openerp-server.conf