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 |
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.
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.
<field name="girl_id" invisible="1"/>
<field name="boy_id" domain="[('id', 'not in', girl_id.relationships.boy_id)]"/> <!-- Obviously this does not work -->
Can anyone help me, please? Thank you!