Odoo 14 Community Edition
I have a One2Many field called lines. I display the field as a tree in a form view like this.
<field name="lines">
<tree editable="bottom">
<field
... doesn't matter ...
/>
</tree>
</field>
The field is now editable but I would like to change it so that it will allow to create/delete the records within the tree by some conditions.
I tried create="0" delete="0" in the tree but it only works for "0" and "1". I can't seem to find the way to put a condition in there.
How to overcome such challenge? The conditions can just be depending on the parent's state -- simple conditions.
You can use
attrson the field itself, because besides the often usedinvisibleattribute you also can usereadonlyandrequired.Using
readonlywith a domain on the field will lead to other usable fields. Because the fieldlinesis a x2many relation (child) so the fields of the parent are usable.Because i don't know the models here, let's assume we have the known one2many relation
sale.orderandsale.order.lineand we want the lines to get readonly when thestatefield has either the valuesaleordone.