Search code examples
javascriptpythonodooodoo-13

Odoo 13 - Add second sum_field to Kanban Column ProgressBar


I'd like to know if there is a way to modify the Kanban Column ProgressBar in order to allow a second sum_field, to show it beside the existing sum_field.

I found out the progressbar js code seems to be in addons/web/static/src/js/views/kanban/kanban_column_progressbar.js, but I don't know how or what to do to add that second sum_field.

Should I inherit the js file in some way? If so, how can I do that?

This is the progressbar I'm talking about:

Odoo CRM Kanban ProgressBar

This is the idea I have in mind:

Same ProgressBar, but with a second computed field besides


Solution

  • You can alter the KanbanView.ColumnProgressBar template, compute and add the total before the last div.

    The following example compute the total of planned_revenue in each column:

    <t t-inherit="web.KanbanView.ColumnProgressBar" t-inherit-mode="extension">
        <xpath expr="//div[hasclass('o_kanban_counter_side')]" position="before">
            <t t-set="total" t-value="0"/>
                <t t-foreach="widget.columnState.data" t-as="data_record">
                    <t t-set="total" t-value="total + data_record.data.planned_revenue"/>
                </t>
            <b class="ml-2"><t t-esc="total"/></b>
        </xpath>
    </t>