How to change field's string label based on condition?
Pertanyaan ini telah diberikan tanda
Hello Please use simple code
<field name="your_field" string="string1" invisible="condition1"/>
<field name="your_field" string="string2" invisible="condition2"/>
<field name="your_field" string="string3" invisible="condition3"/>
<field name="your_field" string="string4" invisible="condition4"/>
<field name="your_field" string="string5" invisible="condition5"/>
<field name="your_field" string="string6" invisible="condition6"/>
<field name="your_field" string="string7" invisible="condition7"/>
Hi,
To dynamically change a field’s label in a form view based on a condition, follow these steps:
Step 1: Hide the Default Label
Use nolabel="1" on the field to suppress its default label.
<field name="your_field" nolabel="1"/>
Step 2: Add Conditional Labels
Insert two <label> elements before the field and control their visibility with attrs.
<label string="Label A" attrs="{'invisible': [('some_field', '=', False)]}"/>
<label string="Label B" attrs="{'invisible': [('some_field', '=', True)]}"/>
This method is XML-only and works well for conditionally changing field labels
Hope it helps
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
Daftar