Wednesday, August 17, 2016

Install and configure Odoo 9 (community editon) on Ubuntu 15.10

1. installation:
   a. install Odoo

      $ sudo wget -O - | apt-key add -

      $ sudo echo "deb ./" >> /etc/apt/sources.list

      $ sudo apt-get update && apt-get install odoo

   b. install Postgresql

      $ sudo apt-get install postgresql
      $ sudo su - postgres  
      $ createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo 
      Enter password for new role: (you own password for postgres database user)
      Enter it again: (you own password for postgres database user again)  

   c. Configure Odoo

      $ sudo nano /etc/odoo/openerp-server.conf

; This is the password that allows database operations:
; admin_passwd = admin
#you need to change db host, port, user accordingly if you are using a seperate database server 
db_host = localhost
db_port = 5432
db_user = odoo
db_password = (you own password for postgres database user)
addons_path = /usr/lib/python2.7/dist-packages/openerp/addons
  d. install wkhtmltox-0.12.1. Per Odoo, only 0.12.1 version works at this point
      Go to and download 
   d. Start Odoo service

      $ sudo service odoo restart
you now should be able to access odoo using a browser and go to:

Tuesday, August 25, 2015

Understand leverage reset decay, 3X ETF decay

a picture is worth a thousand words, and I believe a chart or spreadsheet is much better than words too, check this first:

The first section assume the underline index changes 2% first day and -2% next day and repeat it for 20 days. If you put $100 at beginning, for 1X ETF, you will have $99.60 left, but for 3X ETF, you will have only $96.45, you lost $3, or 3% because of leverage reset decay.

Now let's check the 2nd scenario, for section 2, we assume the underline index changes 0.2% first day and -0.2% next day and repeat for 20 days, for 1X ETF you will have $99.996 left, for 3X ETF it is $99.964, you only lost 0.03% because of leverage reset decay.

What does this mean? This means if the underline index is running in a range and the change everyday is dramatic(high volatility), it is very risky to keep the 3X ETF for a long time. Compare the 2 sections and you find that if everyday's change is 10 times more, the decay is 100 times more. In real world, oil, natural gas and gold prices are changing in a wider range, that is why UGAZ/DGAZ, UWTI/DWTI, UVXY is similar to this, and you can see they loose value quickly. Take a look at the following chart for a better visual impression, if the underline index go up/down 2% every day for 60 trading days, which is about 3 months, the 3XETF lost 10% of value.

Let's move to the 3rd scenario, if the trend for underline index is going up, we can see using 3X ETF gains higher return than 1X ETF. What do all these mean? If you know the trend of an index, It's better to use 3XETF than 1XETF. If not, you better not touch 3XETF, and do not hold 3XETF for long time if the index is NOT moving on a trend!

Thursday, June 11, 2015

Regular Expression notes

I think I need to collect all my regular expression notes here to help myself and anyone who need it, I might not be smart enough to understand how it work thoroghly by just read tutorial, so I will collect all examples here to help:

1. Remove control characters and space (the red mark is a space) (oracle example):
select 'asdfo'||chr(9)||'dsu iue', regexp_replace('asdfo'||chr(9)||'dsu iue', '[[:cntrl:] ]','') from dual

2. The following will match utill second occurence, *? is lazy qualifier so it will stop when it find the next foo:
string: goo foo goo goo foo goo foo goo foo goo fo
3. The following will match utill last occurence, as we removed the lazy qualifier from #2, it will stop when it find the last foo: 
string: goo foo goo goo foo goo foo goo foo goo fo

Thursday, January 29, 2015

Put multiple images for a product in Odoo 8 ecommerce web page

I really like the idea that Odoo provide both a powerfull ERP solution as well as a quite functional ecommerce solution. However compare to other ecommerce solution Odoo is missing some functions, One concern is on Ebay, Amazon as well as many e-commerce websites, they use slides to show multiple pictures at the left-top section. But Odoo only allow one pictures. So I raised a question here: 
"Can an e-commerce pages show multiple pictures at the left top part of the page in V8?"

Luke Branch now provides a addon. (check It works great and I want to share how I install this addon with you. 

Here is how I install the addon, please be aware you configuration/odoo folders may be different, if you follow my post to install Odoo you should be able to follow this instruction without issue.  

First stop odoo server and run the following to get the custom module. 

sudo su - odoo -s /bin/bash
mkdir custom_modules
cd /opt/odoo/custom_modules/
git clone -b 8.0 
Now you have the file you need to Scaffolding this module. Still run as odoo user:
cd ..
./ scaffold website_multi_image addons
cp -R custom_modules/website_multi_image addons/.
At this point you need to start odoo server. Log into Odoo as admin, make sure "Technical Features" is turned on for admin, if not, go to Settings->Users, edit admin user by check "Technical Features" checkbox. 

No go to Settings->Modules->Update Modules List and click Update button. When finished, install "Product Multi-Image". 

Then you can go to Product configuration page -> product images and add more images for the product. 

Well here is how it looks like on website: 

And here is how it looks in product maintain page: 

Friday, January 9, 2015

Connect Oracle using ODBC 32 bit in 64 bit Windows 7

For some reason I need to build an ODBC connection to Oracle database, the Oracle database version is This turned out to be quite a big challenge. There are several issues during the installation, as usual, Oracle never make things easy. Anyway, here is how:

1. Download Instant Client basic 32 bit and ODBC 32 bit for from here.
2. Extract both zip files you downloaded, put the files in instantclient_11_2 folder into C:\instantclient_11_2\
3. Add C:\instantclient_11_2 into Windows Path
4. Run C:\instantclient_11_2\odbc_install.exe
    You may see a warning from Program Compatibility Assistant says: This program might not be installed correctly. Just ignore it.
5. Goto ODBC 32bit console, tt is not easy to find Windows ODBC 32 bit console, the fastest way is to run C:\Windows\SysWOW64\odbcad32.exe from Start->search
6. If you have ODBC 32bit console open, create a new ODBC connection using Oracle in instantclient_11_2. You will fill the TNS Service Name like this: //host_ip_or_url:port/instance_name.
6. At this point you can test the new ODBC connection, but mostly you will see this error:
    ORA-12705: Cannot access NLS data files or invalid environment specified
The solution was to find the registry key named NLS_LANG under:
and rename it to anything else. I put an "x" at the end. This key is left over from a full install of Oracle. The instant client ODBC works properly now.

Friday, January 2, 2015

Install Adobe Flash Player on Android 4.X

I just got a new Huawei Mate 7, a fantastic phone in my opinion. But I found now Android doesn't support Flash Player anymore, Photon browser can natively support Flash but the Ads is quite annoying. So I did some research and found a solution.

  1. Ensure that the Android device is connected to the Internet.
  2. Open the Settings menu.
  3. Select Security
  4. Select Unknown Sources.
  5. Tap OK to confirm your selection.
  6. Close Settings.
  7. Download flash player apk file here
  8. Open the apk file to install flash player. 
  9. Install Dolphin browser, you can find Dolphin browser from Play Store. I have tried different browsers, no luck with Chrome or Firefox. You may have better luck though. 
Thats it, I don't think you need to change any setting for Dolphin browser.

Wednesday, December 31, 2014

How to access the database management web interfaces in odoo v8

Just use this url and access Odoo database management online interfaces

As you access the web interface, you can create, dulplicate, drop, backup or restore databases there. 

Monday, July 14, 2014

Config postgresql to use pgAdmin from remote client

When I complete Odoo installation, I want to use pgAdminIII to connect to the database from a client computer, I encountered this error:

could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" ( and accepting
TCP/IP connections on port 5432?

To fix the issue, First:

sudo vi /etc/postgresql/9.1/main/postgresql.conf 

You need to add the following line in the config files, this change will not open your server to any computer though, you have opportunity to define which client(s) can access server later.

listen_addresses = '*'

Then: you will define which client(s) can access server here:

sudo vi /etc/postgresql/9.1/main/pg_hba.conf

Add the following line in the config files, in this case is the client computer.

host   all             all             md5

Now you can use pgAdminIII from a client computer to access the database.

Thursday, July 3, 2014

Import and Export in Odoo V8

In order to be able to export/import we have to go to Settings->Configuration->General settings. check the box "Allow users to import data from CSV files" and apply the change.

Now let's see an example of import/export a product:

Go to any products view and change it to "list view", for some reason Kanban View and Form View do not have import/export as an option.

You will only see "Import" in "list view" if you don't choose any product. For export, first choose some or all products by choose the check box(s) in left, then click "more" button on top of the view, choose "Export" from there.

After click Export, set export type to be "import-compatible Export", choose Export Formats as "CSV".

My suggestion: It's better you check the export file to make sure your import file is based on the columns you need):

To use import to create a new record: 
Although your first field will always be ID, be sure to leave that empty when you are importing so ERP will assign IDs to your items instead of using your items to overwrite the fields on existing items.
when you choose your file to improt be sure to click "file format options", if the encoding is UTF-8 change it to latin1 so it can accept a wider variety of characters like the degree symbol and the like.

So how to load a new product that has multiple variants and variants values? Here is an example(copy those in blue and open as csv file to see better format):

Products / External_id,cost_method,categ_id/id,valuation,name,type,Products / Product Attributs / Attribute,Products / Product Attributs / Product Attribute Value,uom_po_id/id,uom_id/id
,Standard Price,product.ipad,Periodical (manual),iPad Retina Display Duplicate3,Stockable Product,Memory,"16 Go,32 Go",product.product_uom_unit,product.product_uom_unit
,,,,,,Wi-Fi,2.4 GHz,,

I will explain the structure of this a little bit:
Products / External_id will be empty for new product
Products / Product Attributs / Attribute is for attribute
Products / Product Attributs / Product Attribute Value: You can put multiple values there, but when you do that, using comma(,) to seperate values. e.g. "16 Go,32 Go". Odoo will not create new attribute values when import product, you only can put the value existing in Odoo.

Even though it has multiple records for one product, Odoo know how to deal with it. Be sure only the first line has product's other information, and Odoo know the following lines is for the product of first line. And be sure to define the right column mapping information when load the variants' attributes and attributes values.

To use import to update a record: 
The only difference is you need to add a reference so Odoo know that is to update a record, not create a new record. My suggestion is use id from the export to identify the records you need to import, be aware that id is called External_id when you import.