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

Hi, english is not my first language and I hope that you can understand me. I'm inheriting sale order form view and added a boolean field using xpath to set its location. That field will affect other buttons styles if its value is true or false. 

For example, if "foo" == False, then I've to remove from view the button "bar" or hide it.

I've tried using some xpath statements like:


First image file...


Also some like:


Second image file...

This is one of worst editors in foros that I've never seen. 

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

Hello Zeugirdor,

You can used bellow example.

Please find code in comment. 

I hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

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

sale.py

class SaleOrder(models.Model):
_inherit = 'sale.order'

is_boolean = fields.Boolean('Is Boolean')

sale_view.xml

*Added fields in sale view and the action_cancel button hide on the field are false.

<xpath expr="//field[@name='invoice_status']" position="after">
<field name="is_boolean"/>
</xpath>

<button name="action_cancel" position="attributes">
<attribute name="attrs">
{'invisible': [('is_boolean', '=', False)]}
</attribute>
</button>

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 6 19
5727
9
thg 8 20
3933
2
thg 1 25
6630
computed fields Đã xử lý
1
thg 4 24
2617
1
thg 12 23
4737