Add search_context for specific model on a Reference field

In a model I have a Reference field to link different records from different models. This works as expected. But now I want to filter down the list of records for a specific model.

So when a user select as Model ‘’ (Work Effort) I want to filter out all the ‘’ records which has state ‘done’. Because I don’t need them. But for other models this should not happen because some of them don’t have a field state and will fail.

Is this possible? And if so, any example available?


Yes, you should build a domain that depends on the target module. There is an example implemented on the sale_compaint module.

Hope it helps!

It worked perfectly! Thanks!

1 Like