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.




Sunday 16 September 2012

Using 'Child_of' operator In 'Parent-Child Relationship In Search view of Openerp module

If You Want to Search the All child Record Related to that text which had Written on Search Box..

follow the Following Step..

1)  That module must have a parent field in that form view When ever you crating Record for Any objects..

for eg.

If you want to search all semester which are belong /child to that semester which you had wrote in search menu..


module

class standard_standard(osv.osv)

name = 'standard.standard'

columns = {
                  'name':fields('sem',char=64),
                  parent_id.fields.many2one('standard.standard',"Parent Semester"),
}

standard_standard()




You have used that moudle as semster in you student profile

standard_id =fields.many2one ('standard.standard',Semester)



Now only one thing you have to set on you search view

<field name="standard_id" operator="child_of" />

Thats It.

Now you can easily get  you all record belong to that parent which had selected at creation of record.

Thank you