跳至內容
選單
此問題已被標幟
3 回覆
27007 瀏覽次數

How to change field's string label based on condition?

頭像
捨棄
最佳答案

Hi Giezel,

One more trick.

Steps 1:

Set nolabel to true in your field.

E.g.

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

Step 2:

Set the two labels above to your field and apply condition inside the labels.


<label string="Label 1" attrs="{'invisible':[]}"/>  <!-- Provide your condition inside [], if condition will be true the label will be invisible -->
<label string="Label 2" attrs="{'invisible':[]}"/> <!-- Provide reverse condition than above label. -->
<field name="your_field"/>


By following this you can hide your make visible your label based on condition.

Hope this will help.

Happy Odooing...


Regards,

Anil.


頭像
捨棄
最佳答案

Its tricky ;)

<field name="my_field" string="LABEL1" attrs="{'invisible': [('partner_id', '!=', False)]}"/>
<field name="my_field" string="LABEL2" attrs="{'invisible': [('partner_id', '=', False)]}"/>


So, here when you have partner, odoo will display LABEL1 as string.

Other wise LABEL2 for "my_field" field.


You can get some help from here.

頭像
捨棄

it works, but this is an unrecommended solution, better to avoid this, imho

相關帖文 回覆 瀏覽次數 活動
2
6月 22
5699
2
9月 21
4619
1
11月 20
7934
2
3月 19
6101
1
4月 18
4274