Hide Fields In Advanced Search

Odoo(formerly OpenERP) consists of various modules such as CRM,Sale,Purchase,Account, Warehouese etc. Each module has a predefined structure. Generally Business objects are implemented with python files.Python files consists of various classes where we define columns and methods etc relevant to the module.These columns/fields can be used in views with the help of xml files.Every view has its own structure where we request input from users.

All the fields are always present in advanced search panel in order to retrieve/search information quickly.However Odoo provides us enough flexibility to hide certain fields from users in the advanced search panel for some security purpose in an organization.

For one of our clients,it was a requirement that certain fields should be hidden from advanced search panel in order to give restricted access to their all users.We had implemented this feature with fields_get method in the respected module.

The following code snippet explains how it was implemented with the help of above method.

def fields_get(self, cr, uid, fields=None, context=None, write_access=True):
fields_to_hide = [‘list of fields to hide’]
res = super(class_name, self).fields_get(cr, uid, fields, context)
for field in fields_to_hide:
res[field][‘selectable’] = False
return res

So it is clear from above piece of code that once we reload the view and look into advanced search panel then the fields which we have inserted into fields_to_hide list are not visible and thus our requirement to hide fields from advanced search panel was implemented successfully.

2 thoughts on “Hide Fields In Advanced Search

Leave a Reply