Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
6 Trả lời
10927 Lượt xem

I need to hide a button in tree view(one2many) but only in non-editable mode. I have tried class="oe_edit_only" but it doesn't work.


NOTE : I need to hide only in non-editable mode NOT in editable mode. Please don't suggest and mark invisible = "1" as correct answer.
Any help would be appreciated.
Thank You :)

Ảnh đại diện
Huỷ bỏ

That's a good question, I have de same problem. Could you find a solution?

A related bug is referenced: https://bugs.launchpad.net/openerp-web/+bug/1311199

Câu trả lời hay nhất

It is not perfect solution but work around to what you want to achieve:
Odoo gives us two classes

  1. 'oe_edit_only' : to show element in edit mode only
  2. 'oe_read_only' : to show element in read mode only

so I defined a duplicate field of my one2many field and show that in only read mode and original only in edit mode.
Note: we can not use same field in xml more than one time because odoo populates value only in lastly defined field. all previous fields with same name remain blank.
 

Ảnh đại diện
Huỷ bỏ

I have tried with field and buttons in tree view inside a form of the parent entity and none of them are hidden in read mode.

<field name="status_acta" class="oe_edit_only"/>

<button name="pickup_units" type="object" string="Pick Up" class="oe_edit_only" attrs="{'invisible':['|','|', ('type','!=','acta_ant'),('activo','=',False),('status_acta','!=','sent')]}"/>

Câu trả lời hay nhất

Try writting invisible="True" in the button xml line, i think it works

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

@Giovanny: I wanted to leave comment but this website is not allowing me to do so. but with your solution button will be hidden permanently. I need to hide only in Non-Editable mode.
 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

You can pass the class to the template by finding the button template "ListView.row.button" in addons/web/static/src/xml/base.xml. Just add "#{widget.class}" to the button t-attf-class attribute. 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 8 25
2621
1
thg 7 25
1017
1
thg 8 25
1151
0
thg 5 25
1474
2
thg 4 25
3621