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.


[SOLVED] How to show create button when creating record and hide it when reading it in a custom form?

Juan Formoso
on 1/19/15, 5:39 AM 698 views

I've created a new model. I've also created a form for it. So, if I click on the create button or on any record of this model in the tree view, my form is opened.

However, my form has no create button. Why? I don't know, but I've fixed it creating my own create button. It works, but now, if I open a record clicking on it (for reading), the create button I've made is there, and it doesn't work.

I want to make it disappear, but only when I open the form for reading (after clicking on a record in the tree view). Can I do this?

If not, how can I see the create button in my form without creating it?

Juan Formoso
On 1/19/15, 6:38 AM

Well, finally, a kind co-worker gave me a trick to solve this problem.

May be there are righter ways to manage what I want, but this works perfectly:

I left my create button, which is inside a footer. What I did is to add a attrs tag to this footer, I made it invisible if the ID of the record is different from False. If I'm creating a record, it doesn't have an ID yet, but if I'm reading, it does. Obviously I also had to add the field ID to the fields shown in the form, otherwise it couldn't be used in the attrs tag.

<footer attrs="{'invisible': [('id','!=',False)]}">
    <button name="create_rplc" string="Create" type="object"
        class="oe_highlight" />
    <button string="Discard" class="oe_link" special="cancel" />

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: 1/19/15, 5:39 AM
Seen: 698 times
Last updated: 3/16/15, 8:10 AM