Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How can I dynamically set the tree views delete state?

Kit Sunde
on 10/26/14, 4:00 AM 638 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')]"/>

Is it possible to dynamically set delete=false based on the draft state of the parent?

On 12/15/14, 11:05 AM

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.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 10/26/14, 4:00 AM
Seen: 638 times
Last updated: 3/16/15, 8:10 AM