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. For this example the model (3) 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 Internal Reference [default_code] contains ‘blue’

The filter name is actually assigned by Studio, and I changed it manually to “Blue filter”.

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s