跳至内容
菜单
此问题已终结
1 回复
6706 查看

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?

形象
丢弃
编写者 最佳答案

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" />
    or
    <button string="Discard" class="oe_link" special="cancel" />
</footer>

形象
丢弃
相关帖文 回复 查看 活动
4
12月 23
19938
2
7月 21
10019
1
5月 15
3871
6
7月 24
46036
2
6月 17
5413