Revoke Public Access on Database

baharali@baharali-HP-ProBook-430-G3:~$ sudo su postgres
postgres@baharali-HP-ProBook-430-G3:/home/baharali$ psql -t template1
psql (9.5.5)
Type “help” for help.

template1=# REVOKE connect ON DATABASE lays FROM public;


Accounting & Sale Settings in Odoo

Inventory -> Products -> General Information:

Product Type: Stockable Product
Sale Price: 100
Cost Price: 90

Inventory -> Products -> Accounting:
Income Account: Product Sales
Expense Account: Expense/ Cost of Revenue

Inventory -> Products -> Product Categories:

Account Properties:
Income Account: Product Sales
Expense Account: Expense/ Cost of Revenue

Account Stock Properties:
Stock Input Account: 101120 Stock Interim Account (Received)
Stock Output Account: 101130 Stock Interim Account (Delivered)
Stock Valuation Account: 101110 Stock Valuation Account
Stock Journal: Stock Journal (USD)

Inventory Valuation:
Inventory Valuation: Perpetual (automated)

How to Add cron job and how to send an email, when cron job is successfully configured

Step 1: For email sending
sudo apt-get install mutt

Step 2: To update Crontab
sudo crontab -e (Note: This will open crobtab of root user)

1. /bin/ed
2. /bin/nano <—- easiest
3. /usr/bin/vim.tiny

Select your editor.
(Note: To update editor later, used command; sudo select-editor)

Add these lines in crontab file
First line is just dumping while
Second other is dumping & mailing….

# m h dom mon dow command
43 15 * * * PGUSER=postgres && PGPASSWORD=postgres && export PGUSER && export PGPASSWORD && pg_dump -h localhost -p 5432 –format custom –blobs cms -f /media/backups/db-backup-“$(date +\%d-\%m-\%Y)”

53 12 * * * 1-5 PGUSER=postgres && PGPASSWORD=postgres && export PGUSER && export PGPASSWORD && pg_dump -h localhost -p 5432 –format custom –blobs cms -f /media/backups/ERP-Backups/db-backup-`date ‘+\%d-\%m-\%y-\%T’` && mutt -s “Database Backup” — < /etc/backupmail # JOB_ID_1

Step 3: Restart crob job service.
sudo service cron restart

For /media/backups/ERP-Backups/
baharali@baharali:~$ cd /media/
baharali@baharali:/media$ mkdir backups

baharali@baharali:/media$ sudo fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe99f0667

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 206847 102400 7 HPFS/NTFS/exFAT
/dev/sda2 206848 204802047 102297600 7 HPFS/NTFS/exFAT
/dev/sda3 204804094 512002047 153598977 5 Extended
/dev/sda4 512002048 976771071 232384512 7 HPFS/NTFS/exFAT
/dev/sda5 204804096 237029375 16112640 82 Linux swap / Solaris
/dev/sda6 237031424 512002047 137485312 83 Linux

baharali@baharali:/media$ sudo mount /dev/sda4 /media/backups
Mount /media/backups on each restart
Step 1: Open mtab
sudo vi /etc/mtab

Step 2: Copy this line
/dev/sda4 /media/backups fuseblk rw,nosuid,nodev,allow_other,blksize=4096 0 0

Step 3: Open fstabl
sudo vi /etc/fstab

Step 3: Add line
/dev/sda4 /media/backups fuseblk rw,nosuid,nodev,allow_other,blksize=4096 0 0

You have done.

Insatlling OpenERP 7.0 on Ubuntu 12.04

Step 1. Update

sudo apt-get update
sudo apt-get dist-upgrade

Step 2. Install and configure the database server, PostgreSQL

sudo apt-get install postgresql
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp

Enter New passowrd 4 username in postgres.

sudo passwd postgres // if you don't remember password then first change password...

/var/lib/$ su - postgres
/var/lib/$ psql -d postgres
postgres=# CREATE USER baharali with PASSWORD 'baharal' VALID UNTIL '2011-01-01' CREATEDB;

You exit the connection with:::: \q

Step 3. Install the necessary Python libraries for the server

sudo apt-get install python-docutils
sudo apt-get install python-gdata
sudo apt-get install python-mako
sudo apt-get install python-dateutil
sudo apt-get install python-feedparser
sudo apt-get install python-lxml
sudo apt-get install python-libxslt1
sudo apt-get install python-ldap
sudo apt-get install python-reportlab
sudo apt-get install python-pybabel
sudo apt-get install python-pychart
sudo apt-get install python-openid
sudo apt-get install python-simplejson
sudo apt-get install python-psycopg2
sudo apt-get install python-vobject
sudo apt-get install python-tz
sudo apt-get install python-vatnumber
sudo apt-get install python-webdav
sudo apt-get install python-xlwt
sudo apt-get install python-werkzeug
sudo apt-get install python-yaml
sudo apt-get install python-zsi
sudo apt-get install python-psutil
sudo apt-get install python-pydot
sudo apt-get install python-pyparsing
sudo apt-get install python-unittest2
sudo apt-get install python-jinja2
sudo apt-get install python-mock

Step 4. Install the OpenERP server


Now install the code where we need it: cd to the /opt/openerp directory and extract the tarball there.

cd /opt/openerp
sudo tar xvf ~/openerp-7.0-latest.tar.gz

Next we need to change the ownership of all the the files to the OpenERP user and group we created earlier.

sudo chown -R openerp: *

Step 5. Configuring the OpenERP application

sudo cp /home/baharali/openerp/install/openerp-server.conf /etc/
sudo chown openerp: /etc/openerp-server.conf
sudo chmod 640 /etc/openerp-server.conf
sudo nano /etc/openerp-server.conf

One other line we might as well add to the configuration file now, is to tell OpenERP where to write its log file. To complement my suggested location below add the following line to the openerp-server.conf file:

logfile = /var/log/openerp/openerp-server.log

Once the configuration file is edited and saved, you can start the server just to check if it actually runs.


Step 6. Installing the boot script

sudo cp /home/baharali/openerp/install/openerp-server.init /etc/init.d/openerp-server
sudo chmod 755 /etc/init.d/openerp-server
sudo chown root: /etc/init.d/openerp-server

In the configuration file there’s an entry for the server’s log file. We need to create that directory first so that the server has somewhere to log to and also we must make it writeable by the openerp user:

sudo mkdir /var/log/openerp
sudo chown openerp:root /var/log/openerp

Create Log file

touch /var/log/openerp/openerp-server.log

Step 7. Testing the server
To start the OpenERP server type:

sudo /etc/init.d/openerp-server start

You should now be able to view the logfile and see that the server has started.

less /var/log/openerp/openerp-server.log

Now it’s time to make sure the server stops properly too:

sudo /etc/init.d/openerp-server stop

Step Note.
Run this command

/home/baharali/openerp/openerp-server -s

This will save configuration to file ~/.openerp_serverrc

go to

gedit ~/.openerp_serverrc

Now Make sure db_port is Ok.

For a many2many field, a list of tuples is expected. Here is the list of tuple that are accepted, with the corresponding semantics

(0, 0, { values }) link to a new record that needs to be created with the given values dictionary

(1, ID, { values }) update the linked record with id = ID (write values on it)

(2, ID) remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)

(3, ID) cut the link to the linked record with id = ID (delete the relationship between the two objects but does not delete the target object itself)

(4, ID) link to existing record with id = ID (adds a relationship)

(5) unlink all (like using (3,ID) for all linked records)

(6, 0, [IDs]) replace the list of linked IDs (like using (5) then (4,ID) for each ID in the list of IDs)

Android Source download Commands

mkdir ~/bin
curl > ~/bin/repo
sudo apt-get install curl
curl > ~/bin/repo
chmod a+x ~/bin/repo
mkdir android
cd android
repo init -u
git –version
repo init -u -b android-4.0.1_r1
repo sync