2
votes

I have a many2one field into tab(Notebook/page/tree) like this enter image description here

so I make a method on_changed on this field when I change the value field I want to hide some column in this tree based on condition

this is my xml Code

 <page string="page_name">
 <field name="lines" context="{'academic_year_id' : academic_year_id}" >
 <tree name="T1" editable="top">
 <field name="field1"/>
 <field name="field2"
 domain="[('academic_year_id','=',parent.academic_year_id('id','=',parent.period_id)]/>
 <field name="field3"/>
 <field name="field4"/>
 </tree>
</field>
</page>

and this is my code python

@api.onchange('field_to_change')
def onchange_program(self):
    domain = {}
    if self.field1:
        //code

    return {'domain': {'lines ' : [('field1 ', '=',False),('field2 ', '=',False),('field3 ', '=',False),('field4 ', '=',False)]}}

Overall, I want to make something like, domain in fields of tree on this page it's possible ?? Version odoo 8 thanks .

1

1 Answers

1
votes

For making a field invisible and visible you can write by code in XML.

Syntax:

<field name="field_name" attrs="{'invisible':[('condition')]}"/>

For example:

<field name="contact_two" attrs="{'invisible'[('customer_type','=','individual')]}"/>

Don't forget to put a up mark and tick mark if it was right.