Thursday, April 25, 2013

Find latitude, longitude from Address with python


import json
from StringIO import StringIO
import urllib2



address_geo = 'gandhinagar,india'
url = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false' %        address_geo.replace(' ', '+')
response = urllib2.urlopen( url )
responseBody = response.read()
body = StringIO( responseBody )
result = json.load(body)
if 'status' not in result or result['status'] != 'OK' or result['results']==[]:
    return False
else:
    print  result['results'][0]['geometry']['location']['lat']
    print  result['results'][0]['geometry']['location']['lng']

Tuesday, January 1, 2013

                   
Install OpenERP 7.0 in Ubuntu
1. Install and Configure PostgreSQL database server

  • Below command will install the postgreSQL.
    sudo apt-get install postgresql


  • Change the postgres user so we have the necessary privileges to configure the database.
    sudo su - postgres


  • Create a new database user, same as the system user. it is because while starting the openerp server, openerp will find the same database user as the system user. Command to create new postgres user is
    createuser -d -S -R <username>

   

  • Go to the postgres prompt by running a command psql in terminal.

  • Now change the postgres user password by writting a database query.
    alter user serpent05 with password "password";

   


2. Install the necessary Python libraries for the server

  • Run this command in terminal to install dependent python libraries for OpenERP 7.0
    sudo apt-get install python-dateutil python-docutils python-feedparser \
python-gdata python-jinja2 python-ldap python-libxslt1 python-lxml python-mako \
python-mock python-openid python-psycopg2 python-psutil python-pybabel \
python-pychart python-pydot python-pyparsing python-reportlab python-simplejson \
python-tz python-unittest2 python-vatnumber python-vobject python-webdav \
python-werkzeug python-xlwt python-yaml python-zsi python-pip

  • Install python gdata
    sudo pip install gdata --upgrade




3. Register yourself with Launchpad.


  • After finishing the registration go to launchpad profile page.

4. Install Open-SSH client

  • Run the below commad to install the Open-SSH client. For getting the latest & updated code from the launchpad.
sudo apt-get install openssh-client

  • Generate ssh public and private key
    ssh-keygen -t rsa

   




  • Default location of the “id_rsa.pub” file is home/.ssh/id_rsa.pub which includes the public ssh key, open the file with text-editor and copy the public key.   

  • Open Launchpad Account Click on pencil icon to add the public ssh key.





  • Paste the SSH key in and click import public key



  • SSH key will allow to get the updated or latest code from the Launchpad using Bazaar(version control system) commands.


5. Get the latest code of OpenERP 7.0 from Launchpad
  • Install Bazaar using
    sudo apt-get install bzr

  • Run bzr commands to get the latest code of OpenERP

    bzr branch lp:openobject-server/7.0
    bzr branch lp:openobject-addons/7.0

  • bzr branch will get the latest code from the Launchpad.







6. Configure the PostgreSQL


  • Install PostgreSQL GUI, run below command in terminal to install.
    sudo apt-get install pgadmin3
   
  • Open the pgadmin and click on “Add new server connection“ from upper left corner.


  • It will open new window. Fill the server information as shown in the screenshot. Username and password should be same as the database user.




7. Start the OpenERP server


  • change the directory in the terminal to the OpenERP server using cd command. e.g.
    cd workspace/openerp/7.0/server

  • after changing the path run the server with addon path
    ./openerp-server --addons ../addons/,../web/addons/



8. Start the OpenERP web-client
    In browser URL you have put your IP with OpenERP port, here in example
    localhost:8069



Monday, January 16, 2012

Module Structure in OPENERP

-->
Module Structure :   Module Structure Consider Following Things : 
1.OpenERP Addons (openobject-addons) OpenERP business modules :  
   Addons provides the extra functionality to create our module
   and enhance the capability of themodule. OpenERP Addons
   hosts the functional business modules of openerp

 covering:accounting, sales, crm, purchases, warehouse,
          manufacturing, project, human resources, marketing,
          knowledge, point-of-sale, and much more...    
  • Addons contains the List of Modules. 
  • The Modules : 
  • When u create any module there are four files are required.
  •  which is given below : 
                1. __init__.py  
               2. __openerp__.py  
               3. Filename.py (Your model file )
               4. filename_view.xml :              
  • Views 
  • Actions 
  • Menu entries 
  • Reports 
  • wizard 
     
  • Now we can see how to create a module in OpenERP: 
           Step 1: Create the __init__.py file in the new folder you  
                  have created for the module, in the addons directory.
                  The __init__.py file must have a line to import the main
                  python(.py) file you intend create for the module.
                  Having the __init__.py file in your modulemakesthe
                  code a package. 
  
         Step 2: Create a module description file (i.e __openerp__.py)
                 The __openerp__.py file provides a description of the
                 module you want to create. 
  • It essentially forms a python dictionary. 
          Step 3: Create your python file it containing the objects. 
                (Infact thats your module)This file you have defined(import)
                 in your __init__.py file.

        step 4 :Create your view.xml file .XML located in the module directory
                are used to modify the structure of the database.  
  •  They are used for many purpose : 
      1. Initialization and demonstration data declaration.      
     2. Views declaration :         
  • Views are a way to represent the objects on the client-side. 
  • They indicate to the client how to layout the data coming from
  • the objects on the screen. 
  • There are two types of views:
  • form views, tree views 
  • List are simply a particular case of tree views. 
      3. Report declaration : 
  • OpenERP uses a flexible and powerful reporting system.
  • Reports are generated either in PDF or HTML. 
  • Reports are designed on the principle of separation between
  • the data layer and Presentation layer. 
   4. Wizard declaration :  
  • A wizard is declared using wizard tag.        
        5. Workflow declaration. s 
  • The objectsand the views allow you to define a new forms very
  • simply lists/trees/ and interactions between them.
  • The workflow describes these interaction with graphs. 
  • One or several workflows may be associated with the objects. 
  • Workflows are not mendatory.
          In this figure ,Left side column will be reprsente the list
         of Modules. When you Extract the module you will be easily
         see the four file which will be discussed above topic.