Field of type Reference in Odoo, how to use it ?

Reference field type in Odoo

The main use of this field type is to make a reference with a specific model and then a specific recordset of this model.

By using the reference field type, the first thing you will choose is the model:

field reference

And by choosing the model you will be asked the choose one of the recordset of the chosen Model

field reference recordset

Structure of the reference field in Odoo (New API)

A field of type reference is declared as below :

ref = fields.Reference(string='Reference', selection='_get_document_types')

Selection attribute : We define the method that will determine which models will be showed, and from which we can choose

In our example we used this method :

method selection field reference

@api.model
    def _get_document_types(self):
        records = self.env['ir.model'].search(['|', ('model', '=', 'sale.order'), '|', ('model', '=', 'account.invoice'), '|', ('model', '=', 'stock.picking'), ('model', '=', 'purchase.order')])
        return [(record.model, record.name) for record in records] + [('', '')]

In this example, we specified that we want to choose from [ Sale Order, Account Invoice, Stock Picking, Purchase Order ] models

Hope it was useful for you
Good luck !!

List Vs Tuple in python with Odoo

Hello everyone

In this article we will emphasize the difference in the use of tuple and list :

list gives you values between brackets “[]”. For example, when we do in odoo:

account_ids = self.env['account.account'].search([])
account_ids ---> [1, 4, 5, 8 , 9]

account_ids is a list of values

We can use this list:

* in loops:

for account_id in account_ids:
     move = self.env['account.account'].search([('account_id', '=', account_id)])

* to search in another table:

move = self.env['account.account'].search([('account_id', 'in', account_ids)])

* to change or search a specific value:

account_ids[2] -----> 5
account_ids[4] -----> 9
account_ids[0] = 10 -----> will replace the first value "1" by "10"

* change a tuple to a list:

 list(my_tuple)

tuple gives you values between parentheses “()”. we can use them in :

* change a tuple to a list:

account_ids = tuple(self.env['account.account'].search([])) 
account_ids ---> (1, 4, 5, 8 , 9)

* in loops:

for account_id in account_ids:
     move = self.env['account.account'].search([('account_id', '=', account_id)])

* to search in another table:

move = self.env['account.account'].search([('account_id', 'in', account_ids)])

* in SQL filter Query:

In SQL Query we should use a tuple of values and not a list

account_ids = tuple(self.env['account.account'].search([]))
cr.execute('SELECT * FROM account_move_line where account_id in %s,(account_ids))

Odoo V9 Community VS Enterprise

Hello everyone

This article will help you to understand the differences between Community  and Enterprise version.

let’s first recapitulate “what is odoo?” ( for more details, I advice you  to refer to the article ” what is Odoo ?”)

Odoo, known as OpenERP in the beginning,  is a suite of open-source enterprise management applications.

Odoo is used by large companies, small businesses, associations and many different types of organizations to help them manage, automate, measure and optimize their operations, finances and projects.

Odoo V6,7 and 8 had no technical or functional difference between Community and Enterprise versions. That, however, has changed with V9.

Before talking about the technical  differences between the two edition, let’s first discover some of the features of this two edition:

Odoo 9 Community:

  • Odoo Community Association (OCA)is a nonprofit organization whose mission is to promote the widespread use of Odoo and to support the collaborative development of Odoo features.
  • The Association provides financial, organizational and legal support to the broader Odoo Open Source community. It also serves as an independent legal entity to which community members can contribute to the code, funding and other resources with the knowledge that their contributions will be maintained for public benefit.
  • Odoo Software can be used, modified, distributed by anyone.
  • Odoo project is fully hosted on GitHub, access to anyone ( source code, bug reports, pull requests).

Odoo 9 Enterprise:

  • Proprietary license applies to Enterprise Apps only-Using requires Odoo Enterprise subscription

        – Modifications are allowed

        – Distribution only to Odoo Enterprise subscribers

  • Odoo project is fully hosted on GitHub, access to all partners (or some customers)

Context:

Copyleft relies on universal Copyright laws to enforce freedom for a piece of work. The Free Software Foundation defines four freedoms: use, modify, distribute, and distribute modifications. To guarantee these freedoms to every user, GPL forbids any restriction coming from other licenses.

From GPLv2 for TinyERP 1.0-4.0 to AGPLv3 for Odoo 8.0, Odoo software license is following up the changes of GPL, which is a strong copyleft license, but it suffers from the ASP loophole and lacks a linking exception. And AGPL v3 is not well suited for the CMS features. LGPL was created to fix this, by adding a linking exception on top of GPL.

Odoo 9 changes license to LGPL v3, becomes Odoo Community Edition, it will pemit selling Odoo Apps. Odoo Enterprises Edition will contain a set of new Apps on top of Odoo Community.

Core is absolutely the same in both versions.

community-vs-enterprise-odoo

 

To understand better, here’s an illustration that shows the differences between Community and Enterprise edition:

community-vs-enterprise-odoo-1

The whole database and back-end applications, without limitations, are in Odoo Community

    • Basic Functionality is in Odoo Community
    • + (additionally) Migration to the next version by Odoo SA engineers is in Odoo Enterprise
    • + (additionally) Several Functionalities are in Odoo Enterprise
    • + (additionally) Support of the non-customized Odoo Enterprise by Odoo SA Engineers
    • + (you can install any moment) Apps from Odoo Store

Technically, Odoo Enterprise is Odoo Community + Additional Functional Modules.

There’s a set of layer differences between the two edition, let’s discover them:

layer

  • Scalability: 

Following the Hardware abstract, Odoo can be scaled up for companies of almost any size. We did it for 2k+ and global companies with huge geographical distribution. Proper infrastructure provider selection, applications load balancing and database replication can do magic with this open source ERP.

  • Flexibility:

It is the most scalable business application in the world for two good reasons:

1. Open source
2. Modular structure: All functions can be customized via modules and database configuration.

If your company changes fast and experiments with processes, then Odoo should fit perfectly well.

  • Community and Enterprise App:

There are free (~90%) and paid (~10%) applications (modules) in the Odoo App store. Odoo Enterprise already includes additional unique modules that will move the ERP experience to the next level.

communityenterprise-app

  • Localizations:

Any localization can be installed as additional package on both versions. Around 50 localizations are available at this moment. The ones that are ready are for EU and US countries. Additional configuration for accounting and payroll modules is needed in most cases.

Bank integrations are available mainly for US banks and corresponding branches.

  • How functionally-rich the “out-of-the-box” system is:

As described earlier, all service-related processes are well supported in all Odoo versions: Community, Cloud and Enterprise. Companies in Software, Engineering, Service, Retail and Wholesale Industries with less than 15 employees can select any version. Any one of them would perform great with a little amount of customization.

Odoo Enterprise is the most preferred choice for middle enterprises of 50 to 300 employees. It contains modules that dramatically improve company performance. It has intuitive and clear UI that increases system adoption. The Enterprise version is more ready to be used out of the box from this point of view .

  • Access rights:

There are no differences here. Both versions have generic access rights with rules that are good enough for small and medium companies. However, for companies with complex organizational structure, basic access rights functionality is not enough. They should be ready for additional configurations.

  • User interface:

The most obvious difference between the two versions is the new UI of Odoo Enterprise. Odoo adopted the latest Google, mobile and web UI / UX trends to meet the high expectations of modern users. If your colleagues are using modern applications a lot, then they should feel very comfortable with Odoo Enterprise interface.

Odoo9EnterpriseHome

Each module is accessed as a separate application through the single dashboard. And each module provides access to one ERP application, which automates a particular business process. Under the “Contacts” icon you’ll see all your prospects, customers, and partners. Website app allows you to build your own website without coding. Odoo Enterprise interacts with a customer on intuitive level and familiarity with the ERP happens organically.

The new UI is built in a responsive design so that it’s interface can readily adapt to the resolution and orientation of your tablet or smartphone.

The Community edition inherited the classic corporate design from previous versions of Odoo. It has standard left column navigation structure and typical list and form views.

  • Price:

The Community version is open source and has no license costs. So you can use Odoo as is or customized by system integrator without support of the vendor, next updates, and additional improved apps for free. It’s a good choice for a small company that doesn’t need additional services and complex customizations.

The cost of the Enterprise version is 20EUR/user/month. For this price, a customer gets all additional apps + vendor support + future updates (Odoo 10+, for example).

There’s also a new additional features that has to deal with modules, let’s check them out:

  • New Features for Planning Projects and Resources – Community & Enterprise 

New Drags and Drop Gantt-Charts further facilitate the planning of resources and projects

  • New Accounting Features – Enterprise

The Enterprise Version also sports several new features for financial accounting. The extensive additions include automatic bank synchronization with more than 24.000 banks and SEPA payments.

  • Phone Connection via VoIP – Enterprise

-Planned and rescheduled calls

-Dial queue

-Calls on follow-up

-Auto Pop-up

  • New WYSIWYG Editor – Community & Enterprise

-Possibilty to distribute mass mails with pre-designed templates

-Possibility of A/B Tests

-New templates and themes for building your own website

-Multi-Website support

-Complete integration of front and back end

A complete introduction is available under the following link: https://www.odoo.com/fr_FR/slides/slide/keynote-odoo-9-new-features-201.

 

 

 

what is Odoo ?

Hello everyone

Today’s article will be about “what is Odoo ?”, so you’ll get the chance to discover Odoo: its definition and its release history.

Overview about Odoo:

Odoo, formerly known as OpenERP, is a suite of enterprise management applications. Targeting companies of all sizes.

The application suite cover all the company’s needs:  CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

It is 100 % modular application, so when Odoo is first installed there are ZERO modules installed with it, so you are able to only install the modules you need.

Odoo includes the following modules that may be installed with a simple mouse click:

– Accounting
– Customer Relationship Management (CRM)
– Warehouse Management
– Manufacturing Resource Planning (MRP)
– Purchase Management
– Project/Service Management
– Human Resource Management (HRM)
– Content Management (CMS)
– Document Management
– Fleet Management
– Point of Sale (POS)
– Application Builder

modules-odoo

  • Odoo offers a simple and rapid solution for all users, it allows you to customize or modify your modules.
  • Odoo is writing in Python, JavaScript and XML.
  • Odoo is compatible with: Linux, Unix-Like, OS X and Windows

Release history:

release-history

NB: Odoo have released software as open source but starting at the V9.0 release, the company of Odoo has transitioned to an open core model which provides subscription-based proprietary Enterprise software and cloud-hosted Software as a service, and a cut-down community version.

Software license:

  • GNU General Public License (GNU GPL):  is a widely used free software license, which guarantees end users the freedom to run, study, share and modify the software.
  • GNU Affero General Public License ( GNU AGPL): is a free, copyleft license published by the Free Software Foundation in November 2007, and based on the GNU General Public License, version 3 and the Affero General Public License.

The Free Software Foundation has recommended that the GNU AGPLv3 be considered for any software that will commonly be run over a network.

  • GNU Lesser General Public License (GNU LGPL): is a free software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate software released under the LGPL into their own (even proprietary) software without being required by the terms of a strong copyleft license to release the source code of their own components.


Debug Odoo 10.0 using Pycharm in Windows

Hello everyone
This article well help you step by step to debug odoo-10.0 in Windows using PycharmProjects.

For the environment, I am using Windows 7 and Pycharm, version 2016.3 in 64 bit

This article is divided into three parts:
Part 1: describes how to install required packages and source code
Part 2: show how to configure PostgresSQL and Odoo
Part 3: gives you the solution of some errors occurred while my installation process

 

I.Install required packages and source code:

1.1-Install Pycharm:

https://www.jetbrains.com/pycharm/download/#section=windows

1.2-Install Python 2.7:

https://www.python.org/ftp/python/2.7.12/python-2.7.12.amd64.msi

1.3-Install odoo 10:

First, go to:

  https://github.com/odoo/odoo/archive/10.0.zip 

to download the field “odoo-10.zip”, after that extract the content of “odoo-10.zip”.

1.4- Run Pycharm, and open the odoo-10 ( folder extracted earlier )

 

odoo-server-in-PyCharm-Project

1.5-Install Microsoft Visual C++ Compiler for Python 2.7 if you don’t have one:

https://www.microsoft.com/en-us/download/details.aspx?id=44266

1.6-Install required packages:

For this step you could either:

Install the requirements.txt once you open PycharmProjects, it will appear a message asking you to install “requirements.txt

Go to “cmd” command line and execute these commands:

> cd C:\ python27 (here you specify the location of your field “python27”)
> python -m pip install -r C:\Users\PycharmProjects\Odoo-10.0\requirements.txt  (here you specify the location of your field “Odoo-10.0”)

NB: some of this required packages will not be installed, to do so I ask you to refer to the part 3 of this article.

1.7-Install pywin32 (This installation is optional) :

While installing the required packages missing, you may have some errors dealing with pywin32. So all you need to do is to install it:

link to the pywin32.exe

1.8-Install pip:

-Go to:

https://pip.pypa.io/en/latest/installing/

download get-pip.py

-Go to “cmd” command line and execute these commands:

> cd C:\python27(here you specify the location of your folder “python27”)
> Python get-pip.py

II.Install PostgreSQL and configure Odoo:

2.1- install and download PostgresSQL for Windows:

Download PostgreSQL from official website

NB : You should remember the password of “postgres” role that you set when installing PostgreSQL.you will need it in the next step.

2.2- Create a new role with superuser privilege for Odoo application:

In my case, I create a superuser “lenovo” and set its password as “lenovo”.
To do so, Go to “cmd” command line and execute these commands:

> cd "C:\Program Files\PostgreSQL\9.4\bin"
> createuser.exe --createdb --username postgres --no-createrole --pwprompt lenovo

2.3- configure Odoo:

To configure Odoo, you can refer to the file odoo-server.conf:

This is the password that allows database operations:

; admin_passwd = admin
db_host = localhost
db_port = 5432
db_user = lenovo
db_password =lenovo
addons_path = C:\Users\PycharmProjects\odoo10\addons

If you want to change your port, you can add this line to that file: xmlrpc_port = 8070

III.Errors and solutions:

3.1-You may have an error telling that you don’t have “Setuptools”, so you can install it.

To do so, go to “cmd” command line and execute these commands:

> cd C:\python27
> python -m pip install --upgrade setuptools

3.2- Install wheel & lxml-3.6.4-cp27-cp27m-win32.whl:

Go to “cmd” command line and execute these commands:

> cd C:\python27
> python -m pip install wheel

To install lxml-3.6.4-cp27-cp27m-win32.whl, go here

Then, go to “cmd” command line and execute this commands:

> cd C:\python27
> python -m pip install lxml-3.6.4-cp27-cp27m-win32.wh

(here you should choose the file that go with your environment)

3.3- Install ebaysdk:

Go to:
 https://pypi.python.org/pypi/ofxparse

(here you should choose the file that go with your environment)

Then, go to “cmd” command line and execute these commands:

> cd C:\python27
> python -m pip install "C:\path to\tar\ofxparse-0.15.tar.gz "

3.4- Install psycopg2 .exe:

http://www.stickpeople.com/projects/python/win-psycopg/

3.5- once you launch your odoo server using your navigator: localhost: 8069, you may have this error: « could not execute command lessc »

to resolve that problem, you follow those steps:

  • – Install nodejs : https://nodejs.org/en/
  • – go to “cmd” command line and execute this commands:
> cd C:\Program Files\nodejs (here you specify the location of your field “nosejs”) 
> npm install -g less less-plugin-clean-css

3.6- how to use wkhtmltopdf to print a PDF:

  • -Install wkhtmltopdf : http://wkhtmltopdf.org/downloads.html  (Windows (MSVC 2013))
  • -In system variable on windows add in PATH: C:\Program Files\wkhtmltopdf\bin
  • -Restart the OS(systeme windows)


Install Odoo 9 on Ubuntu 14.04

Hello everyone

Thanks to a script writing by André Schenkels, you can install Odoo 9 on Ubuntu easily just by runing the script and following the steps.

NB: You can create/run the script from any place/directory you want, for example right under /opt/

Open up an Ubuntu terminal and #sudo cd to the directory where you’d like to keep and run the script. for /opt case, we will do :

#sudo cd /opt

Then we create the file odoo_install.sh

#sudo nano odoo_install.sh

Next fill the file with this content :

#!/bin/bash
################################################################################
# Script for Installation: ODOO 9.0 Community server on Ubuntu 14.04 LTS
# Author: André Schenkels, ICTSTUDIO 2015
#-------------------------------------------------------------------------------
#
# This script will install ODOO Server on
# clean Ubuntu 14.04 Server
#-------------------------------------------------------------------------------
# USAGE:
#
# odoo-install
#
# EXAMPLE:
# ./odoo-install
#
################################################################################

OE_USER="odoo"
OE_HOME="/opt/$OE_USER"
OE_HOME_EXT="/opt/$OE_USER/$OE_USER-server"

#Enter version for checkout "9.0" for version 9.0,"8.0" for version 8.0, "7.0 (version 7), "master" for trunk
OE_VERSION="9.0"

#set the superadmin password
OE_SUPERADMIN="superadminpassword"
OE_CONFIG="$OE_USER-server"

#--------------------------------------------------
# Update Server
#--------------------------------------------------
echo -e "\n---- Update Server ----"
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y locales

#--------------------------------------------------
# Install PostgreSQL Server
#--------------------------------------------------
sudo export LANGUAGE=en_US.UTF-8
sudo export LANG=en_US.UTF-8
sudo export LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales

echo -e "\n---- Install PostgreSQL Server ----"
sudo apt-get install postgresql -y

echo -e "\n---- PostgreSQL $PG_VERSION Settings  ----"
sudo sed -i s/"#listen_addresses = 'localhost'"/"listen_addresses = '*'"/g /etc/postgresql/9.4/main/postgresql.conf

echo -e "\n---- Creating the ODOO PostgreSQL User  ----"
sudo su - postgres -c "createuser -s $OE_USER" 2> /dev/null || true

sudo service postgresql restart

#--------------------------------------------------
# System Settings
#--------------------------------------------------

echo -e "\n---- Create ODOO system user ----"
sudo adduser --system --quiet --shell=/bin/bash --home=$OE_HOME --gecos 'ODOO' --group $OE_USER

echo -e "\n---- Create Log directory ----"
sudo mkdir /var/log/$OE_USER
sudo chown $OE_USER:$OE_USER /var/log/$OE_USER

#--------------------------------------------------
# Install Basic Dependencies
#--------------------------------------------------
echo -e "\n---- Install tool packages ----"
sudo apt-get install wget git python-pip python-imaging python-setuptools python-dev libxslt-dev libxml2-dev libldap2-dev libsasl2-dev node-less postgresql-server-dev-all -y

echo -e "\n---- Install wkhtml and place on correct place for ODOO 8 ----"
sudo wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo apt-get install -f -y
sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin
sudo cp /usr/local/bin/wkhtmltoimage /usr/bin

#--------------------------------------------------
# Install ODOO
#--------------------------------------------------

echo -e "\n==== Download ODOO Server ===="
cd $OE_HOME
sudo su $OE_USER -c "git clone --depth 1 --single-branch --branch $OE_VERSION https://www.github.com/odoo/odoo $OE_HOME_EXT/"
cd -

echo -e "\n---- Create custom module directory ----"
sudo su $OE_USER -c "mkdir $OE_HOME/custom"
sudo su $OE_USER -c "mkdir $OE_HOME/custom/addons"

echo -e "\n---- Setting permissions on home folder ----"
sudo chown -R $OE_USER:$OE_USER $OE_HOME/*

#--------------------------------------------------
# Install Dependencies
#--------------------------------------------------
echo -e "\n---- Install tool packages ----"
sudo pip install -r $OE_HOME_EXT/requirements.txt

#echo -e "\n---- Install python packages ----"
sudo easy_install pyPdf vatnumber pydot psycogreen suds ofxparse


#--------------------------------------------------
# Configure ODOO
#--------------------------------------------------
echo -e "* Create server config file"
sudo cp $OE_HOME_EXT/debian/openerp-server.conf /etc/$OE_CONFIG.conf
sudo chown $OE_USER:$OE_USER /etc/$OE_CONFIG.conf
sudo chmod 640 /etc/$OE_CONFIG.conf

echo -e "* Change server config file"
echo -e "** Remove unwanted lines"
sudo sed -i "/db_user/d" /etc/$OE_CONFIG.conf
sudo sed -i "/admin_passwd/d" /etc/$OE_CONFIG.conf
sudo sed -i "/addons_path/d" /etc/$OE_CONFIG.conf

echo -e "** Add correct lines"
sudo su root -c "echo 'db_user = $OE_USER' >> /etc/$OE_CONFIG.conf"
sudo su root -c "echo 'admin_passwd = $OE_SUPERADMIN' >> /etc/$OE_CONFIG.conf"
sudo su root -c "echo 'logfile = /var/log/$OE_USER/$OE_CONFIG$1.log' >> /etc/$OE_CONFIG.conf"
sudo su root -c "echo 'addons_path=$OE_HOME_EXT/addons,$OE_HOME/custom/addons' >> /etc/$OE_CONFIG.conf"

echo -e "* Create startup file"
sudo su root -c "echo '#!/bin/sh' >> $OE_HOME_EXT/start.sh"
sudo su root -c "echo 'sudo -u $OE_USER $OE_HOME_EXT/openerp-server --config=/etc/$OE_CONFIG.conf' >> $OE_HOME_EXT/start.sh"
sudo chmod 755 $OE_HOME_EXT/start.sh

#--------------------------------------------------
# Adding ODOO as a deamon (initscript)
#--------------------------------------------------

echo -e "* Create init file"
echo '#!/bin/sh' >> ~/$OE_CONFIG
echo '### BEGIN INIT INFO' >> ~/$OE_CONFIG
echo "# Provides: $OE_CONFIG" >> ~/$OE_CONFIG
echo '# Required-Start: $remote_fs $syslog' >> ~/$OE_CONFIG
echo '# Required-Stop: $remote_fs $syslog' >> ~/$OE_CONFIG
echo '# Should-Start: $network' >> ~/$OE_CONFIG
echo '# Should-Stop: $network' >> ~/$OE_CONFIG
echo '# Default-Start: 2 3 4 5' >> ~/$OE_CONFIG
echo '# Default-Stop: 0 1 6' >> ~/$OE_CONFIG
echo '# Short-Description: Enterprise Business Applications' >> ~/$OE_CONFIG
echo '# Description: ODOO Business Applications' >> ~/$OE_CONFIG
echo '### END INIT INFO' >> ~/$OE_CONFIG
echo 'PATH=/bin:/sbin:/usr/bin' >> ~/$OE_CONFIG
echo "DAEMON=$OE_HOME_EXT/openerp-server" >> ~/$OE_CONFIG
echo "NAME=$OE_CONFIG" >> ~/$OE_CONFIG
echo "DESC=$OE_CONFIG" >> ~/$OE_CONFIG
echo '' >> ~/$OE_CONFIG
echo '# Specify the user name (Default: odoo).' >> ~/$OE_CONFIG
echo "USER=$OE_USER" >> ~/$OE_CONFIG
echo '' >> ~/$OE_CONFIG
echo '# Specify an alternate config file (Default: /etc/openerp-server.conf).' >> ~/$OE_CONFIG
echo "CONFIGFILE=\"/etc/$OE_CONFIG.conf\"" >> ~/$OE_CONFIG
echo '' >> ~/$OE_CONFIG
echo '# pidfile' >> ~/$OE_CONFIG
echo 'PIDFILE=/var/run/$NAME.pid' >> ~/$OE_CONFIG
echo '' >> ~/$OE_CONFIG
echo '# Additional options that are passed to the Daemon.' >> ~/$OE_CONFIG
echo 'DAEMON_OPTS="-c $CONFIGFILE"' >> ~/$OE_CONFIG
echo '[ -x $DAEMON ] || exit 0' >> ~/$OE_CONFIG
echo '[ -f $CONFIGFILE ] || exit 0' >> ~/$OE_CONFIG
echo 'checkpid() {' >> ~/$OE_CONFIG
echo '[ -f $PIDFILE ] || return 1' >> ~/$OE_CONFIG
echo 'pid=`cat $PIDFILE`' >> ~/$OE_CONFIG
echo '[ -d /proc/$pid ] && return 0' >> ~/$OE_CONFIG
echo 'return 1' >> ~/$OE_CONFIG
echo '}' >> ~/$OE_CONFIG
echo '' >> ~/$OE_CONFIG
echo 'case "${1}" in' >> ~/$OE_CONFIG
echo 'start)' >> ~/$OE_CONFIG
echo 'echo -n "Starting ${DESC}: "' >> ~/$OE_CONFIG
echo 'start-stop-daemon --start --quiet --pidfile ${PIDFILE} \' >> ~/$OE_CONFIG
echo '--chuid ${USER} --background --make-pidfile \' >> ~/$OE_CONFIG
echo '--exec ${DAEMON} -- ${DAEMON_OPTS}' >> ~/$OE_CONFIG
echo 'echo "${NAME}."' >> ~/$OE_CONFIG
echo ';;' >> ~/$OE_CONFIG
echo 'stop)' >> ~/$OE_CONFIG
echo 'echo -n "Stopping ${DESC}: "' >> ~/$OE_CONFIG
echo 'start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \' >> ~/$OE_CONFIG
echo '--oknodo' >> ~/$OE_CONFIG
echo 'echo "${NAME}."' >> ~/$OE_CONFIG
echo ';;' >> ~/$OE_CONFIG
echo '' >> ~/$OE_CONFIG
echo 'restart|force-reload)' >> ~/$OE_CONFIG
echo 'echo -n "Restarting ${DESC}: "' >> ~/$OE_CONFIG
echo 'start-stop-daemon --stop --quiet --pidfile ${PIDFILE} \' >> ~/$OE_CONFIG
echo '--oknodo' >> ~/$OE_CONFIG
echo 'sleep 1' >> ~/$OE_CONFIG
echo 'start-stop-daemon --start --quiet --pidfile ${PIDFILE} \' >> ~/$OE_CONFIG
echo '--chuid ${USER} --background --make-pidfile \' >> ~/$OE_CONFIG
echo '--exec ${DAEMON} -- ${DAEMON_OPTS}' >> ~/$OE_CONFIG
echo 'echo "${NAME}."' >> ~/$OE_CONFIG
echo ';;' >> ~/$OE_CONFIG
echo '*)' >> ~/$OE_CONFIG
echo 'N=/etc/init.d/${NAME}' >> ~/$OE_CONFIG
echo 'echo "Usage: ${NAME} {start|stop|restart|force-reload}" >&2' >> ~/$OE_CONFIG
echo 'exit 1' >> ~/$OE_CONFIG
echo ';;' >> ~/$OE_CONFIG
echo '' >> ~/$OE_CONFIG
echo 'esac' >> ~/$OE_CONFIG
echo 'exit 0' >> ~/$OE_CONFIG

echo -e "* Security Init File"
sudo mv ~/$OE_CONFIG /etc/init.d/$OE_CONFIG
sudo chmod 755 /etc/init.d/$OE_CONFIG
sudo chown root: /etc/init.d/$OE_CONFIG

echo -e "* Start ODOO on Startup"
sudo update-rc.d $OE_CONFIG defaults

sudo service $OE_CONFIG start
echo "Done! The ODOO server can be started with: service $OE_CONFIG start"


When running this script, you will be asked to configure somethings.

For safety, make sure to change the Odoo super administrator password.

The next step is to make this file executable, to be able to execute it and everything will be installed automatically. To do this use :

#sudo chmod +x odoo_install.sh

And now you should execute the script by using:

./odoo_install.sh


Odoo will be installed automatically!

Important : Give this a while since it will need to download all dependencies, download Odoo and install it.

Browse to http://localhost:8069/ and you’ll see this screen:

Odoo 9

Congratulation ! you have finished 🙂

Debug Odoo 9 & 8 using Eclipse IDE

Hello everyone
We will show you in this tutorial, how to debug Odoo V9 / V8 from Eclipse IDE ( step by step ). We will be working on Ubuntu  14.04 for stability reasons, but you can use any other version.

Update the system and install necessary packages for Odoo :

First thing to do is to update your system, which let you get the newest versions of packages and their dependencies existing on your machine.

#sudo apt-get update
#sudo apt-get upgrade

aptget upgrade

aptget update

Then we should install the Prerequisites packages for Odoo :

#sudo apt-get install python-cups python-dateutil python-decorator python-docutils python-feedparser python-gdata python-geoip python-gevent python-imaging python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid python-passlib python-psutil python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-pypdf python-reportlab python-requests python-simplejson python-tz python-unicodecsv python-unittest2 python-vatnumber python-vobject python-werkzeug python-xlwt python-yaml wkhtmltopdf

To install wkhtmltopdf (a package that let you print reports in Odoo 8 & 9), you should run this commands :

#sudo wget http://download.gna.org/wkhtmltopdf/0.12/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

For Ubuntu 14.04 users, you should install “python-passlib” package, to avoid “error 500 Internal Server” Error :

#sudo apt-get install python-passlib

Setup Eclipse :

Very Important : For me I used LiClipse is a very featured Eclipse (Provides a number of enhancements) for Linux with PyDev (Python) support, To install/run it : (A big thanks to arulmr)

LiClipse is the lightweight version of the most popular Eclipse IDE and it includes PyDev and Egit by default which will help python/django developers

To install it follow my article Liclipse (Eclipse) Installation on Ubuntu

Once LiClipse installation is Done. We need to setup the GIT repository in order to download Odoo Source code. To do so, Click Windows -> Open Perspective -> Other

Eclipse 7

A Window will Open ask you to select a perspective. Click Git

Eclipse 8

 

In Next Windows Select “Clone a Git Repository

Eclipse 9

In th URI field type “https://github.com/odoo/odoo.git“ | In the Host field type “github.com“ | In the Repository path type “/odoo/odoo.git“. Click Next

Eclipse 10

You will be presented which Branches you want to clone, You can see all of the versions of Odoo. Select only 8.0 or 9.0 or which ever version you want.

In next windows Select the Directory where you want to clone the Source and Click Finish (We recommend Eclipse workspace  : /home/workspace/odoo). The Cloning Process will begin. This Process may Take a while depending on the speed of your Internet.

Now we need to Setup eclipse’s Perspective to work with Python. To do so click Window -> Open Perspective -> Other and from the Window Select Pydev and Click OK.

Eclipse 11

To setup the Interpreter for python, Click Windows -> Preference and In the Left Pane, Select Pydev and the Interpreter Python and then Click Auto-Config on the Right side, The System will automatically detect Your python version. Click OK to Close this Windows once eclipse is done setting up Environment.

Eclipse 13

To dispaly your code in Eclipse Click File -> Pydev Project.

In project name type odoo the name you like. uncheck Use Default and click Browse and select the source directory (The directory that you specified earlier, where cloning the source. As an example we used /home/workspace/odoo ) and click Finish.

We Finished with setting up Eclipse for Odoo use.

Setting up Odoo Configuration File

You can create your own config file for Odoo like this one :

#sudo nano /etc/openerp-server.conf

Copy this content in the file :

[options]
; This is the password that allows database operations:
; admin_passwd = admin
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /home/workspace/odoo/addons

( In addons_path you should use your own addons directory )

ctrl + o to save the file and ctrl + x to exit nano

To take this file in consideration go to the “Running the Code of Odoo from Eclipse” step.

Configure PostgreSQL server

Now we need to create a role in PostgreSql for the user that will be Running Eclipse.

Usually we use our current user

#sudo su postgres
#psql -t template1
#template1=# create user usmanbek with superuser password 'postgres';
#template1=# \q

Running the Code of Odoo from Eclipse

To take the openerp-server.conf file in consideration, you should go to Eclipse openerp-server -> Run As -> Run Configuration.

config 1

In the argument tab click on Variables.

config 2

A select variable box appears. Click on Edit Variables.

config 3

A preferences box appears. Click on New.

config4

A new box appears. Put whatever you want in “Name” field, Ex: Config file | In the “Value” field put : –config=/etc/openerp-server.conf

config5

Choose the variable you have just created (for my case it’s Config file) and Click Ok

config 6

Finally you click on Run 🙂

Now to access the Webclient, type localhost:8069. You will see this page.

odoo running

Congratulation, now you can develop Odoo modules easily