Hwo to create Sales Order using frappe client?

I’m using frappe python client to create Sales Order but for some reason its not getting created. I’m using all mandatory fields for Sales Order (and Sales Order Item). Its not giving any error but its not even getting created.

I am able to create customer, address, contact, lead but creating sales order is not working.
Its returning “None” when I’m trying to print it.
I have attached my code below. Please do let me know if I am missing some fields or anything?

Ignore the values, I’ve changed them before posting here.

client = FrappeClient(apiConfig.erpNextUrl)
client.authenticate(apiConfig.erpNextApiKey, apiConfig.erpNextApiSecret)

sales_order = client.insert({
    "doctype": "Sales Order",
    "order_type": "Sales",
    # "naming_series": "SAL-ORD-.YYYY.-",
    "conversion_rate": 1.00,
    "customer_name": "TEST",
    "company": "TEST-COMPANY",
    "transaction_date": str(date.today()),
    "currency": "INR",
    "selling_price_list": "state price",
    "price_list_currency": "INR",
    "plc_conversion_rate": 1.00,
    "status": "Completed",
    "set_warehouse": "some warehouse",
    "delivery_date": "24-05-2021",
    "grand_total": "₹ 1,800.00",
    "items": [
        {  # mandatory fields on ERP
            "item_code": "some item code",
            "item_name": "name of the item",
            "uom": "Kg",
            "description": "item description",
            "conversion_factor": 1,
            "qty": 3,
            "price_list_rate": "₹ 700.00",
            "rate": "₹ 700.00",
            "amount": "₹ 2,100.00",
            "stock_uom_rate": "₹ 700.00",
            "net_rate": "₹ 600.00",
            "net_amount": "₹ 1,800.00",
            "billed_amt": "₹ 2,100.00",
            "valuation_rate": "₹ 500.00",
            "gross_profit": "₹ 600.00",
            "projected_qty": 31,
            "actual_qty": 42,
            "delivered_qty": 3,
            "ordered_qty": 0,
            "work_order_qty": 0,
1 Like

Hi! I am having a similar issue, I am not able to insert a new sales order using frappe client. Did you find any solution?

This is the error message:

FrappeException: [“Traceback (most recent call last):\n File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 68, in application\n response = frappe.api.handle()\n File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 140, in handle\n doc = frappe.get_doc(data).insert()\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 239, in insert\n self._validate()\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 493, in _validate\n self._validate_mandatory()\n File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 813, in _validate_mandatory\n name=self.name))\nfrappe.exceptions.MandatoryError: [Sales Order, SAL-ORD-2021-00040]: customer\n”]

Maybe you can try to use:

import frappe

doc = frappe.new_doc('Sales Order')
doc.order_type = "Sales"
doc.conversion_rate = 1