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

Hello everyone

After reading the posts: https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-remove-sum-of-total-in-group-by-29666 and https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-used-read-group-method-in-new-api-59798,

I have finished with this code:

@api.multi
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False):
if 'year' in fields:
        fields.remove('year')
    return super(demo_demo, self).read_group(cr, uid, domain, fields, groupby, offset, limit=limit, context=context, orderby=orderby)

I am trying to remove the "sum" of the field "year" from the tree view when I make a group by.

Problem is, I am getting an "index out of range" error.

My field "year" is declared as:

year = fields.Integer('Year')

How can I do that in Odoo v12?

Thank you in advance

Regards

Paulo




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

this post will help you : https://www.odoo.com/forum/help-1/question/how-to-remove-sum-of-total-in-groupby-in-tree-view-154455

just add group_operator=False to the field in .py like this

year = fields.Integer('Year', required=True, group_operator=False)

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

Hello

in xml file year field having sum attribute so it's showing sum of the year, please remove sum attribute your problem will solve.

if you don't want please inherit and remove year field from the view

Ảnh đại diện
Huỷ bỏ
Tác giả

Thank you subbarao,

In fact I do not have "sum" on my tree view on xml, already removed it. Problem is that I really need to have this integer type field on the tree view. I have noticed that even removing the "sum" for the fields, integer and floats always shows a sum of values...

Tác giả

My xml entry for 'year' filed is <field name="year"/>. No sum.

Bài viết liên quan Trả lời Lượt xem Hoạt động
Add sum in Group By Đã xử lý
3
thg 10 21
15586
1
thg 4 25
3423
0
thg 5 24
1618
0
thg 3 24
1282
0
thg 10 22
2454