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

JSONRPC : search_read with partner_id.country_id=76 but can not display partner_id.country_id

By
cd
on 3/2/15, 5:05 AM 735 views

I use a simple JSONRPC query, to search_read all sale orders created with partners with country = 76 (France)

{"jsonrpc":"2.0","method":"call","params":{"service":"object","method":"execute","args":["admin3",1,"admin","sale.order","search_read",[["partner_id.country_id","=",76]],["name"]]},"id":"1"}

 

It's working fine.

My question is : if it's possible to search on a joined field (partner_id.country_id in this case), why it seems impossible to display the content of this joined field, in the query result ?

 

{"jsonrpc":"2.0","method":"call","params":{"service":"object","method":"execute","args":["admin3",1,"admin","sale.order","search_read",[["partner_id.country_id","=",76]],["name","partner_id.country_id"]]},"id":"1"}

 

Gives only the "name" of sale orders. Syntax problem ? Or real technical impossibility ? And if so, what would be the reason ?

0
cd
On 3/2/15, 11:57 AM

I looked at the server with the SQL debug mode... and it's not really pretty.

I thought that the ORM was capable of doing JOIN queries...

With my example, actually, the system performs first a SELECT on res.partner to retrieve the IDs of all the partners who have country = 76... In my case : a few thousands of IDs... !

And then, another SELECT... on sale.order to find SO with... partner_id among the previous list of IDs.

No JOIN queries, brutal force instead. And therefore, no way to display columns from res.partners with a simple search_read query on sale.order.

If I understand the ORM's logic, I would need to inherit the model sale.order, add a few columns (partner.id.country, or phone, or whatever else) linked to the res.partner model, I would need to work on "on change" stuff, and fix some list views.

Lot of work, isn't it?

Or do I miss something obvious ?

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: 3/2/15, 5:05 AM
Seen: 735 times
Last updated: 3/16/15, 8:10 AM