Search code examples
javascriptcsstreeviewodooodoo-10

Add color to checkbox in Odoo10 according to condition


Need to add color to checkbox in list view according to a condition like tree view decorator. If any line in tree view doesn't satisfy certain condition then need to change color of checkbox in odoo 10


Solution

  • Add this code to your module/static/src/xml/file.xml

    <tr t-extend="ListView.row">
        <t t-jquery="td[class='o_list_record_selector']" t-operation="replace">
            <td t-if="options.selectable" class="o_list_record_selector">
                <t t-set="checked" t-value="options.select_view_id == record.get('id') ? 'checked' : null"/>
                <input t-if="options.radio" type="radio" name="radiogroup" t-att-checked="checked"/>
                <t t-if="view.model == 'account.asset.asset'">
                    <t t-if="asData.state.value == 'make_draft'">
                        <div t-if="!options.radio" class="o_checkbox">
                            <input type="checkbox" name="radiogroup" style="outline-color: solid !important; outline-style: auto;" t-att-checked="checked"/><span/>
                        </div>
                    </t>
                    <t t-if="asData.state.value == 'draft'">
                        <div t-if="!options.radio" class="o_checkbox">
                            <input type="checkbox" name="radiogroup" style="outline-color: green !important; outline-style: auto;" t-att-checked="checked"/><span/>
                        </div>
                    </t>
    
                </t>
                <t t-if="view.model != 'account.asset.asset'">
    
                    <div t-if="!options.radio" class="o_checkbox">
                        <input type="checkbox" name="radiogroup" t-att-checked="checked"/><span/>
                    </div>
                </t>
            </td>
        </t>
    </tr>