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.

2

one2one fields in views

By
Allison
on 3/19/13, 1:30 PM 2,875 views

I have a need for a one2one relationship between project.project and crm.lead and display the link in each object's form view. I have put my many2one field into crm.lead and added it to the Opportunity Form View. I now need to do the same thing to the Project Form View, but the only way I can get that relationship to display is by using a one2many field in project.project. I saw in other forum posts that _inherits need to be set, however when I do that and put the field in my view I get "Automatically created field to link to..." in the label section and no value.

Has anyone successfully created this one2one relationship with links in the object views?

1
Allison
On 3/20/13, 2:47 PM

The closest I came to achieving this was adding a many2one field on crm.lead and a functional field on project.project that returns the corresponding crm.lead (if there is one).

I'm having a similar problem and cannot find the answer. my model has a many2one field to a related "category" model. On the form this field shows up as "model.category id" since it doesn't have a name field. So I write my own name_get function and now have my derived name on the form and it links to the category instance like before. However, now when I edit the form and change the category record instead of the id being sent back for the onchange event I get the derived name now. Source on the form page shows no value attribute on the <option> tags. And my name_get returns (record.id, name).

mike
on 3/22/13, 1:03 PM
0
Kobus Wolvaardt
On 6/24/15, 5:18 AM

Hi,

I am unsure if it helps, but you can inherit from another model in a way that it the second model is one to one in embedded with the first. Your DB has two tables, but the view treats them as one. I am unsure if there is actually a link back from the inheretid model, but I think this is what is done with res_user vs res_partner... the user iniherits and actually creates a res_partner.

See in:

https://www.odoo.com/forum/how-to/developers-13/the-different-openerp-model-inheritance-mechanisms-whats-the-difference-between-them-and-when-should-they-be-used-46

The heading Polymorphic data using _inherits

Not exactly one2one, but might still be what you need.


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

0 follower(s)

Stats

Asked: 3/19/13, 1:30 PM
Seen: 2875 times
Last updated: 6/24/15, 5:18 AM