Hide Fields In Advanced Search

Hide Fields In Advanced Search

Odoo(formerly OpenERP) consists of various modules such as CRM, Sale, Purchase, Account, Warehouse etc. Each module has a predefined structure. Generally, Business objects implement python files.

 

Python files consist of various classes where we define columns and methods etc relevant to the module. Columns/fields are used in views with XML files. Every view has its own structure where we request input from users.

 

All the fields are always present in the 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 the 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.

 

For example, The following code snippet explains how it was implemented.

 

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 the fields_to_hide list are not visible thus our requirement to hide fields from advanced search panel was implemented successfully.

 

 

 


Author Pic
Author Name: Diwakar Prabhu

If you would like to write to Diwakar Prabhu mail at [email protected].

2 responses to “Hide Fields In Advanced Search”

  1. Avatar Nevpro says:

    Hi Shiv,

    I would like to let you know that this piece of code is working fine and producing desired output without any errors. Kindly provide more details on your issue(as you said it is working properly on your local machine).

  2. Avatar Shiv says:

    Hi,
    I used your code to hide field in Advance Search dropdown and getting an error:

    Can you check following thread: https://www.odoo.com/nl_NL/forum/help-1/question/advance-search-hide-field-error-90821

    and help me to fix the problem. Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *