This question has been flagged
1 Reply
4574 Views

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 delet 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?

Avatar
Discard
Best Answer

Well, I know that this question is a bit old, but still I am going to try and answer it.

From what I have search on the Internet, it seems that there is no support for what you want directly.

What I had to do was in the case of the form view, put in the <form> element delete=false, and add in the form <header> a button calling "unlink" that appears only when the state=draft.

And for the tree, I enabled the delete=true, and I have overwritten in my class the unlink method, to ensure that it is not called on records that have the state != draft.
So it always appear in the more, but it cannot be used on records I don't enable.

Avatar
Discard