How to install OpenERP 8 (Odoo) on FreeBSD and run it alongside OpenERP 7.x


September 2014.
ImageImageThe FreeBSD logo

Situation


You're running a nice OpenERP 7.x on one of your favorite FreeBSD server. You'd like to try the new version 8 (Odoo), but you heard about the fact that databases can't be migrated automatically, so you want to run the two versions alongside.

Install version 8


Download and install


These ports should already be installed since you were running openerp-7.x previously. If not, install or upgrade them:

/graphics/py-imaging
/textproc/py-libxml2
/devel/py-pytz
/lang/py-mx-base
/databases/py-psycopg2
/graphics/py-chart
/graphics/py-pydot
/textproc/py-libxslt
/devel/py-lxml
/textproc/py-xml
/devel/py-yaml
/textproc/py-mako
/devel/py-dateutil
/print/py-reportlab2

Fetch and extract the release:

fetch 'http://nightly.odoo.com/8.0/nightly/src/odoo_8.0rc1-latest.tar.gz'
tar xzvf odoo_8.0rc1-latest.tar.gz
cd openerp-8.0rc1

Install the release

python setup.py install

Warning: this setup will install python packages itself without using the port tree. This is not optimal but it should work quite well anyway.

I recommend installing Odoo in a jail so that you don't trash your entire superb production system.

Set the permissions on the install folder:

chown -R openerpd:wheel /usr/local/lib/python2.7/site-packages/openerp-8.0rc1-py2.7.egg/

Create the configuration files


Theses configuration files might include some useless fields or some things that aren't supported anymore. Use them at your own risks.

/usr/local/etc/openerp-server.conf:

[options]
# Basic daemon configuration options ##################
root_path = /usr/local/lib/python2.7/site-packages/openerp-8.0rc1-py2.7.egg
addons_path = /usr/local/lib/python2.7/site-packages/openerp-8.0rc1-py2.7.egg/openerp/addons
# netinterface =
# interface =
xmlrpc_interface =
xmlrpc_port = 8169
debug_mode = False
stop_after_init = False
soap = False
xmlrpc = True
netrpc = True
netrpc_interface =
netrpc_port = 8070
secure = False
cache_timeout = 100000
pidfile = /var/run/openerp/openerp-server.pid
reportgz = False
admin_passwd = admin
login_message = False
price_accuracy = 2
csv_internal_sep = ,
translate_modules = ['all']

# Logging options #####################################
syslog = False
log_level = info
logfile = /var/log/openerp/openerp-server.log
assert_exit_level = warn

# Database options ####################################
db_name = openerp
db_user = openerp
db_password = openerppassword
db_host = localhost
db_maxconn = 64
pg_path = /usr/local/bin
list_db = True
# import_partial =

# SMTP options ########################################
smtp_server = localhost
smtp_port = 25
smtp_user = False
smtp_password = False
email_from = False

# Use demo files? #####################################
# without_demo = True
# demo = {}

/usr/local/etc/openerp-web.conf:

# Example configuration file for OpenERP-web
#
# This is an example configuration file, just copy it
# to openerp-web.conf and edit it to suit your needs.

# OpenERP Web server
[global]

# the ip and port the web server will be listening on
server.socket_host = "0.0.0.0" # 0.0.0.0 means all ip addresses
server.socket_port = 8180

# Sets the number of threads the server uses
server.thread_pool = 10

server.environment = "development"

# Simple code profiling
server.profile_on = False
server.profile_dir = "profile"

# Set to True if you are deploying your App behind a proxy
# e.g. Apache using mod_proxy
#tools.proxy.on = True

# If your proxy does not add the X-Forwarded-Host header, set
# the following to the *public* host url.
#tools.proxy.base = 'http://mydomain.com'

# logging
log.access_file = "/var/log/openerp-web/access.log"
log.error_file = "/var/log/openerp-web/error.log"

# OpenERP Server information
[openerp]
host = 'localhost'
port = '8170'
protocol = 'socket'

# Web client settings
[openerp-web]
# filter dblists based on url pattern?
# NONE: No Filter
# EXACT: Exact Hostname
# UNDERSCORE: Hostname_
# BOTH: Exact Hostname or Hostname_

dblist.filter = 'NONE'

# whether to show Databases button on Login screen or not
dbbutton.visible = True

# will be applied on company logo
company.url = ''

# options to limit data rows in M2M/O2M lists, will be overriden
# with limit="5", min_rows="5" attributes in the tree view definitions
child.listgrid.limit = 5
child.listgrid.min_rows = 5

Don't forget to do what's needed to allow user openerpd to write its log files.

Create the RC scripts


Don't forget to chmod them so they can be executed.

/usr/local/etc/rc.d/openerp-server:

#!/bin/sh
#
# PROVIDE: openerpd
# REQUIRE: postgresql LOGIN
#
# Add the following lines to /etc/rc.conf to enable openerp-server
#
#
# openerpd_enable (bool): Set to "NO" by default,
# Set it to "YES" to enable openerp-server
#
# openerpd_config (str): The path to the openerp-server configuration file
# (defaults to /usr/local/etc/openerp-server.conf)
#
# openerpd_flags (str): Extra arguments to be used when invoking
# the openerp-server daemon.
#
# Patch submitted by (c) Franck Porcher, Ph.D, to fix some issues regarding
# pidfile, log files, and discrepencies with the main configuration file.

# getval varname file [default_value] [separator_char]
# - Discard comment lines (any text leading with blanks then #)
# - Retain only the last value set


. /etc/rc.subr

name=openerpd
command=/usr/local/bin/openerp-server
rcvar=openerpd_enable

load_rc_config $name

openerpd_enable="${openerpd_enable-"NO"}"
openerpd_config="${openerpd_config-"/usr/local/etc/openerp-server.conf"}"
openerpd_user="${openerpd_user-"openerpd"}"
openerpd_pidfile="${openerpd_pidfile:-"$(grep pidfile /usr/local/etc/openerp-server.conf | awk -F "=" ' { print $2 } ' |sed 's/[ ]//g' )"}"
openerpd_logdir="${openerpd_logdir:-"$(dirname `grep logfile /usr/local/etc/openerp-server.conf | awk -F "=" ' { print $2 } ' `)"}"
openerpd_flags="${openerpd_flags:-"--config=${openerpd_config}"}"

# /etc/rc.subr use $pidfile (not ${name}_pidfile)
pidfile="${openerpd_pidfile}"

required_files="${openerpd_config}"

start_precmd="${name}_prestart"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
getval_cmd="${name}_getval"

openerpd_prestart()
{
local d

d="$(dirname "${openerpd_pidfile}")"
if [ ! -d "${d}" ]
then
mkdir -p "${d}"
fi
chown "${openerpd_user}" "${d}"

d="$openerpd_logdir"
if [ ! -d "${d}" ]
then
mkdir -p "${d}"
fi
chown "${openerpd_user}" "${d}"
}

openerpd_stop()
{
# echo "Looking for (openerp-server ${openerpd_flags})"
openerpd_pid=$(pgrep -f "openerp-server ${openerpd_flags}")
# Try its best to stop the service
if [ -f "${openerpd_pidfile}" ] && [ "${openerpd_pidfile}" = "${openerpd_pid}" ]
then
echo "Stopping ${name}."
kill -15 "$(cat "${openerpd_pidfile}")"
else
if [ -n "${openerpd_pid}" ]
then
echo "Stopping ${name}."
kill -15 "${openerpd_pid}"
else
echo "${name} not running? (pidfile not found)"
fi
fi
}

openerpd_status()
{
# Try its best to find the service's status
if [ -f "${openerpd_pidfile}" ]
then
openerpd_pid="$(cat "${openerpd_pidfile}")"
fi

if [ -z "${openerpd_pid}" ]
then
openerpd_pid=$(pgrep -f "openerp-server.py ${openerpd_flags}")
[ -n "${openerpd_pid}" ] && echo "${openerpd_pid}" > "${openerpd_pidfile}"
fi

if [ -n "${openerpd_pid}" ]
then
echo "${name} running with pid: $openerpd_pid"
else
echo "${name} not running? (pid not found)"
fi
}

command_args=" >/dev/null 2>&1 &"

load_rc_config $name
run_rc_command "$1"


/etc/rc.conf:

openerpd_enable="YES"
openerpweb_enable="YES"
openerpweb_user="openerpd"

/usr/local/bin/openerp-server:

#!/usr/local/bin/python
# EASY-INSTALL-SCRIPT: 'openerp==8.0rc1','openerp-server'
import os
os.environ['PYTHON_EGG_CACHE'] = '/home/openerpd/.python-eggs'
os.environ['XDG_DATA_HOME'] = '/home/openerpd/.local'
__requires__ = 'openerp==8.0rc1'
import pkg_resources
pkg_resources.run_script('openerp==8.0rc1', 'openerp-server')

Start the server



/usr/local/etc/rc.d/openerp-server start

If the server does not start, try to start it manually and look for any output:

su -m openerpd -c 'sh -c "/usr/local/bin/openerp-server --config=/usr/local/etc/openerp-server.conf"'

Run OpenERP 7.x at the same time


Install OpenERP 7.x the same way as version 8, or using port finance/openerp-server.

Create the configuration files


Makes sure that the two version listen on different ports.

/usr/local/etc/openerp-server7.conf:

[options]
# Basic daemon configuration options ##################
root_path = /usr/local/lib/python2.7/site-packages/openerp-server/
addons_path = /usr/local/lib/python2.7/site-packages/openerp-7.0_20130917_231058-py2.7.egg/openerp/addons
# netinterface =
# interface =
port = 8069
netport = 8070
debug_mode = False
stop_after_init = False
soap = False
xmlrpc = True
netrpc = True
secure = False
cache_timeout = 100000
pidfile = /var/run/openerp/openerp-server7.pid
reportgz = False
admin_passwd = admin
login_message = False
price_accuracy = 2
csv_internal_sep = ,
translate_modules = ['all']

# Logging options #####################################
syslog = False
log_level = info
logfile = /var/log/openerp/openerp-server7.log
assert_exit_level = warn

# Database options ####################################
db_name = openerp
db_user = openerp
db_password = openerppassword
db_host = localhost
db_maxconn = 64
pg_path = /usr/local/bin
list_db = True
# import_partial =

# SMTP options ########################################
smtp_server = localhost
smtp_port = 25
smtp_user = False
smtp_password = False
email_from = False

# Use demo files? #####################################
# without_demo = True
# demo = {}


/usr/local/etc/openerp-web7.conf:

# Example configuration file for OpenERP-web
#
# This is an example configuration file, just copy it
# to openerp-web.conf and edit it to suit your needs.

# OpenERP Web server
[global]

# the ip and port the web server will be listening on
server.socket_host = "0.0.0.0" # 0.0.0.0 means all ip addresses
server.socket_port = 8180

# Sets the number of threads the server uses
server.thread_pool = 10

server.environment = "development"

# Simple code profiling
server.profile_on = False
server.profile_dir = "profile"

# Set to True if you are deploying your App behind a proxy
# e.g. Apache using mod_proxy
#tools.proxy.on = True

# If your proxy does not add the X-Forwarded-Host header, set
# the following to the *public* host url.
#tools.proxy.base = 'http://mydomain.com'

# logging
log.access_file = "/var/log/openerp-web/access7.log"
log.error_file = "/var/log/openerp-web/error7.log"

# OpenERP Server information
[openerp]
host = 'localhost'
port = '8170'
protocol = 'socket'

# Web client settings
[openerp-web]
# filter dblists based on url pattern?
# NONE: No Filter
# EXACT: Exact Hostname
# UNDERSCORE: Hostname_
# BOTH: Exact Hostname or Hostname_

dblist.filter = 'NONE'

# whether to show Databases button on Login screen or not
dbbutton.visible = True

# will be applied on company logo
company.url = ''

# options to limit data rows in M2M/O2M lists, will be overriden
# with limit="5", min_rows="5" attributes in the tree view definitions
child.listgrid.limit = 5
child.listgrid.min_rows = 5

Create the RC scripts


/usr/local/etc/rc.d/openerp-server7:

#!/bin/sh
#
# PROVIDE: openerpd7
# REQUIRE: postgresql LOGIN
#
# Add the following lines to /etc/rc.conf to enable openerp-server
#
#
# openerpd7_enable (bool): Set to "NO" by default,
# Set it to "YES" to enable openerp-server
#
# openerpd7_config (str): The path to the openerp-server configuration file
# (defaults to /usr/local/etc/openerp-server.conf)
#
# openerpd7_flags (str): Extra arguments to be used when invoking
# the openerp-server daemon.
#
# Patch submitted by (c) Franck Porcher, Ph.D, to fix some issues regarding
# pidfile, log files, and discrepencies with the main configuration file.

# getval varname file [default_value] [separator_char]
# - Discard comment lines (any text leading with blanks then #)
# - Retain only the last value set


. /etc/rc.subr

name=openerpd7
command=/usr/local/bin/openerp-server7
rcvar=openerpd7_enable

load_rc_config $name

openerpd7_enable="${openerpd7_enable-"NO"}"
openerpd7_config="${openerpd7_config-"/usr/local/etc/openerp-server7.conf"}"
openerpd7_user="${openerpd7_user-"openerpd"}"
openerpd7_pidfile="${openerpd7_pidfile:-"$(grep pidfile /usr/local/etc/openerp-server7.conf | awk -F "=" ' { print $2 } ' |sed 's/[ ]//g' )"}"
openerpd7_logdir="${openerpd7_logdir:-"$(dirname `grep logfile /usr/local/etc/openerp-server7.conf | awk -F "=" ' { print $2 } ' `)"}"
openerpd7_flags="${openerpd7_flags:-"--config=${openerpd7_config}"}"

# /etc/rc.subr use $pidfile (not ${name}_pidfile)
pidfile="${openerpd7_pidfile}"

required_files="${openerpd7_config}"

start_precmd="${name}_prestart"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
getval_cmd="${name}_getval"

openerpd7_prestart()
{
local d

d="$(dirname "${openerpd7_pidfile}")"
if [ ! -d "${d}" ]
then
mkdir -p "${d}"
fi
chown "${openerpd7_user}" "${d}"

d="$openerpd7_logdir"
if [ ! -d "${d}" ]
then
mkdir -p "${d}"
fi
chown "${openerpd7_user}" "${d}"
}

openerpd7_stop()
{
# echo "Looking for (openerp-server ${openerpd7_flags})"
openerpd7_pid=$(pgrep -f "openerp-server ${openerpd7_flags}")
# Try its best to stop the service
if [ -f "${openerpd7_pidfile}" ] && [ "${openerpd7_pidfile}" = "${openerpd7_pid}" ]
then
echo "Stopping ${name}."
kill -15 "$(cat "${openerpd7_pidfile}")"
else
if [ -n "${openerpd7_pid}" ]
then
echo "Stopping ${name}."
kill -15 "${openerpd7_pid}"
else
echo "${name} not running? (pidfile not found)"
fi
fi
}

openerpd7_status()
{
# Try its best to find the service's status
if [ -f "${openerpd7_pidfile}" ]
then
openerpd7_pid="$(cat "${openerpd7_pidfile}")"
fi

if [ -z "${openerpd7_pid}" ]
then
openerpd7_pid=$(pgrep -f "openerp-server.py ${openerpd7_flags}")
[ -n "${openerpd7_pid}" ] && echo "${openerpd7_pid}" > "${openerpd7_pidfile}"
fi

if [ -n "${openerpd7_pid}" ]
then
echo "${name} running with pid: $openerpd7_pid"
else
echo "${name} not running? (pid not found)"
fi
}


command_args=" >/dev/null 2>&1 &"

load_rc_config $name
run_rc_command "$1"

/etc/rc.conf:

openerpd7_enable="YES"
openerpweb7_enable="YES"
openerpweb7_user="openerpd"

/usr/local/bin/openerp-server7:

#!/usr/local/bin/python
# EASY-INSTALL-SCRIPT: 'openerp==7.0-20130917-231058','openerp-server'
import os
os.environ['PYTHON_EGG_CACHE'] = '/tmp/python_egg_cache'
__requires__ = 'openerp==7.0-20130917-231058'
import pkg_resources
pkg_resources.run_script('openerp==7.0-20130917-231058', 'openerp-server')

Start the server



/usr/local/etc/rc.d/openerp-server7 start

If the server does not start, try to start it manually and look for any output:

su -m openerpd -c 'sh -c "/usr/local/bin/openerp-server7 --config=/usr/local/etc/openerp-server7.conf"'