Adding filters (Odoo Studio)

Odoo Studio makes it easy to add filters to a view.

Start by enabling Developer Mode and click on the Studio icon.

Select “Views” and then the Search View. The following screen is displayed:

Now drag the “filter” handle to the list of filters. A pop-up window is displayed for you to define the filter you want to add:

For this example we will select variants with an internal reference that contains “blue”.

Click on “Save”, exit Studio and your filter has been added

We can now check what Odoo Studio has done.

Navigate to Settings / Technical / Views and enter some search criteria (“Studio” on its own will show all views created by Odoo Studio, you can select Search View from the standard filters, and it’s also possible to limit it to views for the product.product model)

A new Search View has been created.

  1. View Name: Odoo Studio: product.product.search.stock.form customization
  2. View Type: Search
  3. Model: product.product
  4. Sequence: 99
  5. Inherited View: product.product.search.stock.form
  6. View inheritance mode: Extension View
  7. Model Data: Odoo Studio: product.product.search.stock.form customization
  8. External ID

The View Name (1) is descriptive and can be anything. The View Type (2) is always Search. The model (3) in this example is product.product (Product Variants) and the Inherited View (5) must be for the same model. This will always be an Extension View (6) because we are “extending” an existing view.

Architecture

<xpath expr="//filter[@name='inactive']"
     position="after"><filter domain="[['default_code','ilike','blue']]"
     name="Blue filter" string="New filter"/></xpath>

This means that a new filter has been added after “inactive” and the domain is that the Internal Reference [default_code] contains ‘blue’

The filter name is actually assigned by Studio, and I changed it manually to “Blue filter”. Note that this new filter could be manually set as a default – that’s done on the Windows Action.

“New filter” isn’t a very good description and the string can be changed to something more meaningful.

2 thoughts on “Adding filters (Odoo Studio)

  1. Thanks for this explanation – does the inheritance in this search view mean that the users that have access to the base view also have acces to this extended view? Or do you have to set this separately on the access rights of this view?

    Like

    1. That’s an interesting question. I can only find one example of a search view that is limited by user access group, and Studio doesn’t seem to be able to handle that.

      Like

Leave a comment