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

Hi to all. Is it possible to change string label base on condition? I have function that will return something but before it return an object i want to change label of some fields kindd this one:

if state == 'approved':

self.write(cr,uid,ids,{

                               'temp_holder' : uid,

                               #but at the same time, i want to change the string label of temp_holder just like this: Approved by              

                })

Any help is very much appreciated.

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

What you can do is add labels.

<div >

<label for="name" attrs="{'invisible': ['condition','=',False)]}"/>

<label for="name" string="Custom String" attrs="{'invisible': [('condition','=',True)]}"/>

</div>

<field name="name" nolabel="1" />

only problem is that it will not have a vertical separator between label and field value.

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

Yes, it doesn't look exceptionally good, but it works.

To me this is the best solution I've tried by now.

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

Dear Anirudh Loh,

Please refer def fields_view_get method, Using that you can achieve your goal.

Best Regards,

Ankit H Gandhi.

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