Skip to Content
Menu
This question has been flagged
1 Reply
4204 Views

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.

Avatar
Discard
Best Answer

What's in x_enterprises? I mean, what is that x_enterprises[0][2] reference in the domain? When you are using the 'in' operator, the value operand should be a list.

<field name="x_entreprises_ids" string=" " readonly="1" domain="[('id', 'in', [1, 2, 3]]">
Avatar
Discard
Related Posts Replies Views Activity
3
Apr 20
9512
1
Apr 17
17874
1
Feb 24
836
0
Jul 24
1500
0
Mar 23
1088