Wednesday, June 20, 2018

Installing Odoo 11 on ubuntu 16.04

Odoo version 11 is officially released now. You can find its Source Code for Community Edition from this GITHUB LINK.

Here, in this tutorial I`ll explain how to install Odoo version 11 (Community Edition) on Ubuntu 16.04, same steps can also work for previous Ubuntu version(s) till version 14.

If Python Is Already Installed, Make Sure It Is 3.5 Or Above That, Previous Versions Are Not Compatible With Odoo 11

Open the terminal and execute below commands step-by-step to achieve excellence:

Step 1: 

Update apt source-lists:
sudo apt-get update

Step 2: 

Create the Odoo user that will own and run the application
sudo adduser --system --home=/opt/odoo --group odoo

Step 3: 

Install and configure the database server, PostgreSQL
sudo apt-get install -y postgresql
Once the PostgreSQL is installed, next we setup a new PostgreSQL user for our application. This user will be used for making all the database interaction form the Odoo.

sudo service postgresql start

sudo su - postgres

createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
Enter password for new role: *****
Enter it again:*****
Finally exit from the Postgres user account:

exit

Step 4:(Optional)

Your Odoo server may encounter some issue(s), so I`m also mentioning few issues & their way around to fix them:

FIX 1: You need to upgrade ”wkhtmltopdf” to 0.12.1  You can also check this LINK
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin
FIX 2: Check if your PostgreSQL has a proper encoding(UTF-8) or not, used in Odoo Application, if not you can do like this:
sudo su - postgres

psql

update pg_database set encoding = pg_char_to_encoding('UTF8');

\q
exit

sudo service postgresql restart

Step 5: 

Install the necessary Python libraries & other needed libraries needed for the application:
Odoo 11 will use python 3.5(which is pre-installed on our Ubuntu), previously it uses Python 2.7, so in order to install all dependent libraries easily we`ll install pip3 in our server, as:
sudo apt-get install -y python3-pip
Once pip3 is installed on your server, we can proceed with installing other dependent libraries using pip3 as:
pip3 install Babel decorator docutils ebaysdk feedparser gevent greenlet html2text Jinja2 lxml Mako MarkupSafe mock num2words ofxparse passlib Pillow psutil psycogreen psycopg2 pydot pyparsing PyPDF2 pyserial python-dateutil python-openid pytz pyusb PyYAML qrcode reportlab requests six suds-jurko vatnumber vobject Werkzeug XlsxWriter xlwt xlrd 
Next is to install Odoo Web Dependencies:
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install -y node-less
Once all the packages are installed we are ready to proceed with installing Odoo server.

Step 6:

Installing ODOO version 11 Community Edition hosted on GITHUB.
Make sure you have GIT installed on your system and if not then install with the simple command:
sudo apt-get install -y git
Switch to the Odoo user:
sudo su - odoo -s /bin/bash
Clone the latest branch of Odoo, in our case it is 11.0 from Github:
git clone https://www.github.com/odoo/odoo --depth 1 --branch 11.0 --single-branch .

exit

Step 7:

Next step is to create a configuration file for Odoo. But before doing so w`ll first create the directory for storing logs of Odoo server and assigning proper ownership to the directory:

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

Next is to create the configuration file for odoo server. Odoo application will use these configurations to run to fill in the configuration as per your requirements.
sudo nano /etc/odoo-server.conf

A sample configuration file will look like this:
[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = False
logfile = /var/log/odoo/odoo-server.log
addons_path = /opt/odoo/addons,/opt/odoo/odoo/addons

(* You need to use the same password you used back in step 3.)
Once the configuration file is created we will set the ownership rights
sudo chown odoo: /etc/odoo-server.conf

sudo chmod 640 /etc/odoo-server.conf

Step 8:

Installing the boot script
For the final step we need to install a script which will be used to start-up & shut-down the Odoo server automatically, with the correct user. Here is a Link, you can use this script for the same purpose, as:

Paste the same contents of this script to this file. Once it is in the right place you will need to make it executable and owned by root:
sudo chmod 755 /etc/init.d/odoo-server
sudo chown root: /etc/init.d/odoo-server

Step 9:

Testing the server
To start the Odoo server type:
sudo /etc/init.d/odoo-server start
You should now be able to view the log-file as:
sudo nano /var/log/odoo/odoo-server.log
If there are any problems in this step you need to go back and check, feel free to comment on this blog I`ll try my best to help you 
[OPTIONAL] Also, in order to debug, you can start the server manually just to check if it actually runs well or not, as:
sudo su – odoo -s /bin/bash
/opt/odoo/odoo-bin
If the log file looks OK, you can check Odoo server running on your browser with url:
http://yourip:8069

BOOT SCRIPT USAGE:
/etc/init.d/odoo-server {start|stop|restart/reload|status|force-restart|force-stop}
For Start Server
sudo service odoo-server start
For Stop Server
sudo service odoo-server stop
For Restart server 
sudo service odoo-server restart
That`s it…
Thanks for reading this blog !!! I hope it will help someone.

Saturday, July 9, 2016

install Odoo 9 on CentOS 7 VPS

Odoo is one of the most popular and most powerful Open Source ERP business software based on the Python programming language. In this blog article we will show you how to install Odoo 9 on a CentOS 7 VPS / RHEL. This new version of Odoo comes with many improvements over its predecessor and many new features 


In order to install all Odoo 9 dependencies the EPEL repository must be added to the distribution’s repositories
yum install -y epel-release

if you can't use yum then add repo like that
yum --enablerepo=epel install python-pip

Install PostgreSQL server
yum install -y postgresql-server

Once it is installed and started for the first time, we have to initialize the PostgreSQL database
postgresql-setup initdb

Start the PostgreSQL server and enable it to start at boot time
systemctl start postgresql
systemctl enable postgresql

Create new yum repository for Odoo
nano /etc/yum.repos.d/odoo.repo
With the following content
odoo-nightly]
name=Odoo Nightly repository
baseurl=http://nightly.odoo.com/9.0/nightly/rpm/
enabled=1
gpgcheck=1
gpgkey=https://nightly.odoo.com/odoo.key

and finally install Odoo 9
yum install -y odoo
This will install the latest version of Odoo and all its dependencies.

After the installation is completed, start Odoo and enable it to start at boot times
systemctl start odoo
systemctl enable odoo

Restart Odoo for the changes to take effect

systemctl restart odoo
In order to print PDF reports, wkhtmltopdf has to be installed on your server. The version of wkhtmltopdf available in the CentOS repositories does not support headers and footers, so we will download it and manualy install wkhtmltopdf from their official website.

Install some wkhtmltopdf dependencies
yum install fontconfig libpng libX11 libXext libXrender xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi

Copy the appropriate rpm file from wkhtmltopdf’s website and install it using the following command


rpm -Uvh http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-centos7-amd64.rpm
Now, open a web browser and access Odoo 9 at http://yourIPaddress:8069 to create a new PostgreSQL database and set password for the admin user.

if you can't open 8069 port then 


firewall-cmd –zone=public –add-port=8069/tcp –permanent
firewall-cmd –reload

Wednesday, May 4, 2016

Install Odoo 9 on Ubuntu 14.04


This guide covers how to install and configure Odoo in just 35 minutes using Git source so it will be easy to upgrade, maintain and customize.

Before You Begin

Log in to your Linode via SSH and check for updates using apt-get package manager.


sudo apt-get update && sudo apt-get upgrade

Open Corresponding Firewall Ports

In this case we’re using Odoo’s default port 8069, but this could be any port you specify later in the configuration file.

sudo ufw allow ssh
sudo ufw allow 8069/tcp
sudo ufw enable

Install Database and Server Dependencies

Now we’re going to install the PostgreSQL database and other necesary server libraries  using  apt-get
sudo apt-get install subversion git bzr bzrtools python-pip postgresql postgresql-server-dev-9.3 python-all-dev python-dev python-setuptools libxml2-dev libxslt1-dev libevent-dev libsasl2-dev libldap2-dev pkg-config libtiff5-dev libjpeg8-dev libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev liblcms2-utils libwebp-dev tcl8.6-dev tk8.6-dev python-tk libyaml-dev fontconfig
Create Odoo User and Log Directory
Create the Odoo system user.


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

change or set odoo user password
sudo passwd odoo
it will ask for new password of odoo user 
enter new password as you want for odoo user 

for login to odoo user (optional)

sudo su - odoo -s /bin/bash



Create the log directory.

sudo mkdir /var/log/odoo


Install Odoo Server Files from Source

Change to the Odoo directory, in our case:

cd /opt/odoo/

Clone the Odoo files on your server.

sudo git clone https://www.github.com/odoo/odoo --depth 1 --branch 9.0 --single-branch .


Create PostgreSQL User

Switch to postgres user.
sudo su - postgres
But, if you’re deploying a Production server you may want to set a strong password for the database user.

createuser odoo -U postgres -dRSP
You’ll be prompted for a password, save it, we’ll need it shortly.
Press CTRL+D to exit from postgres user session.



Specific Dependencies for Odoo Applications


Using pip instead of apt-get will guarantee that your installation has the correct versions needed. We’ll also abstain of using Ubuntu’s packaged versions of Wkhtmltopdf and node-less.

Install Python Dependencies

Install Python libraries using the following commands:
sudo pip install -r /opt/odoo/doc/requirements.txt
sudo pip install -r /opt/odoo/requirements.txt


Install Less CSS via nodejs and npm.

Download nodejs installation script from nodesource.
wget -qO- https://deb.nodesource.com/setup | sudo bash -

Now that our repository list is updated install nodejs using apt-get.

sudo apt-get install nodejs

Time to install a newer version of Less via npm.

sudo npm install -g less less-plugin-clean-css


Install Updated Wkhtmltopdf Version

Switch to a temporally directory of your choice.
cd /tmp

Download the recommended version of wkhtmltopdf for Odoo server, currently 0.12.1

sudo wget http://download.gna.org/wkhtmltopdf/0.12/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb

Install the package using dpkg.

sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb

To function properly we’ll need to copy the binaries to an adequate location.

sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin


Odoo Server Configuration

Copy the included configuration file to a more convenient location changing it’s name toodoo-server.conf

sudo cp /opt/odoo/debian/openerp-server.conf /etc/odoo-server.conf

Next we need to modify the configuration file. The finished file should look similar to this depending on your deploying needs:
File :- /etc/odoo-server.conf

[options]
admin_passwd = admin
db_host = False 
db_port = False
db_user = odoo
db_password = <PostgreSQL_user_password>
addons_path = /opt/odoo/addons
logfile = /var/log/odoo/odoo-server.log
xmlrpc_port = 8069


  • admin_passwd = admin This is the password that allows database operations.
  • db_host = False Unless you plan to connect to a different database server address, leave this line untouched.
  • db_port = False Odoo uses PostgreSQL default port 5432, change only if necessary.
  • db_user = odoo Database user, in this case we used the default name.
  • db_password = The previously created PostgreSQL user password.
  • addons_path = We need to modify this line to read: addons_path = /opt/odoo/addons. Add</path/to/custom/modules> if needed.
  • We need to include the path to log files adding a new line:logfile = /var/log/odoo/odoo-server.log
  • Optionally we could include a new line specifying the Odoo Frontend port used for connection: xmlrpc_port = 8069. This only makes sense if you’re planning to run multiple Odoo instances (or versions) on the same server. For normal installation you could skip this line and Odoo will connect by default to port 8069.


Odoo Boot Script

Next step is creating a boot script odoo-server to gain control over Odoo behavior and use it at server startup and shutdown.
File :- /etc/init.d/odoo-server
#!/bin/sh
### BEGIN INIT INFO
# Provides: odoo-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Odoo ERP
# Description: Odoo is a complete ERP business solution.
### END INIT INFO

PATH=/bin:/sbin:/usr/bin
# Change the Odoo source files location according your needs.
DAEMON=/opt/odoo/openerp-server
# Use the name convention of your choice 
NAME=odoo-server
DESC=odoo-server

# Specify the user name (Default: odoo).
USER=odoo

# Specify an alternate config file (Default: /etc/odoo-server.conf).
CONFIGFILE="/etc/odoo-server.conf"

# pidfile
PIDFILE=/var/run/$NAME.pid

# Additional options that are passed to the Daemon.
DAEMON_OPTS="-c $CONFIGFILE"

[ -x $DAEMON ] || exit 0
[ -f $CONFIGFILE ] || exit 0

checkpid() {
[ -f $PIDFILE ] || return 1
pid=`cat $PIDFILE`
[ -d /proc/$pid ] && return 0
return 1
}

case "${1}" in
start)
echo -n "Starting ${DESC}: "

start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}

echo "${NAME}."
;;

stop)
echo -n "Stopping ${DESC}: "

start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo

echo "${NAME}."
;;

restart|force-reload)
echo -n "Restarting ${DESC}: "

start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \
--oknodo

sleep 1

start-stop-daemon --start --quiet --pidfile ${PIDFILE} \
--chuid ${USER} --background --make-pidfile \
--exec ${DAEMON} -- ${DAEMON_OPTS}

echo "${NAME}."
;;

*)
N=/etc/init.d/${NAME}
echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2
exit 1
;;
esac

exit 0


Odoo Files Ownership and Permissions

Change the odoo-server file permissions and ownership so only root can write to it, while odoo user will only be able to read and execute it.


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

Since odoo user will run the application, change its ownership accordingly.


sudo chown -R odoo: /opt/odoo/

We should set odoo user as the owner of log directory as well.

sudo chown odoo:root /var/log/odoo

Finally, we should protect the server configuration file changing its ownership and permissions so no other non-root user can access it.


sudo chown odoo: /etc/odoo-server.conf
sudo chmod 640 /etc/odoo-server.conf


Testing the Server

It’s time to check that everything is working as expected, lets start the Odoo server.
sudo /etc/init.d/odoo-server start
Let’s take a look at log file to verify no errors occurred.

cat /var/log/odoo/odoo-server.log

Now we can check if the server stops properly too.

sudo /etc/init.d/odoo-server stop
Enter the same command again.

cat /var/log/odoo/odoo-server.log


Running Boot Script at Server Startup and Shutdown

If the Odoo server log doesn’t indicate any problem we can continue and make the Boot script start and stop with the server.
sudo update-rc.d odoo-server defaults

It’s a good idea to restart our Server to see if everything is working

sudo shutdown -r now

Once restarted verify one more time the log file.

cat /var/log/odoo/odoo-server.log


Testing Odoo Frontend

Open a new browser window and enter in the address bar:
http://<your_domain_or_IP_address>:8069

A screen similar to this would show up.





Congratulations, now you can create your first database and start using Odoo!