How to change field's string label based on condition?
Se marcó esta pregunta
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
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse