Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Filtering many2many with one2many odoo 8

By
Munesh Nandwani
on 9/5/15, 3:18 PM 1,031 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.

0
Miku Laitinen
On 9/16/15, 9:09 AM

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]]">

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 9/5/15, 3:18 PM
Seen: 1031 times
Last updated: 9/16/15, 9:09 AM