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

External API Error - Getting sale.order information

Subscribe

Get notified when there's activity on this post

This question has been flagged
apiapiclient
3 Replies
5468 Views
Avatar
xenic82661

Hi
I'm testing odoo external APi and I'm getting this error when i execute this last command:
models.execute_kw(db, uid, password, 'sale.order', 'search', [[]])
[4, 3, 1]

models.execute_kw(db, uid, password, 'sale.order', 'read', [1])

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\xenic82661\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", line 1116, in __call__
return self.__send(self.__name, args)
File "C:\Users\xenic82661\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", line 1458, in __request
response = self.__transport.request(
File "C:\Users\xenic82661\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", line 1160, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Users\xenic82661\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", line 1176, in single_request
return self.parse_response(resp)
File "C:\Users\xenic82661\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", line 1348, in parse_response
return u.close()
File "C:\Users\xenic82661\AppData\Local\Programs\Python\Python39\lib\xmlrpc\client.py", line 662, in close
raise Fault(**self._stack[0])
xmlrpc.client.Fault: \n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/home/odoo/src/odoo/saas-16.1/odoo/addons/base/controllers/rpc.py", line 148, in xmlrpc_2\n response = self._xmlrpc(service)\n File "/home/odoo/src/custom/trial/saas_trial/controllers/main.py", line 266, in _xmlrpc\n res = super(OdooRPC, self)._xmlrpc(service)\n File "/home/odoo/src/odoo/saas-16.1/odoo/addons/base/controllers/rpc.py", line 129, in _xmlrpc\n return xmlrpc.client.dumps((result,), methodresponse=1, allow_none=False)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 981, in dumps\n data = m.dumps(params)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 514, in dumps\n dump(v, write)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 536, in __dump\n f(self, value, write)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 589, in dump_array\n dump(v, write)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 536, in __dump\n f(self, value, write)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 607, in dump_struct\n dump(v, write)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 536, in __dump\n f(self, value, write)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 607, in dump_struct\n dump(v, write)\n File "/usr/lib/python3.10/xmlrpc/client.py", line 526, in __dump\n raise TypeError("cannot marshal %s objects" % type(value))\nTypeError: cannot marshal objects\n'>

 
BTW for res.partner is working without any problem
models.execute_kw(db, uid, password, 'res.partner', 'search', [[]])
[9, 10, 8, 7, 1, 3]

models.execute_kw(db, uid, password, 'res.partner', 'read', [9])

[{'id': 9, 'message_is_follower': True, 'message_follower_ids': [...], 'message_partner_ids': [...], 'message_ids': [...], 'has_message': True, 'message_needaction': False, 'message_needaction_counter': 0, 'message_has_error': False, ...}]

0
Avatar
Discard
Niyas Raphy (Walnut Software Solutions)

seems the shared one line of code is fine for me, to debug more to cross check again, may be this helps: https://www.odoo.com/documentation/16.0/developer/api/external_api.html

Avatar
Mikhail Zuev
Best Answer

We are experiencing the same error. Could you please tell me if you solved it?

0
Avatar
Discard
Mikhail Zuev

odoo support suggested specifying the exact orders attributes/fields that you want to download
this solved our issue

import xmlrpc.client

url = '<insert_own_db_url>'
db = '<insert_db_name>'

## username and password for uid performing search read
username=''
password=''

common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
common.version()

uid = common.authenticate(db, username, password, {})

models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
models.execute_kw(db, uid, password,
'sale.order', 'search_read',
[[['id', '<', 10]]], # Replace with your own search domain
{'fields': ['id', 'name']}) # replace with necessary fields that you would like to read

Avatar
xenic82661
Author Best Answer

Thanks for your reply Bennie, I already executed the 'search' and this record exists

0
Avatar
Discard
Avatar
Bennie
Best Answer

You must be used to "search" method before "read" method.
You can used to "read" method when you know exactly recordset of model. Let's reference document for detail.

ids = models.execute_kw(db, uid, password, 'res.partner', 'search', [[['is_company', '=', True]]], {'limit': 1})
[record] = models.execute_kw(db, uid, password, 'res.partner', 'read', [ids])


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 can we accept a clients orders using the Odoo API
api apiclient
Avatar
0
Jul 21
2512
How to send data from odoo to another oracle database using AP I? mettre a jours ou creer ou suprimer les donnes d une application oracle externes a partir de odoo
api send apiclient
Avatar
Avatar
1
Jan 23
3433
External API Auth problem
api apiclient v15
Avatar
0
Dec 21
3846
How add new Log Note to Lead/Opportunity using API Solved
api apiclient odoov12
Avatar
Avatar
1
Jun 20
8987
how can using odoo api without session id i want using jwt authentication ?
api apiclient ReactJs
Avatar
0
Nov 19
7203
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