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

Odoo 14 Development Cookbook - Fourth Edition, published by Packt
MIT License
180 stars 274 forks source link

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

Open BDam-Humans opened 2 years ago

BDam-Humans commented 2 years ago

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.