Saturday, 29 May 2010

Installing OpenERP on Ubuntu 10.04 LTS

Background

It's that time of the year again. I need to prepare all the information required by my accountant to issue my company accounts. Luckily I have most of it saved in a handy directory on my laptop, with a backup copy on the server. However, it still takes a lot of time that I'd rather be spending doing something else. Accounts are not the only process that I'd like to improve: sales, expenses, invoicing, everything that is not part of my daily job is done in an ad-hoc way. This is exactly what ERP systems are designed to address. And as usual, there is an open source solution out there, one that is even fully supported on Ubuntu: OpenERP. Let's install it then!

Before we start, OpenERP is a client-server solution and as such there are two components to consider:

OpenERP Server
This is a central component that is deployed on a central server and is responsible for managing the company database. You should have a single instance of it for the whole company.
OpenERP Client
This is a desktop application that enables users to view and update the data held in the server. It should be installed on every computer that needs access to the ERP system.

In addition, OpenERP also offers another server component called OpenERP Web. This component is meant to be deployed on the same server as OpenERP Server and offers a web interface to the ERP system, meaning that you can access the system using a vanilla web browser, rather than the dedicated client application. This is great if you have a large number of users and don't want to deploy the dedicated client everywhere. I will ignore this component for today and only go through the installation of the server and dedicated client.

OpenERP Server

To install the server component, you need a computer that will act as a server. You could potentially install it on your desktop or laptop if you are sure that you will only ever be the single user of the application but I wouldn't recommend it. In my case, I decided to install it on my existing home server that runs Ubuntu Server 10.04 LTS.

Install PostgreSQL

OpenERP needs a database engine and is designed to run with PostgreSQL so we need to install this first. To do this, connect to the server and just install the relevant package, as detailed in the OpenERP manual:

$ sudo apt-get install postgresql
Create an openerp user in PostgreSQL

The server will need a dedicated user in the database so we need to create it. To do this, we first need to start a session under the identity of the postgres Linux user. We can then create the database user that we will name openerp. When prompted, enter a password and make sure you remember it. There is no need for that user to be an administrator so we answer n when asked that question. Then close the postgres session to come back to your standard Linux user.

$ sudo su - postgres
$ createuser --createdb --username postgres --no-createrole \
 --pwprompt openerp
Enter password for new role: 
Enter it again: 
Shall the new role be a superuser? (y/n) n
$ exit

Now that this new user is created, let's try to connect to the database engine using it:

$ psql -U openerp -W
psql: FATAL:  Ident authentication failed for user "openerp"

It doesn't work. This is because PostgreSQL uses IDENT-based authentication rather than password-based authentication. To solve this, edit the client authentication configuration file:

$ sudo vi /etc/postgresql/8.4/main/pg_hba.conf

Find the line that reads:

local all all ident

Replace the word ident with md5:

local all all md5

And restart the database server:

$ sudo /etc/init.d/postgresql-8.4 restart

Let's try again:

$ psql -U openerp -W
psql: FATAL:  database "openerp" does not exist

OK, that's a different error which is due to the fact that PostgreSQL tries to connect to a database that has the same name as the user if none is specified. So let's try to connect to the postgres database, which is contains system information and is always installed.

$ psql -d postgres -U openerp -W
psql (8.4.4)
Type "help" for help.
postgres=>

That works so we know that the user has been successfully created and there should be no problem connecting with that user identity.

Install OpenERP Server

OpenERP Server is part of the Ubuntu repositories so it's extremely easy to install:

$ sudo apt-get install openerp-server

Now is a good time for a coffee break. On my installation, the openerp-server package triggers the installation of no less than 108 packages in 48.9MB of archives that will require an additional 251MB of disk space. This may take some time. Most of the additional packages are Python packages, which is sensible because OpenERP is written in Python but the fact that it also requires things like xterm and bits of GTK makes me think that the dependency list could be pruned somewhat. At the end of the installation, a message appears saying that you should go and read the file called /usr/share/doc/openerp-server/README.Debian. Go and do this. It mainly explains the PostgreSQL installation that we just did but it also mentions a bit of useful information, namely that the OpenERP Server configuration file is /etc/openerp-server.conf. That's quite handy because we need to update it.

$ sudo vi /etc/openerp-server.conf

If you are installing the server and client on different machine, which I would recommend, you need to find the line that says:

interface = localhost

And replace the word localhost with the IP address of your server. If you don't know the IP address of the server, just run ifconfig with no parameters and look for the words inet addr: at the beginning of the second line of output: the IP address is the set of four number separated by dots that come just after that. You then need to modify another two lines:

dbpassword = the password you chose for the openerp user
dbhost = localhost

In theory you shouldn't have to specify dbhost = localhost because leaving that entry blank should default to the value localhost but when I tried this, OpenERP Server could not connect to PostgreSQL. It's now time to restart the server process but before we do this, it's always good to be able to follow the logs in a second window just in case something goes wrong. The location of the log file is helpfully specified in the configuration file that we just edited. Open another terminal, connect to the server and run the following command:

$ tail -f /var/log/openerp-server.log

The last 10 lines of log will appear and every time a new entry is added to the log file, it will also appear in this window. In the first window, we can restart the server:

$ sudo /etc/init.d/openerp-server restart

If all goes well, no nasty error message should appear in the log window.

OpenERP Client

Now, to install the client software on a desktop, connect to the desktop, open a terminal and install the package:

$ sudo apt-get install openerp-client

That's it. Once finished, you will find an OpenERP Client entry in the Applications -> Internet menu. Click on it to open the client. If you want to fill in the feedback form, do so, otherwise click Cancel. You then need to create a new database. To do this, go to the File -> Databases -> New Database menu:

New Database menu

This will open a dialogue where you can enter the details of the new database.

New Database dialogue

You will need to click on the Change button at the top to specify the name or IP address of the server. The port should be the default, 8070. Of course, if you have a firewall between the client and the server, the firewall configuration will need to be updated to allow traffic to the server through this port. The default password for the super administrator is admin as specified in the dialogue. Note that the database name cannot contain spaces, dashes or any non-alphanumeric characters.

So that's OpenERP installed. It's now time to read the rest of the documentation and get a copy of Accounting for Dummies to understand what it's all about.

32 comments:

fhe said...

How to install OpenERP 5.0.10 on Ubuntu 10.04 in less than 5 minutes:
http://www.youtube.com/watch?v=ReOgF2cPSt8

Anonymous said...

Got it working by following your instructions - thanks, much appreciated!

Unknown said...

No problem, I'm glad it was useful. If there is anything that I could have explained better, don't hesitate to tell me.

Danny said...

Hi Bruno...
Thank you very much for this Guide!

I followed it step by steps and don't have any issue at all.

I am just wondering, have you ever tried to use ldap module in OpenERP?

I have installed python-ldap and users_ldap OpenERP module, but it just won't connect to my AD.

If you have done one before, could you share your skill again please? :)

Unknown said...

Danny, I haven't tried the LDAP module so can't help you with it, sorry.

Danny said...

No Worries Bruno :)

Again, thank you for your step by step guide!

Anonymous said...

cant wait for the quick web client install

Edgar said...

-What would be the name of the user of the new database? Administrator? In the dialog box the password is specified, but not the name of the user.

Anonymous said...

My server is Ubuntu 9.04
The IP-address of the server 192.168.1.100

When in the browser I go to http://192.168.1.100:8080/

I get: Could not connect to server!

But with:

psql -d postgres -U openerp -W

I get:

Welcome to psql 8.3.11, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

postgres=#

Why is it not possible to connect trough the browser?

Unknown said...

Thank you very much for this instructions, the first what ok instalation

Anonymous said...

Excellent Post, thats what im looking for, it solved my issues. Thanks for all and best reggards from Cuba.

Anonymous said...

Excellent Post, thats what im looking for, it solved my issues. Thanks for all and best reggards from Cuba.

Anonymous said...

This worked great for me as well. for those that read this literally. The only trip up I had that others might want to know about is under "Create an openerp user in PostgreSQL" your command "$ createuser --createdb --username postgres --no-createrole\
--pwprompt openerp"
Did not work for me I had to del the trailing slash after "createrole" so:
$ createuser --createdb --username postgres --no-createrole --pwprompt openerp

worked for me

Unknown said...

The backslash character (\) is used to enable you to split a command over multiple lines, it's a standard shell construct that you can use with any command. I include it on multi-line commands but if you write those commands on a single line, you should remove the backslash characters.

R. Granados T, said...

Hello, openerp install step by step and I'm trying to openerp logearme client from a Windows machine and I have not had access.

roger_d said...

Hello,

Thanks for your tutorial.

But i'm stuck to the installation of openerp-server.

I followed your instructions but I can't restart openerp-server.

"Restarting openerp-server: start-stop-daemon: warning: failed to kill 16302: No such process
openerp-server."

And when I try to start openerp-server an error occured :

"[2010-11-18 11:05:36,946][?] CRITICAL:xml-rpc:[16]: Error occur when starting the server daemon: [Errno 98] Adresse déjà utilisée"

Does it mean that openerp-server is already running? So why can't I restart it?

Thank you for your help.

Unknown said...

Hi Bruno, first of all i want to thank you for your great help with this fantastic tutorial. I've followed all steps, and everything is working right on my linux server, the openerp server is working fine, and the client perfectly connects to the DB.

But there's a problem, i have 5 computers on my home network, i've installed the openerp-client in 3 of them and i get the same error on all of them.

When i start the client on any Windows, it find the openerp-server on the port 8070 of the linux computer, the database and it accept my user and password too, but when i hit connect, the client gets froozed 8 minutes and after that it give me this error (It's tranlated from spanish)

Connection error
It's not possible to connect to the OpenERP server¡
You should check your net connection and the OpenERP server.


Could you please give me a hand on this error?
Thank you very much,
Best Regards,
Antonio Cordero Hueros

P.D. My apologies about my spelling i'm from Spain

Unknown said...

@roger_d: I'm not sure as I've never seen that error. What I would suggest is check the IP address that you provided on the "interface =" line and make sure that this IP address is indeed the IP address of your server and is not used by another machine on the network.

@Antonio: I'm not sure I can help here as I don't use Windows at all and the standard Linux client connects fine.

Sorry about not being able to be much help on those two issues.

shenu said...

Very Good Documentation

Unknown said...

hello bruno, good guide!

i was just wondering, does using "apt-get" install the server version 6 or 5?

Unknown said...

ahmad, the version of the server available on Ubuntu 10.04 is 5.0.6 and on Ubuntu 10.10 is 5.0.14.

mechiscogo said...

Hello, Bruno,
I have managed to install both server and client, although, I must say that I installed them both at the same time, and then created the user and modified the configuration.
However, when I open the client from the Applications menu, I can't create the database. I thought that I could possibly be miswriting the passwords: does the super-administrator password is the same as the openerp user? do I have to give a different password for the administrator? are there reserved characters for the password? (I used non-alphanumeric). What is the right way?
My system is actually in Spanish, but I don't think that is the problem.
The log has the following information

[2011-01-21 18:05:32,200] INFO:dbpool:Connecting to template1
[2011-01-21 18:05:33,494] INFO:dbpool:Closing all connections to template1

Unknown said...

@mechiscogo: indeed, I didn't cover that last bit in this article. If you created a standard user, that user will have a password that is different from the super administrator.

However, you will first need to connect as the super administrator and give that new user access to the database, otherwise the user won't be able to open it. I can't remember how to do this as I haven't used OpenERP for some time but I remember it was reasonably straightforward.

mechiscogo said...

Hi Bruno,
I browsed a little bit more, and I found a partial solution:
openerp-server -s --db_user=openuser --db_password=your_password_of_openuser
If I run the process like this for the first time, I can create the initial database. Right now, I guess that if I log-in with the Ubuntu user openerp, I could simply run openerp-server. Moreover, perphaps I can use something like sudo su - openerp -c "openerp-server". Right now, I am trying to build the 5.0.15 version due to localisation issues. However, I will get back to you as soon as I try this solution

mechiscogo said...

Didn't work
This is what I did (without modifying the openerp-server.conf file as you stated) with my "new" 5.0.15 installation:
# Create user without home directory nor login
sudo adduser --disabled-login --no-create-home openerp
# First test:
sudo su - openerp -c "openerp-server"
# Second test:
sudo su - openerp -c "openerp-server -s"

Well, it was a long-shot anyway. Do you know where is the documentation for the openerp-server.conf file?

Two Cents on Flix said...

Hi Bruno, I am a newb with Ubuntu, I actually installed it yesterday and I am now trying to install openerp.
I cant change the ident with md5. Also, once you change it, what do you press to make it go to the $ so that I could enter your next step?
Thank you so much for your help!!!!

Unknown said...

If you're new to Ubuntu, it may be easier to use nano rather than vi as a text editor so replace the vi step with:

sudo nano /etc/postgresql/8.4/main/pg_hba.conf

To come back to the prompt, just save the file and exit the editor.

hoffmaao said...

Can someone comment on the remaining issue where the database cannot be created? I have followed this article in multiple attempts and still get "Error during database creation. Could not create database." I even tried creating a separate administrator user which matched that of the database user and no luck.

Blue Whale SEO said...

Hello,

My OpenERP 6 installation guide on Fedora 16.
Hopefully, you will find it useful :)

Regards,

sap support packs said...

Good explanation, it was extremenly helpul for my, given that Ubuntu is not such an used system.

Unknown said...

Best explanation of installation can be found here.

http://blog.anoopkumarsharma.com/start-openerp-server-for-development/

Priyanka said...

I'm new to OpenERP 7 and went through all modules and settings. Earlier, I created a module using blog's details and they worked also.

But i saw that there is an option to create model, views and menus in Settings -> Technical -> User Interface -> Views. Also model under database structure.

Is there any possibility to create a module with that options? I couldn't find any documentation for OpenERP Ver.7