How to show and align label for a field on a form in OpenERP?

10,193

Solution 1

Fields placed inside a <group> XML element will display labels by default.

<field name="arch" type="xml">  
  <group>
    <field name="default_code" string="Item Number" readonly="1"        
         invisible="0" />
  </group>
</field> 

Solution 2

Or you can add a label tag like this:

<field name="arch" type="xml">  
     <label for="default_code" string="Item Number"/>
     <field name="default_code" readonly="1" 
            invisible="0" class="oe_inline"/>
</field> 
Share:
10,193
SmithMcPatrick
Author by

SmithMcPatrick

I am a Software Developer with ineterests in electronics, signal processing, software.

Updated on June 14, 2022

Comments

  • SmithMcPatrick
    SmithMcPatrick almost 2 years

    I have a field, in popup window, called "default_code" which correctly displayed the value 201-0147, picture attached. I want to have label "Item Number" just left of the field, on the same line. I tried setting attribute string to the "Item Number" (xml code attached) but it does not display. I know I can use <label> element, but, when displayed, it's displayed above the field, which I don't want. I want in line with field. What am I missing and what is the way to do it?

    Thanks for your help!

    Here is the popup window:

    enter image description here

    Here is the XML code:

    <record id="replace_all_in_BOM_form" model="ir.ui.view">
        <field name="name">replace.all.in.BOM.form</field>
        <field name="model">product.template</field>
        <field name="priority" eval="20"/>
        <field name="type">form</field>
        <field name="arch" type="xml">  
            <field name="default_code" string="Item Number" readonly="1"        
                 invisible="0" />
            </field> 
    </record>