Skip to Content
Menu
This question has been flagged
1 Reply
4153 Views

I have this class: project.task that has this field:

state = fields.state = fields.Selection([ ('draft', 'Draft'),
                                          ('sent', 'In progress')], default='draft')
task_line_ids = fields.One2many('project.task.line','task_id',string="Articles")

And in project.task.line class I have this line:

progress = fields.Float()

In my xml code now I have:

<record name="task_form_view" model="ir.ui.view">
    <field name="name">Task Form View</field>
    <field name="model">project.task</field>
    <field name="arch" type="xml">
    <form>
    <header>
        <field name="state" widget="statusbar"/>
    </header>
        ....
    <notebook>
          <page name="Lines">
              <field name="task_line_ids">
                  <tree string="Tasklines" editable="bottom"> 
                      <field name="product_id" /> 
                      <field name="description"/> 
                      <field name="um_id"/> 
                      <field name="progress" />              
                  </tree> 
              </field>  
         </page>
    </notebook>
  </form>
</field></record>

Now what I want is that the field named progress inside tree view should be invisible when state is draft. I changed progress field like this:

 <field name="progress"  attrs="{'invisible': [('state','=','draft')]}" />

But it doesn't work. I got this error: Error: Unknown field state in domain [["state","=","draft"]]

I got the same error when I tried this code:

<field name="progress"  attrs="{'invisible': [('task_id.state','=','draft')]}" />
Avatar
Discard
Best Answer

Hi,

please refer this link if useful..

https://www.odoo.com/forum/help-1/question/conditionally-display-or-hide-a-field-in-a-view-13042


Avatar
Discard