Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
12610 Lượt xem

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?

 

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất


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')
Ảnh đại diện
Huỷ bỏ
Tác giả

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?

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 11 24
44228
1
thg 4 21
11644
1
thg 5 25
842
4
thg 1 24
23068
Attrs attribute Đã xử lý
2
thg 1 24
2405