'Display sum of numbers in the groups in odoo-12
I have created two fields and defined their views in the tree view. I added the attribute sum to the field view to show the sum, but it only works in the tree view, not in the group. How can I also display the sum in the groups?
This is the python part:
quantity_in = fields.Float('Quantity In', compute='get_qty_in')
quantity_out = fields.Float('Quantity Out', compute='get_qty_in')
and this is the xml part of the fields view:
<record id="stock_move_inherit_view" model="ir.ui.view">
<field name="name">stock.move.inherit.view</field>
<field name="model">stock.move.line</field>
<field name="inherit_id" ref="stock.view_move_line_tree"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='qty_done']" position="before">
<field name="quantity_in" sum="Total In Quantity"/>
<field name="quantity_out" sum="Total Out Quantity"/>
<field name="quantity_total"/>
</xpath>
</field>
</record>
Solution 1:[1]
Computed fields needs to be stored to make the sum work fine in the grouping.
quantity_in = fields.Float('Quantity In', compute='get_qty_in', store=True)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Henry Ecker |
