Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5208 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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]]">
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
3
thg 4 20
10912
1
thg 4 17
19488
1
thg 1 25
1809
1
thg 2 24
2110
0
thg 7 24
3154