Search This Blog

Thursday, 28 November 2013

Read Data from xml using Dom in Python

Here is sample code for how we can use dom in python for extracting data from xml.

import xml.dom.minidom

document = """<root><firstname>Anil</firstname>
dom = xml.dom.minidom.parseString(document)

def getText(nodelist):
    rc = []
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
    return ''.join(rc)

def handleTok(tokenlist):
    texts = ""
    for token in tokenlist:
        texts += " "+ getText(token.childNodes)
    return texts

first_name = dom.getElementsByTagName("firstname")
first_name = handleTok(first_name)

middle_name = dom.getElementsByTagName("middlename")
middle_name = handleTok(middle_name)

last_name = dom.getElementsByTagName("surname")
last_name = handleTok(last_name)

print "Name Detail :::",first_name + " " + middle_name + " " + last_name

Setup Aeroo Report Configuration Step by Step In ubuntu

Here is the link for Aeroo library installation and configuration of aeroo report in your system

Click Here 

List Date between Two Dates using Python

Here is sample code for listing the all dates for between two dates

    from dateutil import rrule
    from datetime import datetime

    def get_date_range(date_from, date_to):
        date_list = []
        for dd in rrule.rrule(rrule.DAILY,
                  dtstart=datetime.strptime(date_from, "%Y-%m-%d"),
                  until=datetime.strptime(date_to, "%Y-%m-%d")):
    return date_list

    date_from = '2013-11-02'
    date_to = '2013-11-13'

    date_data = get_date_range(date_from, date_to)

    print "List Dates ::::::",date_data

O/P :
List Dates :::::: ['2013-11-02', '2013-11-03', '2013-11-04', '2013-11-05', '2013-11-06', '2013-11-07', '2013-11-08', '2013-11-09', '2013-11-10', '2013-11-11', '2013-11-12', '2013-11-13']

Saturday, 21 September 2013

Step by Step Configure OpnERP 7.0 Development Environment on Ubuntu

Required Openrep 7.0 source code.

 If you don't have the source code than no worry you can download it from launchpad.

Note: Before using launchpad command, Register in Launch Pad  and share the ssh key of your system.

SSH Key config.

Register SSH key(
1) sudo apt-get install openssh-client
2) ssh-keygen -t rsa
3) When prompted, press Enter to accept the default file name for your key.
4) Next, enter then confirm a password to protect your SSH key. Your key pair is stored in ~/.ssh/ as (public key) and id_rsa (private key)
5) Then the public and private keys are available in the directory .ssh
6) open the in text editor. copy its contents to your clipboard
7) Visit your SSH keys page(
8) Paste your public key into the text box and then click the Import public key button to continue.

for downloading you need to install bzr in your system. if it is already install than its fine. other wise you can install it by using this command.

sudo apt-get install bzr

sudo apt-get install bzrtools

Create Separate Directory for OpenERP and download all these branches branches one by one.

bzr branch lp:openobject-server

bzr branch lp:openobject-addons

bzr branch lp:openerp-web/7.0

Required Basic Library to be Install 
(These lib are used in Openerp Existing Modules so basically you need to install these All,Just copy and paste into your commmand prompt.)

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-psutil

Download the Eclipse from below link.

     Download Linux 32 Bit

     Download Linux 64 Bit 

Now All downloading procedure is finished.

Steps for Setup the OpenERP Source code into your Eclipse.

1) Create One directory for your Workspace and inside that Workspace directory create directory for OpenERP. .

2) Paste your all three branches into OpenERP directory which are downloaded from launchpad.

3) Go to Eclipse Create new project select under General category and than select Project and than click Next.

4) It will ask for the project name give the project as , your directory name which is in Workspace

Eg : Your source directory name is OpenERP which is inside the work space than give your Project name as OpenERP.

5) Click on Finish button. 

All the OpenERP source code will be available on your project directory.

Setup OpenERP Eclipse Template

    Download OpenERP XML Template files.

       sudo apt-install subversion

       svn checkout

Friday, 23 August 2013

Generate Random password using Python

#Random Password Generatation

    import random, string

    rand_obj = random.SystemRandom()
    length = 10 #specify lenth of your password
    password_string = string.letters[0:52] + string.digits  # concate the small , big alaphabet & numbers
    password = str().join(rand_obj.choice(password_string) for _ in range(length))
    #generate the password based on your alphabet string and lenght.

    print "Random Generated Password with 10 size lenght",password

Sunday, 26 May 2013

Importance of space while applying Group Acess on menu item in OpenERP

How to apply more than one groups to menu item on Openerp.


Xml file :

<menuitem id="sub_menu_id" parent="main_menu" name="Reports" groups="base.group_hr_manager,user_define_group" />

Here I have given two groups to the Menu item. so this menu only visible to those user who has access of this two groups.

Note :  (Improtance of space).

When you apply more than two groups on specific menu than don't give space between two groups just separate it with comma ','  other wise there will be an error raise No such external ID.

Wrong Ways.

 <menuitem id="sub_menu_id" parent="main_menu" name="Reports" groups="base.group_hr_manager, user_define_group" />

Monday, 13 May 2013

HTMl page-break solution for webkit report in OpenERP

HTML page break solution for webkit report in OpenERP

    table {

    table tr {
                page-break-inside:avoid; page-break-after:auto;


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
    table { page-break-inside:auto }
    tr    { page-break-inside:avoid; page-break-after:auto }
    thead { display:table-header-group }
    tfoot { display:table-footer-group }
        <!-- Number ofrows -->

 Applied this code in your CSS File or inside the <style> tag.