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

Hello,

I made a graph and pivot view for my model. By default all fields(that are numeric as well as stored) are available in Measures drop-down. I want to exclude some fields.

How can i do that?



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

This seems to be hardcoded in the graph_view.js.. But one way you can hack around this is to use 
def fields_get override in python file.

If the fields are not needed in any of Measures, GroupBy, Export, AddCustomFilter, then you can use the allFields parameter of the super to control the list. To control individually, you can use different attributes of each field. Example (V 13.0):

@api.model
def fields_get(self, allfields=None, attributes=None):
res = super(ResPartner, self).fields_get(allfields, attributes=attributes)
not_selectable_fields = set(res.keys()) - set(self.selectable_fields)
for field in not_selectable_fields:
res[field]['selectable'] = False # to hide in Add Custom filter view
res[field]['sortable'] = False # to hide in group by view
res[field]['exportable'] = False # to hide in export list
res[field]['store'] = False # to hide in 'Select Columns' filter in tree views
return res
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
groups attribute can be used
<field name="partner_id" groups="base.group_user"/>

 

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

Hello Dhaval,


Mentions those field which you want to in measurement.

like <field name="your_field" type="measure"/> in your pivot view.

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

Thanks for reply But this is not what i want. Your solution only select specified field by default. Other fields are still there in the drop-down list. I want to remove them.

can you find any solution for this? I need to this too.

Câu trả lời hay nhất

Hello, 

If you want to remove some of fields from the measure drop-down list, you need to remove their fields in the python code.

For exemple, if you want to remove a measure called "Price", go to the classe of the report in python and search for the field with the description "Price" and remove/comment it. and also check if this field is used in the xml of the report in pivot view, and remove it from the xml

Don't forget to reset the Odoo server and upgrade your module.

I hope that solution will help you.



 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 11 21
2443
0
thg 2 18
4727
14
thg 1 25
123514
2
thg 9 23
9842
1
thg 2 22
6862