Search This Blog

Monday 17 September 2012

Use of 'attrs' property of field in OpenERP

Attrs property of field in OpenERP

If you want to change the access and visibility of field at run time at that time you can use 'attr' property of fields

The 'attrs' property has mainly three attributes here is the examples.

Eg.

In .py File

    class account_invoice(osv.osv)
           
            _name=''account.invoice"

            _columns = {
                                 'type':fields.selection([('retail','Retail'),('tax','Tax'),('labour',Labour)],"Invoice Type"),
                                  'frieght':field.float('Frieght'),
             }
    account_invoice()

In .xml File


<field name="frieght" attrs="{"invisible":'['|'('type','=','retail')]}"/>
- The field will be invisible if type equal to retail.

<field name="frieght" attrs="{"readonly":'['|'('type','=','tax')]}"/>
- The field will be readonly if type equal tax

<field name="frieght" attrs="{"required":'['|'('type','=','retail')]}"/>
-The field will become required if type equal labour.




No comments:

Post a Comment