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

Change many2one relation based on a condition

By
emonrockz
on 8/21/14, 8:07 AM 768 views

Hi All,

I have 3 classes (say class1, class2, class3). In class1, I have a checkbox (say cb1) and a many2one field (say field1). If the check box is True, the many2one field must load data from class2 (fields.many2one('class2','field1')). if checkbox is False, the many2one field must load data from class3 (fields.many2one('class3','field1')). Is it possible. Please help me with a solution. Thank you in advance.

 

 

Regards,

Emon.

 

2

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 8/21/14, 9:28 AM

Based on your requirement form view add  two different class many2one field. Based on condition hide one and shows others.

Example,

'class2_id':fields.many2one('table1', 'Table1'),

'class3_id:fields.many2one('table2', 'Table2'),

<field name="class2_id" attrs="{'invisible':[('ischeck','=',False)]}"/>

<field name="class3_id" attrs="{'invisible':[('ischeck','=',True)]}"/>

0
emonrockz
On 9/15/14, 6:11 AM

Thank you for the answer Prakash. But In my scenerio, I have only one field which must be linked with multiple classes. It must be saved in the single column in the table.

In single column using domain you can filter value.

Prakash
on 9/15/14, 6:28 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: 8/21/14, 8:07 AM
Seen: 768 times
Last updated: 3/16/15, 8:10 AM