I've set my order_line to be editable and want to remove the delete button if it's not in draft mode. I attempted the following but the delete button remains:
<xpath expr="//field[@name='order_line']//tree" position="attributes">
<attribute name="delete" domain="[(parent.state,'!=','draft')]"/>
</xpath>
Is it possible to dynamically set delete=false based on the draft state of the parent?
I tried this:
<record id="delete_drafts_only" model="ir.rule">
<field name="name">You can only delete items with draft parents</field>
<field name="model_id" ref="sale.model_sale_order_line"/>
<field name="global" eval="True"/>
<field name="domain_force">[('parent.state', '=', 'draft')]</field>
<field name="perm_unlink" eval="True"/>
</record>
and
<record id="delete_drafts_only" model="ir.rule">
<field name="name">You can only delete items with draft parents</field>
<field name="model_id" ref="sale.model_sale_order_line"/>
<field name="global" eval="True"/>
<field name="domain_force">[('parent.state', '!=', 'draft')]</field>
<field name="perm_read" eval="True"/>
<field name="perm_write" eval="True"/>
<field name="perm_create" eval="False"/>
<field name="perm_unlink" eval="False"/>
</record>
But it doesn't seem to actually apply. The only thing that seem to be working is manipulating the ir_model_access, but that toggles it globally which isn't what I want.
