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.

1

Create extra field on many2many relationship

By
Rafael
on 8/31/13, 10:32 AM 4,222 views

Hello everyone. Let's see if someone can help me. I created a new class called "Course". I created Many2Many relationship between "course" and "Partner". It works fine. I can add to a partner several courses. But I need to add a field to the form, so that when you would add a course to a partner, you ask an expiration date, to take partners_courses_rel Table 3 courses, the id of the partner, the id of the course, and the expiration date . Someone can tell me how to add the date field in the relationship? Thank you very much.

Hi Rafael, instead of do that, you can create new object which have 2 field (contain object "cource" and "partner"), a field date, a field many2one into curent form (object contain your many2many field). Then you add a field one2many (reference new object) into current form.

OpenERP Vietnam
on 8/31/13, 12:05 PM

Ok. I did as I have you told, but now I have a problem. I created the relationship between courses and courses_partners, and between courses_partners and partners, and I are the two date fields that I needed, but now when I get the drop down list to choose a course and choose one, then I will choose another, I reappears in the dropdown list the course he had chosen earlier. Would need to remove from the list the courses that I have selected. How could I?

Rafael
on 9/2/13, 8:21 AM
0
Rafael
On 8/31/13, 9:59 PM

Ok. So as I have understood, now I have this:

Courses ----m2m----> Partners

and I think I have to do this:

Courses ----o2m----> Courses_partners ----m2o---->Partners

Is correct? Thank you very much for helping me because I'm so lost...!

Hi Rafael, it is correct.

OpenERP Vietnam
on 8/31/13, 10:39 PM

Ok. I did as I have you told, but now I have a problem. I created the relationship between courses and courses_partners, and between courses_partners and partners, and I are the two date fields that I needed, but now when I get the drop down list to choose a course and choose one, then I will choose another, I reappears in the dropdown list the course he had chosen earlier. Would need to remove from the list the courses that I have selected. How could I?

Rafael
on 9/2/13, 8:19 AM
0

Brett Lehrer

--Brett Lehrer--
1252
| 5 4 8
Milwaukee, United States
--Brett Lehrer--
Director of IT and open source enthusiast.
Brett Lehrer
On 8/31/13, 6:48 PM

OpenERP Vietnam is correct. Relational tables for many2many fields are handled entirely by the ORM in the background, you cannot just add another column. Make a new object, link the two, and add a field for the expiration.

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: 8/31/13, 10:32 AM
Seen: 4222 times
Last updated: 3/16/15, 8:10 AM