Help

2

Hide Filter name from Add Custom Filter Drop-down ?

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


Avatar
Discard
2 Answers
5
Avatar
Odoo Mates
Best Answer

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
2 Comments
Avatar
Discard
Avatar
Manish Kumar Bohra
-

Thanks It's Working.

Avatar
Manish Kumar Bohra
-

Hello,

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

1
Avatar
Ibrahim Boudmir
Best Answer

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.
1 Comment
Avatar
Discard
Avatar
Manish Kumar Bohra
-

Thanks for Tip