Tuesday, 10 July 2012

_constraints in Openerp

_constraints

    _constraint is a predefine field in OpenERP. It is used for adding a constraint on the object. It takes list of touple as its argument.The touple inside the list contains three parameter

1. Method(to check the constraint)
2. The Message(Constraint 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.

    The example code for the _constraint is displayed bellow.
   

 def _check_length(self, cr, uid, ids, context=None):
    record = self.browse(cr, uid, ids, context=context)
    for data in record:
        if data.length < 0:
            return False
    return True

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

 _constraints = [(_check_length, 'Error: Length must be Positive', ['length'])]



    In the folloeing example the constraint is set on length field, when the record saved in the database it will check if the length is positive or negative, if it 's negative the constraint gets fired and the message will be display to end user.

Tuesday, 29 May 2012

Ubuntu Libdmtx installation Guide

To install libdmtx first of all we have to configured the machine compatible to libdmtx library:
for that you have to install some python packages.

The required packages are :

(1) python-dev
    This will include the all header file of the c which is requierd for libdmtx library e.g python.h
    sudo apt-get install python-dev

(2) git
    This will install the git which is repository
    sudo apt-get install git

(3) libdmtx-utils
    libdmtx-utils is required for the libdmtx library which includes c file and all header file
    sudo apt-get install libdmtx-utils

(4)  libdmtx-dev
    libdmtx-dev is required for the libdmtx python wrapper.
    sudo apt-get install libdmtx-dev


Now we have to setup the libdmtx library,

(1) first change the directory to
    cd /usr/share/doc/libdmtx-dev/examples/python

(2)unzip pydmtx.py.gz
    sudo gunzip pydmtx.py.gz

(3)unzip pydmtxmodule.c.gz
    sudo gunzip pydmtxmodule.c.gz

(4) installing the setup of libdmtx
    sudo python setup.py install

(5) Thats it!!

now test if the installation

run this python code in your python interpreter:

        from pydmtx import DataMatrix
        from PIL import Image


        # Write a Data Matrix barcode
        dm_write = DataMatrix()
        dm_write.encode("Hello, world!")
        dm_write.save("/home/hello.png", "png")


        # Read a Data Matrix barcode
        dm_read = DataMatrix()
        img = Image.open("/home/hello.png")


        print dm_read.decode(img.size[0], img.size[1], buffer(img.tostring()))
        print dm_read.count()
        print dm_read.message(1)
        print dm_read.stats(1)

Thursday, 16 February 2012

Image In OpenERP Web Kit Report

This is the Blog Post About How to put a image in OpenERP Custom Module, 

It is Quite easy To Put a image in The PDF fire. You just Need a binary field in Your Model, 

i have taken the example of Company logo in OpenERP, Which is the base class in OpenERP. The Name of the model is res.company 

I Think You Know About the MACO Template, and How To Customize it, if Don't no worries Please Comment it down,

<div id="exq">
        ${helper.embed_image("jpg",company.logo, width=100, height=100)}
        <img src="" alt="" >
</div>                                                                                                                          

In the module report_webkit There is a file report_helper, this file contain some methods like 
    • embed_image
    • get_logo_by_name
    • embed_logo_by_name
using This Method You can Put a image inYour webkit report .

For Any Query Please Comment.

Monday, 13 February 2012

OpenERP Webkit Report Installation Demo

This Video describe basic thing about webkit report in OpenERP. it includes installation of Webkit Report in OpenERP. It will help You to Installing the OpenERP Webkit report





For More Guide of OpenERP You can subscribe the My Channel http://www.youtube.com/user/SparkingAtul