Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

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

Subscribe

Get notified when there's activity on this post

This question has been flagged
jsonrpc
3 Replies
14072 Views
Avatar
cd

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
Avatar
Discard
Avatar
Prakash
Best Answer

https://www.odoo.com/documentation/12.0/webservices/odoo.html

"sale.order" models field name defined in fields values in dictionary. If country_id field not available in the sale.order, In that case odoo custom module inherit sale.order and add related field country_id add store= True parameter it will save country_id data in database.

Domain can check res_partner.country_id, but cannot display res_partner field with dot notation. country_id field should be available in sale.order table, then only display. In that case create related field and display.

Example,

class SalesOrdercountry(models.Model):
_inherit = 'sale.order'

country_id = fields.Many2one('res.country', related='partner_id.country_id', string='Country', store=True)
models.execute_kw(db, uid, password, 'sale.order', 'search_read', [[['partner_id.country_id.id','=',79]]], {'fields': ['name', 'country_id']})
0
Avatar
Discard
Avatar
Hutama
Best Answer

First try

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

You should get all data. 


Then

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

You should get name and partners country data.

Sorry if the code wrong I edit it from my phone. It work something like that

And thank you btw , your code example make my json works 

0
Avatar
Discard
Avatar
cd
Author Best Answer

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 ?

0
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
How to Fetch Product Images via JSON-RPC in Odoo?
jsonrpc
Avatar
Avatar
1
Feb 25
2371
odoo 7 & jsonrpc? is this really supported? Solved
jsonrpc
Avatar
Avatar
2
Mar 15
6279
jsonrpc to create/update data in odoo 7?
jsonrpc
Avatar
0
Mar 15
4698
Odoo JSON-RPC API
api jsonrpc
Avatar
0
Feb 25
2743
Usage of authenticate in JSON-RPC external API
jsonrpc odoo17
Avatar
Avatar
Avatar
Avatar
3
Sep 24
14026
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now