Saturday, 20 December 2014

How to display custom header and footer in all page in RML report in OpenERP 7?

Here is page template tag that may used it for display custom header and footer in all pages.

According to the report view, we need to change x and y co-ordinates. 

<pageTemplate id="first">
  <frame id="first" x1="30.0" y1="27.0" width="508" height="815"/>
    <pageGraphics>
        <image x="1.3cm" y="26.0cm" height="90.0">
              [[company.logo or removeParentNode('image')]]</image>
        <place x="16.6cm" y="25.3cm" height="1.8cm" width="15.0cm">
        <para fontSize="7.0" fontName="Helvetica" >
              [[ display_address(company.partner_id) or  '' ]]</para>
        </place>
        <lines>1.3cm 24.9cm 19.9cm 24.9cm</lines>
    </pageGraphics>
</pageTemplate>

I hope you like this article. Share your views to improve content. Happy Learning !!!  

Youtube Video 

Saturday, 13 December 2014

How to hide small edit button beside many2one field in Odoo?


Here is Purchase order form view.


For that we need to Active debug mode from the right hand side and click to the Admin and than About Odoo.


Click to the Active the Active Developer mode.


Now select Edit Formview from the Debugview.


Edit this attribute to partner_id field => options='{"no_open": True}'


Save it and Refresh the browse or press F5. We may see it now navigate menu is hide from there.



I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video 

How to create recurring invoice in Odoo?

First install "Recurring Documents" module.
 

Now follow this path. Settings => Technical => Automation => Recurring Types and create record with name should be any thing and object must be Invoice.


Settings => Technical => Automation => Recurring Documents and create document for invoice. In Source Document, we may select which invoice we need to create recurring.

 
Save this record and click on red button called "Process"


We can see that Cron Job is created.



Documents Created tab is empty because currently no invoice is created.


 After Scheduler run the document is created.
 
 
Cron Job look like.


Below image is a old invoice which is we select in Source Document.

 
Here is new Invoice created based on cron job. 
 

I hope you like this article. Share your views to improve content. Happy Learning !!! 

Youtube Video 

Friday, 12 December 2014

XML-RPC web services in OpenERP

XML-RPC is known as a web service. Let's understand how's work in OpenERP.


import xmlrpclib

username = 'admin' #the login user name
pwd = 'admin'      #the password of the user
dbname = 'my_db'    #the database name

# Connection String ........

sock_common = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/common')
uid = sock_common.login(dbname, username, pwd)
sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')

#create partner record

partner = {
   'name': 'Odedra',
   'lang': 'en_US',
}

partner_id = sock.execute(dbname, uid, pwd, 'res.partner', 'create', partner) #partner is created

print "\n\n===Partner Create id => ", partner_id

#how to update partner record?

vals = {'street': 'Chhaya Road',
   'zip': '360575',
   'city': 'Porbandar',
   'phone': '+2244202',
   'fax': '+2244202222',
}

update_data = sock.execute(dbname, uid, pwd, 'res.partner', 'write', partner_id, vals) #record update successfully

print "\n\n===Is Partner updated? => ", update_data

#how to read partner record?

fields = ['name', 'city', 'zip']

read_data = sock.execute(dbname, uid, pwd, 'res.partner', 'read', partner_id, fields) #read data successfully

print "\n\n===Yes, Here is value for Partner record => ", read_data

#how to search a partner record?

query = [('name', 'ilike', 'Odedra')] #query clause
ids = sock.execute(dbname, uid, pwd, 'res.partner', 'search', query) #give the id of searched record otherwise it's return empty list

print "\n\n===how many partner founds? => ", len(ids)
print "\n\n===What their id? => ", ids

#how to call method?
#NOTE: First we have too method on res.partner object than and than we can call that method

res = sock.execute(dbname, uid, pwd, 'res.partner', 'method_name', [partner_id])

print "\n\n===Is method called? => ", res

#how to delete partner record?

result = sock.execute(dbname, uid, pwd, 'res.partner', 'unlink', partner_id) #delete the partner

print "\n\n===Is Partner deleted ? => ", result

print "\n\nGoodBye...."

I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video

Wednesday, 10 December 2014

How to create constraints in OpenERP v7, Odoo 8,9, and 10 ?

This will help you to create a constraints in OpenERP.

_constraint is a pre-define field in OpenERP. It is used for adding a constraint on the object.

It takes list of tuple as its argument. The tuple inside the list contains three parameter.
  1. Method (to check the constraint)
  2. The Message (Pop-up message for End User)
  3. List of Fields (fields to apply the constraint)
_constraint will fire if the condition returns False on creation and updation of the record and display the message.

Here is an example of integer data-type. It's fire a constraint if length is not positive.

Here is .py side code:

Old API:
 
from openerp.osv import fields, osv
class res_partner(osv.Model):
    _inherit = 'res.partner'

    _columns = {       
        'length': fields.integer('Length', size=64),
    }

    def _check_number(self, cr, uid, ids, context=None):
        for partner in self.browse(cr, uid, ids, context=context):
            if partner.length < 0:
                return False
        return True    
   
    _constraints = [
        (_check_length, 'Length must be Positive.', ['length'])
    ]

New API:

from openerp.exceptions import ValidationError
from openerp import api, fields, models, _

class Partner(models.Model):
    _inherit = 'res.partner'

    @api.one
    @api.constrains('length')
    def _check_length(self):
        if self.length < 0:
            raise ValidationError("Length must be Positive.")

    length = fields.integer('Length', size=64)

Here is .xml side code:

<?xml version="1.0"?>
<openerp>
    <data>
        <!-- res partner form view-->
        <record id="view_res_partner_extended_form" model="ir.ui.view">
            <field name="name">res.partner.extended.form.view</field>
            <field name="model">res.partner</field>
            <field name="inherit_id" ref="base.view_partner_form"/>
            <field name="arch" type="xml">
                <field name="email" position="after">
                    <field name="length"/>
                </field>
            </field>
        </record>
    </data>
</openerp>


I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video 

Tuesday, 9 December 2014

How to install Wkhtmltopdf package in Odoo?

This will help for Ubuntu system.
 
Once we install Odoo v8 and try to print report. WE may see notice at right hand side in black box with message.

You should upgrade your version of Wkhtmltopdf to at least 0.12.0 in order to get a correct display of headers and footers as well as support for table-breaking between pages.
   
That means Odoo v8 support the 0.12.0 or greater  than version of Wkhtmltopdf. So need to just follow the below steps:

cd /tmp
wget http://sourceforge.net/projects/wkhtmltopdf/files/archive/0.12.0/wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz

tar -xvf wkhtmltox-linux-amd64_0.12.0-03c001d.tar.xz
cd wkhtmltox
cd bin/
mv wkhtmltopdf /usr/bin/

mv wkhtmltoimage /usr/bin/
cd ..
cd lib/
mv libwkhtmltox.so.0 /lib64
mv libwkhtmltox.so.0.12 /lib64
mv libwkhtmltox.so.0.12.0 /lib64

cd /usr/bin/
sudo chown root:root wkhtmlto*
cd /lib64
sudo chown root:root libwkhtmlto*
sudo chown -h root:root libwkhtmlto*

Now reboot the system using this command.

sudo reboot

After than we need to start the Odoo server, Login in database and follow the below GUI step:

Configuration -> Parameter -> Parameters Systems
Create a new record like :

    Tipe : webkit_path
    Value : /usr/bin/wkhtmltopdf
   
If you show above record in your Odoo System that means now everything is fine.

I hope you like this article. Share your views to improve content. Happy Learning !!!

Youtube Video

Monday, 8 December 2014

ImportError: No module named pooler

In odoo, Many people have problem with pooler import. So here is trackback and below is solution for that.

   Traceback (most recent call last): File "/usr/bin/openerp-server", line 10, in <module> openerp.cli.main()

    File "/usr/lib/pymodules/python2.7/openerp/cli/__init__.py", line 51, in main __import__(m)
    File "/usr/lib/pymodules/python2.7/openerp/modules/module.py", line 133, in load_module mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
    File "/usr/lib/pymodules/python2.7/openerp/addons/account_test/__init__.py", line 1, in <module> import account_test
    File "/usr/lib/pymodules/python2.7/openerp/addons/account_test/account_test.py", line 32, in <module> import pooler
    ImportError: No module named pooler

Solution:-
 
First go to path location /usr/lib/pymodules/python2.7/openerp/addons/account_test/account_test.py and line number 32

Now replace
    import pooler
to
    from openerp import pooler  
  
Now restart the server.

I hope you like this article. Share your views to improve content. Happy Learning !!!

How to install OpenERP/Odoo from Github?


I would like to share with you, how to Install Odoo(formerly OpenERP) from github on Ubuntu system.

Odoo Github

1. First we need to install git in our Ubuntu system, for that open our terminal or or hit Ctrl+Alt+t

 a) First we need to update apt source list
  
     sudo apt-get update

 b) Upgrade apt source package

     sudo apt-get upgrade

c) Now install git

    sudo apt-get install git

2. Install Python packages  which required for Odoo installation

sudo apt-get install graphviz ghostscript postgresql-client \
python-dateutil python-feedparser python-matplotlib \
python-ldap python-libxslt1 python-lxml python-mako \
python-openid python-psycopg2 python-pybabel python-pychart \
python-pydot python-pyparsing python-reportlab python-simplejson \
python-tz python-vatnumber python-vobject python-webdav \
python-werkzeug python-xlwt python-yaml python-imaging


sudo apt-get install gcc python-dev mc bzr python-setuptools python-babel \
python-feedparser python-reportlab-accel python-zsi python-openssl \
python-egenix-mxdatetime python-jinja2 python-unittest2 python-mock \
python-docutils lptools make python-psutil python-paramiko poppler-utils \
python-pdftools antiword postgresql


3. Install PostgreSQL database

    sudo apt-get install postgresql

4. Install Pgadmin

    sudo apt-get install pgadmin

5. Create User into Postgres Database Odoo

    sudo -u postgres createuser -s odoo

6. Download Odoo from Github to your system

a) make directory in home

    sudo mkdir home/openerp-v8

b) move to  directory

    cd home/openerp-v8

c) Download odoo from Github

    sudo git clone https://github.com/odoo/odoo.git

7. Once finish a download need to run odoo server 

a) Go to oddo path

   cd home/openerp-v8/odoo

b) Run a odoo server

./openerp-server


8. To check Odoo installation is perfectly work  on your system so for that  just open browser type http://localhost:8069

9. Odoo login screen. Currently it will show below screen because first time we don't have database. 

Odoo Database Manager

I hope you like this article. Share your views to improve content. Happy Learning !!!

ImportError: No module named googleapiclient

Recently, I have faced ImportError: No module named googleapiclient and I would like to share knowledge to fix that problem. Open termina...