htmlcheckboxlabelodoo-12formview

How to add label to the right side of checkbox in odoo-12


Hi im trying to design my checkbox in odoo i want it to have a label to the right side of the checkbox just like this enter image description here

Any Idea how can I Achieve this?

I've tried adding <span>Percentage</span> After my field but its always breaking the line


Solution

  • Suppose you have two checkbox fields chk1 and chk2, To make them appear like in the picture you will need to:

    Add two labels one with Discount Mode string and another with an empty string.
    Add a div after each label which will contain the field and its label.

    <group>
        <label for="chk1" string="Discount Mode"/>
        <div class="o_row">
            <field name="chk1"/>
            <label for="chk1"/>
        </div>
    
        <label for='chk2' string=""/>
        <div class="o_row">
            <field name="chk2"/>
            <label for="chk2"/>
        </div>
    </group>
    

    You can refer to weight field in Product -> Inventory (tab) -> logistics (group).