PacktPublishing/Odoo-14-Development-Cookbook-Fourth-Edition

Chapter 15 : Create a custom widget - Problem when Form is in readonly mode

Opened this issue · 0 comments

There is a mismatch when you select a pill_no equals to 0. This adds a o_field_empty class.

To avoid this I suggested this :

<templates>
    <t t-name="FieldColorPills">
        <t t-foreach="widget.totalColors" t-as='pill_no'>
            <span t-attf-class="o_color_pill o_color_#{pill_no+1} #{widget.value === pill_no+1 and 'active' or ''}" t-attf-data-val="#{pill_no+1}"
            data-toggle="tooltip" data-placement="top" t-attf-title="This color is used in #{widget.colorGroupData[pill_no] or 0 } books."/>
        </t>
    </t>
</templates>

Please let me know if there is a better way.