Skip to content

Instantly share code, notes, and snippets.

@rmehta
Last active June 15, 2020 10:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rmehta/5418237 to your computer and use it in GitHub Desktop.
Save rmehta/5418237 to your computer and use it in GitHub Desktop.
from webclient import *
server = "http://myaccount.erpnext.com/server.py"
user = "your user name"
password = "your password"
login()
customer = get_doc("Customer", customer_name)
# make customer if required
if not customer:
response = insert([{
"doctype":"Customer",
"customer_name": customer_name,
"customer_type": "Company",
"customer_group": "Standard Group",
"territory": "Default",
"customer_details": "some unique info",
"company": "Alpha"
}])
# make invoice
resonse = insert([
# main
{
"naming_series": "_T-Sales Invoice-",
"company": "_Test Company",
"conversion_rate": 1.0,
"currency": "INR",
"debit_to": "_Test Customer - _TC",
"customer": "_Test Customer",
"customer_name": "_Test Customer",
"doctype": "Sales Invoice",
"due_date": "2013-01-23",
"fiscal_year": "_Test Fiscal Year 2013",
"grand_total": 561.8,
"grand_total_export": 561.8,
"net_total": 500.0,
"plc_conversion_rate": 1.0,
"posting_date": "2013-01-23",
"price_list_currency": "INR",
"price_list_name": "_Test Price List",
"territory": "_Test Territory"
},
# items
{
"amount": 500.0,
"basic_rate": 500.0,
"description": "138-CMS Shoe",
"doctype": "Sales Invoice Item",
"export_amount": 500.0,
"export_rate": 500.0,
"income_account": "Sales - _TC",
"cost_center": "_Test Cost Center - _TC",
"item_name": "138-CMS Shoe",
"parentfield": "entries",
"qty": 1.0
},
# taxes
{
"account_head": "_Test Account VAT - _TC",
"charge_type": "On Net Total",
"description": "VAT",
"doctype": "Sales Taxes and Charges",
"parentfield": "other_charges",
"tax_amount": 30.0,
},
{
"account_head": "_Test Account Service Tax - _TC",
"charge_type": "On Net Total",
"description": "Service Tax",
"doctype": "Sales Taxes and Charges",
"parentfield": "other_charges",
"tax_amount": 31.8,
},
# sales team
{
"parentfield": "sales_team",
"doctype": "Sales Team",
"sales_person": "_Test Sales Person 1",
"allocated_percentage": 65.5,
},
{
"parentfield": "sales_team",
"doctype": "Sales Team",
"sales_person": "_Test Sales Person 2",
"allocated_percentage": 34.5,
},
)]
@dawoodjee
Copy link

What is webclient in this case @rmehta?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment