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

How to set dynamically the domain in a field depending on the content on another? (SOLVED)

By
Pau Ubach
on 9/18/14, 2:26 AM 666 views

I have a list and form views, I can select one element in the list to access the form.

The form has fields A and B (both many2one), when A has one value B must filter by these value. 

When I change the value in A, I can use function on_change to set the domain in B. 

The problem comes when I access this form view from the list and A already has a value, I don't know how to set the domain then, I have tried with default_get and read functions, but I'm not successful.

0
Pau Ubach
On 9/18/14, 2:39 AM

I was making it too complicated, I found the solution on https://www.odoo.com/forum/help-1/question/problem-with-a-domain-many2one-22314

 

It was enough adding the domain to the field, the problem is that I was writing it as: 

domain=[('B1.B2', '=', A)]

And it raised an error because A wasn't recognized. I changed to 

domain="[('B1.B2', '=', A)]"

Now it works very smooth.

0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
On 9/18/14, 2:28 AM

Pau, you need to developed an on_change method on the field which change will trigger the domain change.  This page provides an overview of how on_change can be developed.

Thanks John, I don't have any problem with the on_change. If the user changes a field, then there's no problem. The problem is if the user doesn't change the field. The field has content already, but nobody changed the content.

Pau Ubach
on 9/18/14, 2:31 AM

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: 9/18/14, 2:26 AM
Seen: 666 times
Last updated: 3/16/15, 8:10 AM