Search code examples
odoo

How to sum all the records and display as single in kanban view?


I need to sum the companies total and display as single row like in the image.

enter image description here

Now I just used the kanban view to display default view.

<kanban class="o_kanban_mobile">
    <field name="name"/>
    <field name="company"/>
    <field name="actual_amount"/>
    <field name="planned_amount"/>
    <templates>
        <t t-name="kanban-box">
            <div t-attf-class="oe_kanban_card oe_kanban_global_click">
                <table border="1" width="100%">
                    <tr>
                        <td rowspan="2"><t t-esc="record.name.value"/>-<t t-esc="record.company.value"/></td>
                        <td>Planned</td>
                        <td>Actual</td>
                    </tr>
                    <tr>
                        <td><t t-esc="record.planned_amount.value"/></td>
                        <td><t t-esc="record.actual_amount.value"/></td>
                    </tr>
                </table>
            </div>
        </t>
    </templates>
</kanban>

Solution

  • I think this will work for you.

    Add a char field to your model don't show it . just define a defaut value for it, default = 'sum' then groub by that field.

    You should get the same result.