This question has been flagged
1 Reply
2403 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?

Avatar
Discard
Author Best Answer

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)]" /> 
Avatar
Discard