I have created Many2Many with:
name: x_entreprises
Field type: res.partner
model: lead/opportunity
Here is the code inside lead/opportunity
<group string="Entreprises">
<field name="x_entreprises" domain="[('customer','=',True)]" string=" ">
<tree string="Entreprises" editable="top">
<field name="id"/>
<field name="x_partner_code"/>
<field name="name"/>
</tree>
</field>
</group>
Then I created One2Many with
name: x_entreprises_ids
Object relation: crm.lead
Relation field: x_entreprises
model: res.partner
Here is the code inside res.partner
<group string="Entreprises">
<field name="x_entreprises_ids" string=" " readonly="1" domain="[('id', 'in', x_entreprises[0][2])]">
<tree>
<field name="id"/>
<field name="name"/>
<field name="stage_id"/>
<field name="planned_revenue" sum="total"/>
</tree>
</field>
</group>
</page>
Inside that Many2Many field i am able to add company that take part on the opportunities. When I access the customer form, I should be able to see the opportunities that the customer is involved in.
The error: when I add more then 1 customer inside that many2many fields and then I go to that Customer form I will have singleton error (Expected singleton: res.partner(52350, 52353)). I believe my domain inside One2Many field is wrong.
Please let me know, how to solve this issue. Thank you so much.