Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
12543 มุมมอง

Hi,

by clicking on a group in a search view, the records in the list view get grouped. The records representing a group automatically sums integer or float fields. But is there a way to change this aggregation behavior? For certain fields, I would like to see the average instead of the sum. 
Is there a way?

 

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด


Hi Gregor Heger

You need to define the field group_operator that by default is sum even if you don't specify it. That it's defined directly in the field, like:

count = fields.Integer('Count', group_operator='avg')
อวตาร
ละทิ้ง
ผู้เขียน

It works! Thank you very much!

Happy to help

How can add some other calculation in group_by. For an example if we need division on two grouped value, how we can do that?

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
พ.ย. 24
44126
1
เม.ย. 21
11584
1
พ.ค. 25
791
4
ม.ค. 24
22978
Attrs attribute แก้ไขแล้ว
2
ม.ค. 24
2344