Skip to Content
Menu
This question has been flagged
2 Replies
3043 Views

I would like to disable the create add button on a kanban view based on the state of the parent record.

I.e.

<field name="one2manyfield" attrs="{'readonly': [('state','!=','draft')]}">

  <kanban> ...... </kanban>

</field>


but it doesn't work, the add button is always displayed and working.


Any workaround ? The same solution works when there is a treeview instead of a kanban inside the field definition.


Avatar
Discard
Best Answer
Try this,

<field name="one2manyfield" options="{'no_create_edit': True}"


Avatar
Discard
Author

It doesn't work :(

Best Answer

Hello, 

Try this in xml and give your state control in py,

    one2manyfield = fields.One2many('your.table', 'your_id', string='One2many', readonly=True, states={'draft': [('readonly', False)]})   

in xml,

    <field name="one2manyfield" mode="kanban">

        <kanban quick_create="false" create="false" >

        </kanban>

    </field>

Avatar
Discard