Odoo Help

Welcome!

This community 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.

0

Restrict list with active_id

By
CGS
on 6/3/15, 8:28 AM 557 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?

0
CGS
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)]" /> 

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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