Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to change the field labels with javascript?

By
Eric
on 4/10/15, 11:25 AM 1,013 views

does anyone know how I can change the field labels with javascript code for an xml form.  I am trying to change the field labels dynamically based on a value that the field has.  I tried using the <label> tags in the xml view to change them, but it messes up the form view when I do that.  I was wondering if there is an easy way to use javascript to change the labels without changing the form view at all

1
Eric
On 4/10/15, 4:50 PM

I still haven't figured out how to change the field labels with Javascript, but I did manage to modify the xml view so that the data was displayed properly.  Here is a short example:

<group>

     <!--

         When using dynamic labels in the same group as fields with non dynamic labels,

         make sure the label and the field are broken up in their own div tag

         This way the data will be displayed on the form properly

      -->

      <field name="another_field" />

      <div>

         <!-- Dynamic labels -->

          <label for="field_1" string="Field 1 Name" attrs="{'invisible': [('another_field','!=','value')]}" />

          <label for="field_1" string="Other Field 1 Name" attrs="{'invisible': [('another_field','=','value')]}" />

      </div>

      <div> <field name="field_1" /> </div>

</group>



Exactly what I was looking for. Thanks.

FEDERICO LEONI
on 7/6/15, 12:26 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 4/10/15, 11:25 AM
Seen: 1013 times
Last updated: 4/10/15, 4:50 PM