Monday, June 30, 2014

How to disassemble a product in Odoo/OpenErp 8

Our company sells clothes. We wholesale the clothes by box or dozen, a dozen normally has different sizes but one color, and a box has many dozens of different colors. I have created a product (Say Product1) with size and color variants. Now I wonder if I can create 2 new products, 1st is "Dozen of Product1" which includes 12 of Product1 of different sizes, and 2nd is "Box of Product1" with many of "Dozen of Product1". We are only reseller, not manufacturer. 

We need to handle that with the BoM function as we are packing/assembling into a Dozen. Create the individual products 1, 2,3..with the color and sizes. Then create the BOM. Manufacturing order will allow you pack the boxes and store them as complete dozens in the warehouse. This way you can monitor the individual products themselves and dozen packs as well.

The second question is, we may need to open a box and sell them to different customers if needed. so that is, we receive our mechandise in boxes, then sale them in boxes or sale them in dozens, how do we handle these in Odoo? 

It can be done by install the mrp_byproducts module. Then you can define "Dozen of Product1" as component, Product1(small size) as the produced product, and Product1(other sizes) as byproducts. By doing this you actually disassemble the package. 

Install Openerp 8 (Odoo 8) on Ubuntu 12.04 or 14.04

Step 1. Create the OpenERP user that will own and run the application


First thing first, I run the following scripts as user=administrator, unless mentioned seperately. 
Also, there are some change so I have update my instruction for newer odoo 8 version. 

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

This is a “system” user. It is there to own and run the application, it isn’t supposed to be a person type user with a login etc. In Ubuntu, a system user gets a UID below 1000, has no shell (it’s actually /bin/false) and has logins disabled. Note that it isspecified a “home” of /opt/odoo, this is where the OpenERP server code will reside and is created automatically by the command above. The location of the server code is your choice of course, but be aware that some of the instructions and configuration files below may need to be altered if you decide to install to a different location.

[Note: If you want to run multiple versions of OpenERP on the same server, the way I do it is to create multiple users with the correct version number as part of the name, e.g. openerp70, openerp61 etc. If you also use this when creating the Postgres users too, you can have full separation of systems on the same server. I also use similarly named home directories, e.g. /opt/openerp70, /opt/openerp61 and config and start-up/shutdown files. You will also need to configure different ports for each instance or else only the first will start.]

how to run the OpenERP server as the openerp system user from the command line if it has no shell. This can be done quite easily:

sudo su - odoo -s /bin/bash

This will su your current terminal login to the openerp user (the “-” between su and openerp is correct) and use the shell /bin/bash. When this command is run you will be in openerp’s home directory: /opt/openerp.

When you have done what you need you can leave the openerp user’s shell by typing exit.

Step 2. Install and configure the database server, PostgreSQL

sudo apt-get install postgresql

Then configure the OpenERP user on postgres:
First change to the postgres user so we have the necessary privileges to configure the database.

sudo su - postgres

Now create a new database user. This is so OpenERP has access rights to connect to PostgreSQL and to create and drop databases. Remember what your choice of password is here; you will need it later on:

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:

Step 3. Install the OpenERP server

Now Odoo put the code on Github, so you need to install Github first:
sudo apt-get install git
Update apt source list
sudo apt-get update
Download and Install Updates
sudo apt-get upgrade

Install required and supporting packages for Odoo

sudo apt-get install graphviz ghostscript postgresql-client \
python-dateutil python-feedparser python-matplotlib \
python-ldap python-libxslt1 python-lxml python-mako \
python-openid python-psycopg2 python-pybabel python-pychart \
python-pydot python-pyparsing python-reportlab python-simplejson \
python-tz python-vatnumber python-vobject python-webdav \
python-werkzeug python-xlwt python-yaml python-imaging

sudo apt-get install gcc python-dev mc bzr python-setuptools python-babel \
python-feedparser python-reportlab-accel python-zsi python-openssl \
python-egenix-mxdatetime python-jinja2 python-unittest2 python-mock \
python-docutils lptools make python-psutil python-paramiko poppler-utils \
python-pdftools antiword postgresql

sudo apt-get install python-geoip python-requests python-decorator \
wkhtmltopdf python-passlib python-pip

sudo pip install wkhtmltopdf
sudo pip install pyPdf

Get / Install Odoo from Github to you system
sudo wget -O- | python
If this does not work, try the following,

Switch to the Odoo User;
sudo su - odoo -s /bin/bash
Grab a copy of the most current Odoo 8 branch (Note there is a “.” at the end of this command!):
git clone --depth 1 --branch 8.0 --single-branch .
(This might take a little while depending on the speed of your Internet connection.)
Once it’s finished exit from the odoo user:

Step 4. Test and configure the OpenERP server

I'd like to restart postgresql at this point, sometimes do not restart database may cause issue.
sudo service postgresql restart 

Now go to odoo folder where opeperp-server file resides. (This command may vary to your system, if you have specify different path for storing odoo project, I suggest to move the folder to /opt/odoo/ folder)

#this will change the user to odoo and change the directory to /opt/odoo
sudo su - odoo -s /bin/bash

Run server

When you see the following information that means your server is up and running now. Congratulation! I will discuss about setup postgres so can use pgAdmin to check database in later post. Here in this post I will discuss creating a script so can run openerp-server asa service.

2014-07-14 20:27:42,242 5826 INFO ? openerp: database hostname: localhost
2014-07-14 20:27:42,242 5826 INFO ? openerp: database port: 5432
2014-07-14 20:27:42,243 5826 INFO ? openerp: database user: odoo
2014-07-14 20:27:42,632 5826 INFO ? openerp.service.server: HTTP service (werkzeug) running on

Step 5. Setup the boot script and log file. 

You can check if Odoo is working by go to the webpage, the url should be host_ip_address:8069. But don't do anything even though you see the setup page. We want to setup the boot script (or service if you want to call it that way). Using ctrl+C to end openerp-server process, then make sure you are login as administrator.

sudo cp /opt/odoo/debian/init /etc/init.d/openerp-server
sudo cp /opt/odoo/debian/openerp-server.conf /etc/openerp-server.conf
sudo chmod 755 /etc/init.d/openerp-server
sudo chown root: /etc/init.d/openerp-server
sudo mkdir /var/log/openerp
sudo chown odoo:root /var/log/openerp

Now use vi or nano or whatever to update /etc/init.d/openerp-server, replace the first few rows to: 


And update the /etc/openerp-server.conf to the following:

; This is the password that allows database operations:
; admin_passwd = admin
db_host = localhost
db_port = 5432
db_user = odoo
db_password = odoo's password

addons_path = /opt/odoo/addons

 Now you should be able to run Odoo as a service:

sudo service openerp-server start
sudo service openerp-server stop

Well, this is it.

How to Delete a page in OpenERP (Odoo)

Per Odoo development team: Currently, the front-end does not provide a way to delete a page indeed. You have to go through the backend with a "technical features" enabled users.
Goto Settings >Technical>User Interface>Views.
Filter on "Whether this view is a web page template (complete)" (which should be a help message not a label, we'll have to fix that).

That will list all pages that you can alter or delete.
Goto the page detail view by click the View Name, click more and you can delete it.

Odoo team has marking this bug as a R&D wishlist item, because it would be a good idea to have a simpler way to remove pages, easily accessible to users who can create pages/