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

Creating a new sales.order with Python API

Subscribe

Get notified when there's activity on this post

This question has been flagged
4 Replies
16964 Views
Avatar
Leonardo M. Ramé

Hi, I spend more than three hours trying to understand how to create an order using Odoo 11 and Python with no luck.

The smallest example I came to is this:

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

models = xmlrpclib.ServerProxy('{}/xmlrpc/2/object'.format(url))

order = models.execute_kw(db, uid, password, 'sale.order', 'create', {

     'name': 'new sale order',

})


But I get:


File "./conexion.py", line 29, in <module>

'name': 'new sale order',

File "/usr/lib/python2.7/xmlrpclib.py", line 1243, in __call__

return self.__send(self.__name, args)

File "/usr/lib/python2.7/xmlrpclib.py", line 1602, in __request

verbose=self.__verbose

File "/usr/lib/python2.7/xmlrpclib.py", line 1283, in request

return self.single_request(host, handler, request_body, verbose)

File "/usr/lib/python2.7/xmlrpclib.py", line 1316, in single_request

return self.parse_response(response)

File "/usr/lib/python2.7/xmlrpclib.py", line 1493, in parse_response

return u.close()

File "/usr/lib/python2.7/xmlrpclib.py", line 800, in close

raise Fault(**self._stack[0])

xmlrpclib.Fault: <Fault 2: ''>


What's wrong with my code?.


0
Avatar
Discard
Sehrish

XML-RPC: http://learnopenerp.blogspot.com/2019/10/connecting-to-odoo-using-xml-rpc.html

Avatar
Leonardo M. Ramé
Author Best Answer

Hi Chandni, thanks for your answer.

After running your code (with some changes to update to Python3) I've got this error:

xmlrpc.client.Fault: <Fault warning -- Object sale.order doesn't exists: ''>

About your code, why do you use /xmlrpc/object and /xmlrpc/common instead of /xmlrpc/2/object and /xmlrpc/2/common? which Odoo version are you running?.

Leonardo.



0
Avatar
Discard
Leonardo M. Ramé
Author

I found the solution. I had to install the Sales Management module.

Avatar
Chandni Gandhi
Best Answer

Hello,

When we create sale order, there must be one partner (Customer) Selected for that.

It is not defined in your python script; the mandatory fields are : partner_id, pricelist_id and date_order

Name will be taken automatically, but mandatory information must be added. (Date is taken automatically from default vale setting.)

Try this: (I have created in my local from this, successfully)


#!/usr/bin/env python

# coding: utf-8

import xmlrpclib

import xlrd

dbname = 'test'

username = 'admin'

pwd = 'a'

sock_common = xmlrpclib.ServerProxy ('http://localhost:8069/xmlrpc/common')

sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/object')

uid = sock_common.login(dbname, username, pwd)

account_ids = sock.execute(dbname, uid, pwd, 'sale.order', 'create', {'partner_id': 1, 'pricelist_id':1})

print "Sale Order Created Successfully...!"


If this is helpful to you, please upvote this answer and mark right.


Thanks,

Chandni.

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