Odoo Help


[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 1,111 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" />

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/19/15, 5:39 AM
Seen: 1111 times
Last updated: 3/16/15, 8:10 AM