Odoo Help


Restrict list with active_id

on 6/3/15, 8:28 AM 1,019 views

A have two models with a Many2one relation. In a form view for model 1, I want an action button that opens a list with the records in model 2, that are related to the current record in model 1. (Just like when you view a customer and has a button to show the customer's orders).

I have found a lot of examples, they all say just about the same: Put a context attribute on the button definition like this:

<button ... context="{'search_default_model1_id': active_id, 'default_model1_id': active_id}">

But it doesn't work. I still get ALL the records from model 2 in the list...

I guess this should be quite basic standard behaviour, so what have I missed?

On 6/4/15, 11:42 AM

I found the solution here: http://stackoverflow.com/questions/25420703/odoo-search-default-does-not-work

- the search view for the model must include a "filter_domain" attribute on the field tag like this:

<field name="model1_id" filter_domain="[('model1_id','child_of',self)]" /> 

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/3/15, 8:28 AM
Seen: 1019 times
Last updated: 6/4/15, 4:38 PM