I have the next table in Odoo, named relationship, which comes from the relation between the table girl and the table boy:
girl_id | boy_id | relationship_type |
1 | 2 | friends |
1 | 3 | siblings |
2 | 7 | lovers |
So:
In the table girl there's a field relationships which is a one2many pointing to the table relationship.
In the table boy there's a field relationships which is a one2many pointing to the table relationship.
In the table relationship there are two fields, girl_id and boy_id, both pointing to the tables girl and boy respectively.
Scenario:
In the forms of girl and boy there's the field relationships. When I add a new relationship for a girl or a boy, a form is opened to fill in the fields of the table relationship (girl_id, boy_id and relationship_type). Imagine I'm in the form of a girl, I click on add a new relationship and the form is opened. I implemented this in order not to see the girl_id (it's invisible but it contains the ID of the current girl). So I can see only two fields (boy_id and relationship_type).
What I want:
Keeping on with the example, if I open the dropdown of boy_id, I'll see all boys, even the ones who are already related to this girl, and that's what I don't want. For example, if I'm adding a relationship to the girl with id 1, I must not see boys with ids 2 and 3, if the girl is the one with id 2, I must not see the boy with id 7.
My code:
<field name="girl_id" invisible="1"/>
<field name="boy_id" domain="[('id', 'not in', girl_id.relationships.boy_id)]"/> <!-- Obviously this does not work -->
<field name="relationship_type"/>
Can anyone help me, please? Thank you!
1) wrong domain, it should not work... 2) why do not use many2many relations between girl and boy? many2many relation seems more convenient to use in your scenario and all this packet of technical problems will disappear with it
Because it's my understanding that it's not possible to store more fields than the IDs in a many2many relationship, is it?