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

Good Morning,

Hello Everyone i want to hide some filter name from add custom filter drop-down.

so any one suggest me how to achieved this one.

Thanks


อวตาร
ละทิ้ง

Dynamic Add Custom Filter Menu Visibility | Remove Add Custom Filter Menu | Disable Add Custom Filter Menu | Control Access by User Group
This module allows administrators to hide or show the "Add Custom Filter" menu based on user groups, ensuring that only authorized users can apply advanced search filters.
https://apps.odoo.com/apps/modules/16.0/mh_hide_add_custom_filter

คำตอบที่ดีที่สุด

Use this code

@api.model
def fields_get(self, fields=None):
fields_to_hide = ['field_name']
res = super(ClassName, self).fields_get()
for field in fields_to_hide:
res[field]['selectable'] = False
return res
อวตาร
ละทิ้ง
ผู้เขียน

Thanks It's Working.

คำตอบที่ดีที่สุด

Hey Manish, 

You can achieve this by inheriting fields_get function ;) 
like this : 

def get_fields_to_ignore_in_search(self): 
return [Your fields that you want to hide :  'field1', 'field2', 'field3',....]

@api.model
def fields_get(self, allfields=None, attributes=None):
    res = super(YourModel, self).fields_get(allfields, attributes=attributes)
    for field in self.get_fields_to_ignore_in_search():
        if res.get(field):
           res.get(field)['searchable'] = False
    return res

Upvote if this helps. If not, you can write back for further analysis. Regards.
อวตาร
ละทิ้ง
ผู้เขียน

Thanks for Tip

คำตอบที่ดีที่สุด

Hello, For version 14 and above, you can use this code.

@api.model
def fields_get(self, fields=None):
fields_to_hide = ['color', 'amount_due']
res = super(ProjectProject, self).fields_get(fields)
for field in fields_to_hide:
if field in res:
res[field]['searchable'] = False
return res

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด
Hello, 'selectable' property doesn't seem to be available in Odoo15. Any other way to do this?? Hide fields from Cutom filter list?
res[field]['selectable']


อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Hello,

Using this one we have unwanted log note. when I am creating any new ticket.

อวตาร
ละทิ้ง

hello Manish Kumar Bohra,
I'm facing the same issue after inhereting the fields_get methodei have unwanted logs created each time i open a sale_order did you manage to fix this please?
Thanks

Related Posts ตอบกลับ มุมมอง กิจกรรม
0
พ.ย. 18
2717
Filters in multiple companies แก้ไขแล้ว
1
พ.ค. 25
767
ADD PROPERTIES แก้ไขแล้ว
1
พ.ค. 25
798
2
มี.ค. 25
835
2
พ.ค. 25
4982