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

[7] onchange domain on field in one2many

By
HateCamel
on 7/3/15, 9:54 AM 724 views

I created onchange method for my field location_id in one2many list that changes the domain of prodlot_id. Everything works fine, except for the fact that it changes the domain for all the prodlot_id fields in my one2many list.

Is there a way to change domain only for the prodlot_id of the record I changed?

1

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/10/15, 4:25 AM

Or you could use another field(invisible and dummy many2many field) to filter the prodlot_id based on this new field, the value of that field you need to compute using the onchange itself, instead of returning a domain for the one2many field you need to return the value for the whole field dummy, but you don't return a new domain, your field domain is using the dummy field as a filter

0

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 7/3/15, 10:12 AM


add one more condition to your domain, using AND operator, something like:  


[ '|','&', ( ...your condition... ), ('prodlot_id','in',[ id_of_record_to_apply_domain_to ]),('prodlot_id','not in',[ id_of_record_to_apply_domain_to ])]
-it's how you can apply domain to the one particular record. but still, the domain will be same in all records.

If you want to have different domain per record, I'm afraid that it should not be possible by setting domain using onchange. most probably computed one2many field is the appropriate solution to your requirement in this case, rather then change domain of field. if you want to have different one2many list per record, then make this one2many field computed field and apply your application logic inside compute function in order to have correct list per record.



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

2 follower(s)

Stats

Asked: 7/3/15, 9:54 AM
Seen: 724 times
Last updated: 7/10/15, 4:25 AM