Installing Odoo from source
To keep things organized, we will work in a /odoo-dev directory inside our home directory. Throughout the book, we will assume that the /odoo-dev is the directory where your Odoo server is installed.
Odoo 12 uses Python 3, specifically 3.5 or later. This means that on the command line, we should use python3 and pip3, instead of python and pip.
Starting from version 11, Odoo runs on Python 3.5 or later. Odoo 11 still runs on Python 2.7, but Odoo 12 only runs on Python 3.5+. Odoo 10 and before only run on Python 2.7.
To install Odoo from source, we start by cloning the Odoo source code directly from GitHub:
$ mkdir ~/odoo-dev # Create a directory to work in $ cd ~/odoo-dev # Go into our work directory $ git clone https://github.com/odoo/odoo.git -b 12.0 \
--depth=1 # Get Odoo sources
The ~ symbol is a shortcut for the user's home directory, such as /home/daniel.
If using Windows Subsystem for Linux, the files in the home directory are stored in a difficult to find place, inside the Windows system folder. A way to avoid this issue is to store our work files in the Windows folder of our preference, and then use a symbolic link for it (similar to a shortcut) in the Linux subsystem. For example, mkdir /mnt/c/Users/Public/odoo-dev creates the C:\Users\Public\odoo-dev working directory, and then ln -s /mnt/c/Users/Public/odoo-dev ~/odoo-dev creates the ~/odoo-dev Linux directory, which is actually a link to the Windows directory. Now, you can run all commands on ~/odoo-dev, such as the previous git clone, and the files are all also available in C:\Users\Public\odoo-dev.
The -b 12.0 option in the Git command explicitly downloads the 12.0 branch of Odoo. At the time of writing, this is redundant since it is the default branch; however, this may change. The --depth=1 option tells Git to download only the last revision, instead of the full change history, making the download significantly smaller and faster.
Before we can run Odoo, we need to install the Python dependencies declared in the requirements.txt file:
$ pip3 install -r ~/odoo-dev/odoo/requirements.txt
Many of these dependencies have Debian packages available to install them, such as python3-lxml. A valid alternative is to install them using the apt package manager. This has the advantage of automatically installing the system dependencies when necessary. The list of dependencies used can be found in the ./odoo/debian/control file.
A few additional Python packages, not included in requirements.txt, can be installed to suppress warning messages or enable additional features:
$ pip3 install num2words phonenumbers psycopg2-binary watchdog xlwt
Now, we can start the Odoo server instance by running the following:
$ ~/odoo-dev/odoo/odoo-bin
To stop the server and return to Command Prompt, press Ctrl + C.
The script used to start Odoo is now ./odoo-bin. In previous Odoo versions, it was ./odoo.py.
By default, Odoo instances listen on port 8069, so if we point a browser to http://<server-address>:8069, we will reach these instances.
As developers, we will need to work with several databases, so it's more convenient to create them from the command line, and we will learn how to do this. Now, press Ctrl + C in the terminal to stop the Odoo server and get back to Command Prompt.