Wednesday, June 10, 2015

Django

How To Install the Django Web Framework on Ubuntu 14.04 :

    There are a number of different ways in which you can install Django depending upon your needs and how you want to configure your         development environment. These have different advantages and one method may lend itself better to your specific situation than others.

One of method is as -- Global Install from Packages :

    If you wish to install Django using the Ubuntu repositories, the process is very straight forward.

    First, update your local package index with apt, and then install the python-django package:

        1. sudo apt-get update

        2. sudo apt-get install python-django

    You can test that the installation was successful by typing:

        django-admin --version

    This means that the software was successfully installed. You may also notice that the Django version is not the latest stable.

Introduction :

    Django is a full-featured Python web framework for developing dynamic websites and applications. Using Django, you can quickly create         Python web applications and rely on the framework to do a good deal of the heavy lifting.


Wednesday, May 20, 2015

Odoo 8

In python fetach the text of DropDownlist :


service_type = dict(self._columns['service_type_ups'].selection).get(stockpicking.service_type_ups)

where :

    stockpicking = it is the object of model which have the field 'service_type_ups' in Odoo

  ----------------------------------------------------------------------------------------------------------------------------------------------

 View Inheritance In Odoo(OpenERP) :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="suspend_order_form" model="ir.ui.view">
            <field name="name">suspend.order.form</field>
            <field name="model">sale.order</field>
            <field name="inherit_id" ref="sale.view_order_form"/>
            <field name="arch" type="xml">
                    <button name="cancel" position="before">
                        <button name="state_in_suspend" states="draft,sent,cancel,waiting_date,progress,manual,shipping_except,invoice_except" string="Suspend Order" groups="base.group_user" type="object"/>
                    </button>
                    <field name="state" position="replace">
                        <field name="state" widget="statusbar" statusbar_visible="draft,sent,progress,suspend,done" statusbar_colors='{"invoice_except":"red","waiting_date":"blue"}'/>
                    </field>
            </field>
        </record>
     </data>
</openerp>

 ----------------------------------------------------------------------------------------------------------------------------------------------

When we want to get the ids of many2many  relation :

Example :

class project(osv.osv):
_name = "project.project"
_columns = {
'type_ids': fields.many2many('project.task.type', 'project_task_type_rel', 'project_id', 'type_id', 'Tasks Stages'),
}
project()
-------------------------------
class jira_config(osv.osv):
     _name = 'jira.config'
     _columns = {
}

     def get_stage_id(self, cr, uid, pro_search_id ,status_name) :
cr.execute('select type_id from project_task_type_rel where project_id = %s' %(pro_search_id))
type_ids = cr.fetchall()
if type_ids :
          for id1 in type_ids :
             type_obj = self.pool.get('project.task.type').browse(cr, uid, list(id1))
             if type_obj.name == status_name :
                 return id1
return False



# where pro_search_id[0] is id of 'project.project' object

def import_issue_from_jira(self, cr, uid, ids, context = None) :
stage_id = self.get_stage_id(cr, uid, pro_search_id[0], result['fields']['status']['name'])
                if stage_id :
                    # Do your operation hear

----------------------------------------------------------------------------------------------------------------------------------------------

 Generate/Export Customer Invoice in XML Format

by using following code we can generate xml file with invoice Data :

1. Py Code :

from openerp import models

class account_invoice(models.Model):
    _inherit = "account.invoice"
    
    def generate_xml(self, cr, uid, ids, context=None):
        invoice_line_obj = self.pool.get('account.invoice.line')
        invoice_obj = self.browse(cr, uid, ids[0])
        invoice_tax_obj = self.pool.get('account.invoice.tax')
        newLine = '<?xml version="1.0" encoding="UTF-8"?>\n'
        file_obj = open("/home/tarachand/Desktop/customer_invoice.xml", "w")
        file_obj.write(newLine)
        file_obj.write('<Invoice>\n')
        file_obj.write('\t<Number>'+invoice_obj.number+'</Number>\n')
        file_obj.write('\t<InvoiceDate>'+invoice_obj.date_invoice+'</InvoiceDate>\n')
        file_obj.write('\t<Customer>'+invoice_obj.partner_id.display_name+'</Customer>\n')
        address = invoice_obj.partner_id.street
        address = str(address.encode('utf-8'))
        address += " "+str(invoice_obj.partner_id.zip)
        address += " "+str(invoice_obj.partner_id.city)
        if invoice_obj.partner_id.country_id :
            address += " "+str(invoice_obj.partner_id.country_id.name)
        file_obj.write('\t<Address>'+address+'</Address>\n')
        file_obj.write('\t<Journal>'+invoice_obj.journal_id.display_name+'</Journal>\n')
        file_obj.write('\t<Account>'+invoice_obj.account_id.display_name+'</Account>\n')
        file_obj.write('\t<Currency>'+invoice_obj.currency_id.display_name+'</Currency>\n')
        file_obj.write('\t<InvoiceLines>\n')
        line_ids = invoice_line_obj.search(cr, uid,[('invoice_id','=',ids[0])])
        if line_ids :
            for line_id in line_ids :
                line_browse = invoice_line_obj.browse(cr, uid, line_id)
                file_obj.write('\t\t<InvoiceLine>\n')
                if line_browse.product_id :
                    file_obj.write('\t\t\t<Product>'+str(line_browse.product_id.display_name)+'</Product>\n')
                else :
                    file_obj.write('\t\t\t<Product></Product>\n')
                file_obj.write('\t\t\t<Description>'+str(line_browse.name.encode('utf-8'))+'</Description>\n')
                if line_browse.account_id :
                    file_obj.write('\t\t\t<Account>'+str(line_browse.account_id.display_name)+'</Account>\n')
                else :
                    file_obj.write('\t\t\t<Account></Account>\n')
                if line_browse.account_analytic_id :
                    file_obj.write('\t\t\t<AnalyticAccount>'+str(line_browse.account_analytic_id.display_name)+'</AnalyticAccount>\n')
                else :
                    file_obj.write('\t\t\t<AnalyticAccount></AnalyticAccount>\n')
                file_obj.write('\t\t\t<Quantity>'+str(line_browse.quantity)+'</Quantity>\n')
                if line_browse.product_id :
                    file_obj.write('\t\t\t<UnitOfMeasure>'+str(line_browse.product_id.product_tmpl_id.uom_po_id.display_name)+'</UnitOfMeasure>\n')
                else :
                    file_obj.write('\t\t\t<UnitOfMeasure></UnitOfMeasure>\n')
                file_obj.write('\t\t\t<UnitPrice>'+str(line_browse.price_unit)+'</UnitPrice>\n')
                file_obj.write('\t\t\t<Amount>'+str(line_browse.price_subtotal)+'</Amount>\n')
                file_obj.write('\t\t</InvoiceLine>\n')
        file_obj.write('\t</InvoiceLines>\n')
        file_obj.write('\t<OtherInfo>\n')
        file_obj.write('\t\t<SalesPerson>'+str(invoice_obj.user_id.display_name)+'</SalesPerson>\n')
        file_obj.write('\t\t<SourceDocument>'+str(invoice_obj.origin)+'</SourceDocument>\n')
        file_obj.write('\t\t<ReferenceDescription>'+str(invoice_obj.name)+'</ReferenceDescription>\n')
        file_obj.write('\t\t<AccountingPeriod>'+str(invoice_obj.period_id.display_name)+'</AccountingPeriod>\n')
        file_obj.write('\t\t<JournalEntery>'+str(invoice_obj.move_id.display_name)+'</JournalEntery>\n')
        file_obj.write('\t\t<DueDate>'+str(invoice_obj.date_due)+'</DueDate>\n')
        line_tax_ids = invoice_tax_obj.search(cr, uid,[('invoice_id','=',ids[0])])
        file_obj.write('\t\t<TaxLines>\n')
        if line_tax_ids :
            for tax_id in line_tax_ids :
                tax_line_browse = invoice_tax_obj.browse(cr, uid, tax_id)
                file_obj.write('\t\t\t<TaxLine>\n')
                file_obj.write('\t\t\t\t<TaxDescription>'+str(tax_line_browse.name)+'</TaxDescription>\n')
                if tax_line_browse.account_id :
                    file_obj.write('\t\t\t\t<TaxAccount>'+str(tax_line_browse.account_id.display_name)+'</TaxAccount>\n')
                else :
                    file_obj.write('\t\t\t\t<TaxAccount></TaxAccount>\n')
                file_obj.write('\t\t\t\t<Base>'+str(tax_line_browse.base)+'</Base>\n')
                file_obj.write('\t\t\t\t<Amount>'+str(tax_line_browse.amount)+'</Amount>\n')
                file_obj.write('\t\t\t</TaxLine>\n')
        file_obj.write('\t\t</TaxLines>\n')
        file_obj.write('\t</OtherInfo>\n')
        file_obj.write('\t<Payments>\n')
        if invoice_obj.payment_ids :
            for move_line in invoice_obj.payment_ids :
                file_obj.write('\t\t<Payment>\n')
                file_obj.write('\t\t\t<EffectiveDate>'+str(move_line.date)+'</EffectiveDate>\n')
                if move_line.move_id :
                    file_obj.write('\t\t\t<JournalEntry>'+str(move_line.move_id.id)+'</JournalEntry>\n')
                else :
                    file_obj.write('\t\t\t<JournalEntry></JournalEntry>\n')
                if move_line.ref :
                    file_obj.write('\t\t\t<Reference>'+str(move_line.ref)+'</Reference>\n')
                else :
                    file_obj.write('\t\t\t<Reference></Reference>\n')
                file_obj.write('\t\t\t<Name>'+str(move_line.name)+'</Name>\n')
                if move_line.journal_id :
                    file_obj.write('\t\t\t<Journal>'+str(move_line.journal_id.display_name)+'</Journal>\n')
                else :
                    file_obj.write('\t\t\t<Journal></Journal>\n')
                file_obj.write('\t\t\t<Debit>'+str(move_line.debit)+'</Debit>\n')
                file_obj.write('\t\t\t<Credit>'+str(move_line.credit)+'</Credit>\n')
                file_obj.write('\t\t\t<AmountCurrency>'+str(move_line.amount_currency)+'</AmountCurrency>\n')
                if move_line.currency_id :
                    file_obj.write('\t\t\t<Currency>'+str(move_line.currency_id.display_name)+'</Currency>\n')
                else :
                    file_obj.write('\t\t\t<Currency></Currency>\n')
                file_obj.write('\t\t</Payment>\n')
        file_obj.write('\t</Payments>\n')
        file_obj.write('\t<SubTotal>'+str(invoice_obj.amount_untaxed)+'</SubTotal>\n')
        file_obj.write('\t<Tax>'+str(invoice_obj.amount_tax)+'</Tax>\n')
        file_obj.write('\t<AmountTotal>'+str(invoice_obj.amount_total)+'</AmountTotal>\n')
        file_obj.write('\t<Balance>'+str(invoice_obj.residual)+'</Balance>\n')
        file_obj.write('</Invoice>\n')
account_invoice()

2. XML Code :

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
    <record id="xml_invoice_form" model="ir.ui.view">
<field name="name">xml.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<button name="invoice_cancel" states="draft,proforma2,open" string="Cancel Invoice" groups="base.group_no_one" position="after">
<button name="generate_xml" states="open,paid" string="Generate XML" type="object"/>
</button>
</field>
</record>
    </data>
</openerp>

----------------------------------------------------------------------------------------------------------------------------------------------

Example to create default data for projects:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record id="all_jira_projects_account" model="account.analytic.account">
           <field name="name">JIRA Projects</field>
           <field name="code">JP001</field>
           <field name="type">view</field>
       </record>
       
       
       <record id="project_tt_open" model="project.task.type">
           <field name="sequence">40</field>
           <field name="name">Open</field>
           <field name="case_default" eval="True"/>
       </record>
       <record id="project_tt_todo" model="project.task.type">
           <field name="sequence">41</field>
           <field name="name">To Do</field>
           <field name="case_default" eval="True"/>
       </record>
       <record id="project_tt_inprogress" model="project.task.type">
           <field name="sequence">42</field>
           <field name="name">In Progress</field>
           <field name="case_default" eval="True"/>
       </record>
       <record id="project_tt_reopened" model="project.task.type">
           <field name="sequence">43</field>
           <field name="name">Reopened</field>
           <field name="case_default" eval="True"/>
       </record>
       <record id="project_tt_resolved" model="project.task.type">
           <field name="sequence">44</field>
           <field name="name">Resolved</field>
           <field name="case_default" eval="True"/>
       </record>
       <record id="project_tt_closed" model="project.task.type">
           <field name="sequence">45</field>
           <field name="name">Closed</field>
           <field name="case_default" eval="True"/>
           <field name="fold" eval="True"/>
       </record>
<record id="jira_project_template1" model="project.project">
           <field name="state">template</field>
           <field name="type">normal</field>
           <field name="name">JIRA Projects</field>
           <field name="color">3</field>
           <field name="parent_id" ref="all_jira_projects_account"/>
           <field name="privacy_visibility">employees</field>
           <field name="user_id" ref="base.user_root"/>
           <field name="type_ids" eval="[(4, ref('project_tt_open')) ,(4,ref('project_tt_todo')), (4,ref('project_tt_inprogress')), (4,ref('project_tt_reopened')), (4,ref('project_tt_resolved')),(4,ref('project_tt_closed'))]"/>
           <field name="alias_model">project.task</field>
       </record>
   </data>
   </openerp>

Saturday, May 16, 2015

Postgresql


Restore Database dump file For Postgresql using Terminal(Command line) :

     - Open Terminal and go to folder(path) where your .sql file is exist and than type following command and hit enter
                         - psql -U {user-name} -d {desintation_db} -f {dumpfilename.sql}

                          where,
                                       user-name is your database username
                                       destination_db is your database in which you will store your dump
                                       dumpfilename.sql is your file dump file for restore

                         example :  psql -U tarachand -d student -f myfile.sql

JavaScript

  1. In javascript to remove last element of array
a). The pop() method removes the last element of an array, and returns
               that element.
   Note: This method changes the length of an array.
               Tip: To remove the first element of an array, use the shift() method.
b.) Use splice(index,howmany)
                arr.splice(-1,1)

Tuesday, May 5, 2015

Best Python Interview Questions With Answer

1. What will be the output of the code below?
     list = ['a', 'b', 'c', 'd', 'e']
     print list[10:]
Ans. []            
The above code will output [], and will not result in an IndexError.As one would expect, attempting to access a member of a list using an index that exceeds the number of members (e.g., attempting to access list[10] in the list above) results in an IndexError. However, attempting to access a slice of a list at a starting index that exceeds the number of members in the list will not result in an IndexError and will simply return an empty list.
What makes this a particularly nasty gotcha is that it can lead to bugs that are really hard to track down since no error is raised at runtime.

------------------------------------------------------------------------------------------------------------------------------------------------------

2. What will be the output of the code below in Python 2? Explain your answer.
   def div1(x,y):
        print "%s/%s = %s" % (x, y, x/y)
    
   def div2(x,y):
        print "%s//%s = %s" % (x, y, x//y)

   div1(5,2)
   div1(5.,2)
   div2(5,2)
   div2(5.,2.)
 
 Ans.
In Python 2, the output of the above code will be:
    5/2 = 2
    5.0/2 = 2.5
    5//2 = 2
    5.0//2.0 = 2.0

By default, Python 2 automatically performs integer arithmetic if both operands are integers. As a result, 5/2 yields 2, while 5./2 yields 2.5.

Note that you can override this behavior in Python 2 by adding the following import:
    from __future__ import division

Also note that the “double-slash” (//) operator will always perform integer division, regardless of the operand types. That’s why 5.0//2.0 yields 2.0 even in Python 2.

Python 3, however, does not have this behavior; i.e., it does not perform integer arithmetic if both operands are integers. Therefore, in Python 3, the output will be as follows:

    5/2 = 2.5
    5.0/2 = 2.5
    5//2 = 2
    5.0//2.0 = 2.0

------------------------------------------------------------------------------------------------------------------------------------------------------

3.What will be the output of the code below? Explain your answer.
def extendList(val, list=[]):
    list.append(val)
    return list

list1 = extendList(10)
list2 = extendList(123,[])
list3 = extendList('a')

print "list1 = %s" % list1
print "list2 = %s" % list2
print "list3 = %s" % list3

Ans.
The output of the above code will be:
list1 = [10, 'a']
list2 = [123]
list3 = [10, 'a']

Many will mistakenly expect list1 to be equal to [10] and list3 to be equal to ['a'], thinking that the list argument will be set to its default value of [] each time extendList is called.

However, what actually happens is that the new default list is created only once when the function is defined, and that same list is then used subsequently whenever extendList is invoked without a list argument being specified. This is because expressions in default arguments are calculated when the function is defined, not when it’s called.

list1 and list3 are therefore operating on the same default list, whereas list2 is operating on a separate list that it created (by passing its own empty list as the value for the list parameter).

The definition of the extendList function could be modified as follows, though, to always begin a new list when no list argument is specified, which is more likely to have been the desired behavior:

def extendList(val, list=None):
    if list is None:
        list = []
    list.append(val)
    return list

------------------------------------------------------------------------------------------------------------------------------------------------------

4. What will be the output of the code below? Explain your answer.
class Parent(object):
    x = 1

class Child1(Parent):
    pass

class Child2(Parent):
    pass

print Parent.x, Child1.x, Child2.x
Child1.x = 2
print Parent.x, Child1.x, Child2.x
Parent.x = 3
print Parent.x, Child1.x, Child2.x

Ans.
The output of the above code will be:
1 1 1
1 2 1
3 2 3

What confuses or surprises many about this is that the last line of output is 3 2 3 rather than 3 2 1. Why does changing the value of Parent.x also change the value of Child2.x, but at the same time not change the value of Child1.x?
The key to the answer is that, in Python, class variables are internally handled as dictionaries. If a variable name is not found in the dictionary of the current class, the class hierarchy (i.e., its parent classes) are searched until the referenced variable name is found (if the referenced variable name is not found in the class itself or anywhere in its hierarchy, an AttributeError occurs).
Therefore, setting x = 1 in the Parent class makes the class variable x (with a value of 1) referenceable in that class and any of its children. That’s why the first print statement outputs 1 1 1.
Subsequently, if any of its child classes overrides that value (for example, when we execute the statement Child1.x = 2), then the value is changed in that child only. That’s why the second print statement outputs 1 2 1.

Finally, if the value is then changed in the Parent (for example, when we execute the statement Parent.x = 3), that change is reflected also by any children that have not yet overridden the value (which in this case would be Child2). That’s why the third print statement outputs 3 2 3.

------------------------------------------------------------------------------------------------------------------------------------------------------

5. What will be the output of the code below? Explain your answer.
def multipliers():
    return [lambda x : i * x for i in range(4)]
 
print [m(2) for m in multipliers()]

Ans.
The output of the above code will be [6, 6, 6, 6] (not [0, 2, 4, 6]).
The reason for this is that Python’s closures are late binding. This means that the values of variables used in closures are looked up at the time the inner function is called. So as a result, when any of the functions returned by multipliers() are called, the value of i is looked up in the surrounding scope at that time. By then, regardless of which of the returned functions is called, the for loop has completed and i is left with its final value of 3. Therefore, every returned function multiplies the value it is passed by 3, so since a value of 2 is passed in the above code, they all return a value of 6 (i.e., 3 x 2).
(Incidentally, as pointed out in The Hitchhiker’s Guide to Python, there is a somewhat widespread misconception that this has something to do with lambdas, which is not the case. Functions created with a lambda expression are in no way special and the same behavior is exhibited by functions created using an ordinary def.)
Below are a few examples of ways to circumvent this issue.

One solution would be use a Python generator as follows:

def multipliers():
     for i in range(4): yield lambda x : i * x


Another solution is to create a closure that binds immediately to its arguments by using a default argument. For example:

def multipliers():
    return [lambda x, i=i : i * x for i in range(4)]

Or alternatively, you can use the functools.partial function:

from functools import partial
from operator import mul

def multipliers():
    return [partial(mul, i) for i in range(4)]

------------------------------------------------------------------------------------------------------------------------------------------------------

6. Consider the following code snippet:
1. list = [ [ ] ] * 5
2. list  # output?
3. list[0].append(10)
4. list  # output?
5. list[1].append(20)
6. list  # output?
7. list.append(30)
8. list  # output?
What will be the ouput of lines 2, 4, 6, and 8? Explain your answer.

Ans.
The output will be as follows:
[[], [], [], [], []]
[[10], [10], [10], [10], [10]]
[[10, 20], [10, 20], [10, 20], [10, 20], [10, 20]]
[[10, 20], [10, 20], [10, 20], [10, 20], [10, 20], 30]

Here’s why:
The first line of output is presumably intuitive and easy to understand; i.e., list = [ [ ] ] * 5 simply creates a list of 5 lists.
However, the key thing to understand here is that the statement list = [ [ ] ] * 5 does NOT create a list containing 5 distinct lists; rather, it creates a a list of 5 references to the same list. With this understanding, we can better understand the rest of the output.
list[0].append(10) appends 10 to the first list. But since all 5 lists refer to the same list, the output is: [[10], [10], [10], [10], [10]].
Similarly, list[1].append(20) appends 20 to the second list. But again, since all 5 lists refer to the same list, the output is now: [[10, 20], [10, 20], [10, 20], [10, 20], [10, 20]].

In contrast, list.append(30) is appending an entirely new element to the “outer” list, which therefore yields the output: [[10, 20], [10, 20], [10, 20], [10, 20], [10, 20], 30].

------------------------------------------------------------------------------------------------------------------------------------------------------

7. Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are:
(a) even numbers, and
(b) from elements in the original list that had even indices
For example, if list[2] contains a value that is even, that value should be included in the new list, since it is also at an even index (i.e., 2) in the original list. However, if list[3] contains an even number, that number should not be included in the new list since it is at an odd index (i.e., 3) in the original list.

Ans.
A simple solution to this problem would be as follows
[x for x in list[::2] if x%2 == 0]

For example, given the following list:
#        0   1   2   3    4    5    6    7    8
list = [ 1 , 3 , 5 , 8 , 10 , 13 , 18 , 36 , 78 ]

the list comprehension [x for x in list[::2] if x%2 == 0] will evaluate to:
[10, 18, 78]

The expression works by first taking the numbers that are at the even indices, and then filtering out all the odd numbers.

Monday, May 4, 2015

Linux and Odoo

Important Linux Commands : - - - - -

               1. See the running process by process name :
                             ps -ax | grep <process name> i.e. openerp

                2. Kill process by process id :
                             sudo kill -9 <process id>
                3. Change The Permission of Folder :
                             sudo chmod -R 777 <Folder Name>

Command 3 to 7 are related to search and install the package:

                 3. aptitude search <library name>

                 4. sudo aptitude <library name> install

                 5. pip install <library name> (takes link and downloads library for install)

                 6. easy_install <library name>

                 7. synaptic

Installation Command Step for Google Chrome:

                 Step 1. sudo apt-get install libxss1 libappindicator1 libindicator7


                  Step 2. wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb


                  Step 3. sudo dpkg -i google-chrome-stable_current_i386.deb


Commands to install PostgreSQL:

1.sudo apt-get install postgresql-client

2.sudo apt-get install postgresql postgresql-contrib

        The installation procedure created a user account called postgres that is associated with the                 default Postgres role. In order to use Postgres, we'll need to log into that account. You can do               that by typing:

3.sudo -i -u postgres

       change the password of database user:
4.psql
1.ALTER USER username WITH PASSWORD 'password';

create new role/user:
2.create user <username>;

list of all user role
3.\du

alter role for super user:
4.alter role <rolename> with superuser;

alter role for create role:
5.alter role <rolename> with createrole;

alter role for create Database:
6.alter role <rolename> with createdb;

Command for help:
7.\h;

exit from psql:
8.\q

                Commands to install Pgadmin3:

              1.sudo apt-get update

              2.sudo apt-get install pgadmin3


Odoo Installation:

Download Odoo from  this link "https://nightly.odoo.com/"

link 1. : http://www.theopensourcerer.com/2014/09/how-to-install-openerp-odoo-8-on-ubuntu-server-14-04-lts/

link 2. : http://www.serpentcs.com/serpentcs-openerp-v7-v8odoo-installation-ubuntu

        Step 1.sudo apt-get update

        Step 2. sudo apt-get dist-upgrade (not compulsory)

        Step 3. Install the necessary Python libraries for the server
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


Step 4. sudo python setup.py install


After Starting Odoo Server Generally following error comes :

       OperationalError: FATAL:  Peer authentication failed for user "odoo8" 

      Solution :
               
                     Step1.
                               open file (/etc/postgresql/9.1/main/pg_hba.conf)
                               with command :
                                             sudo gedit pg_hba.conf
                               give password of the system if it ask.

                               Then,replace follwing line

                                      local   all             postgres                                peer

                               by as,

                                     local    all             postgres                                md5
                                     local    all             odoo8                                    md5

                               and save file and close the file.

                  Step2.
                              Now you should reload the server configuration
                              changes and connect pgAdmin III to your
                              PostgreSQL database server.

                             by command,
                                           sudo /etc/init.d/postgresql reload


Click for Odoo Website 

Best Java Interview Questions With Answer

Que. Can an anonymous class be declared as implementing an interface and extending a class ?

Ans. An anonymous class may implement an intferface or extend a superclass,but may not be declared to do both.
                                                                                -----------

Que. Why isn't there operator overloading ?

Ans. Becuase C++ has proven by example that operator overloading makes code almost impossible to maintain.
                                                                               -----------

Que. What is transient variable ?

Ans. a variable that may not be serialized.
                                                                                -----------

Que. Is sizeof a keyword ?

Ans. The sizeof operator is not a keyword.
                                                                                -----------

Que. What is differance between >> and >>> operators?

Ans. The >> operator carries the sign bit when shifting right.The >>> zero-fills bits that have been shifted out.
                                                                                -----------

Que. When to use transient variable in Java?

Ans. Transient in Java is  used to indicate that the variable should not be serialized. Serialization is a process of saving an object's state in Java. When we want to persist and object's state by default all instance variables in the object is stored. In some cases, if you want to avoid persisting some variables because we don’t have the necessity to transfer across the network. So, declare those variables as transient. If the variable is declared as transient, then it will not be persisted.
                                                                                -----------

Que. Difference between Hashtable and HashMap in Java?

Ans. This is another frequently asked question from Java interview. Main difference between HaspMap and Hashtable are following :
          -HashMap allows null values as key and value whereas Hashtable doesn't allow nulls.
          -Hashtable is thread-safe and can be shared between multiple threads whereas HashMap cannot be shared between multiple threads without proper synchronization.
          -Because of synchronization, Hashtable is considerably slower than HashMap, even in case of single threaded application.
          -Hashtable is a legacy class, which was previously implemented Dictionary interface. It was later retrofitted into Collection framework by implementing Map interface. On the other hand, HashMap was part of framework from it's inception.
          -You can also make your HashMap thread-safe by using Collections.synchronizedMap() method. It's performance is similar to Hashtable.

                                                                                -----------

Que. Difference between wait and sleep in Java?

Ans. Here are some important differences between wait and sleep in Java

          -wait() method release the lock when thread is waiting but sleep() method hold the lock when thread is waiting.wait() is a instance method and sleep is a static method .
          -wait() method is always called from synchronized block or method but for sleep there is no such requirement.waiting thread can be awake by calling notify() and notifyAll() while sleeping thread can not be awaken by calling notify method.
          -wait method is condition based while sleep() method doesn't require any condition. It is just used to put current thread on sleep.
          -wait() is defined in java.lang.Object class while sleep() is defined in java.lang.Thread class.

                                                                                -----------

Que. Difference between extends Thread and implements Runnable in Java

Ans. One of the main point to put across while answering this question is Java's multiple inheritance support. You cannot more than one class, but you can implement more than one interface. If you extend Thread class just to           override run() method, you lose power of extending another class, while in case of Runnable, you can still implement another interface or another class. One more difference is that Thread is abstraction of independent path of execution, while Runnable is abstraction of independent task, which can be executed by any thread. That's why it's better to implement Runnable than extending Thread class in Java.
                                                                                -----------

Que. What is the JLS?

Ans. JLS is The Java Language Specification.Every developer should buy or download (free) this specification and read it, a bit at a time.(http://docs.oracle.com/javase/specs)
                                                                                -----------

Que. Why is there no printf-like function in Java?

Ans. Actually there are! This was fixed in Java 5; see Java Cookbook (2nd Edition) Chapter 9. Java 5 (J2SE 1.5) includes printf (and scanf), String.format(), and lots more.
                                                                                -----------

Que. What other Java sites do I need to know about?

Ans. java.sun.com, Sun's main technology site
          java.net, a collaborative site (run by Sun)
          java.com, an advocacy/news site (run by Sun)
          developer.java.sun.com, Sun's main developer site
          www.javalobby.org, independent advocacy group
          www.javaworld.com, Java news
          www.theserverside.com, Java Review
          http://www.darwinsys.com/java/, my own Java site
                                                                                -----------

Que. What else do I need to know?

Ans. Everything! But nobody can know everything about Java - the subject is now too vast. Imagine somebody saying that they know everything about every single Microsoft product and technology. If someone like that calls me, I'm always out.
                                                                                -----------