How do I create child records using wn-client?

Using github.com/webnotes/wn-client

What is the correct way to pass in child records when creating a new object? The below example for creating a sales order, (I have tried many variations) with one Sales Order Line item. This example fails with the error MandatoryError: sales_order_details

s = [{
    'doctype': 'Sales Order',
    'name': 'tes name',
    'company': 'company',
    'customer': 'client',
    'notes': 'notes',
    'currency': 'EUR',
    'price_list_currency': 'EUR',
    'plc_conversion_rate,': '1.0',
    'selling_price_list': 'Standard Selling',
    'order_type': 'Sales',
    'transaction_date': '2013-09-11 00:00:00',
    'delivery_date': '2013-09-14 00:00:00',
    'fiscal_year': '2013-2014',
    'sales_order_details': [{
        'doctype': 'Sales Order Item',
        'item_code': 'ELTEST',
        'item_name': 'some name',
        'sales_order_details': 'foo',
        'description': 'humbug',
        'qty': 3,
        'export_rate': 2,
        }]
    }]
print(wn.insert(s))

Thanks all,
-Jev



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
I eventually worked this out be grokking the source code. For other readers, here's an example that works;

wn.insert([{
    'doctype': 'Sales Order',
    'name': 'tes name1',
    'company': 'company',
    'customer': 'client',
    'notes': 'notes',
    'currency': 'EUR',
    'price_list_currency': 'EUR',
    'selling_price_list': 'Standard Selling',
    'order_type': 'Sales',
    'transaction_date': '2013-09-11 00:00:00',
    'delivery_date': '2013-09-14 00:00:00',
    'fiscal_year': '2013-2014',
    }, {
    'parentfield': 'sales_order_details',
    'doctype': 'Sales Order Item',
    'item_code': 'ELTEST',
    'item_name': 'some name',
    'description': 'humbug',
    'qty': 3,
    'export_rate': 2.0,
    }, {
    'parentfield': 'sales_order_details',
    'doctype': 'Sales Order Item',
    'item_code': 'ELTEST',
    'item_name': 'some name',
    'description': 'humbug2',
    'qty': 4,
    'export_rate': 2.5,
    }])




On Tuesday, December 31, 2013 10:14:45 AM UTC-8, Jev Björsell wrote:
Using github.com/webnotes/wn-client

What is the correct way to pass in child records when creating a new object? The below example for creating a sales order, (I have tried many variations) with one Sales Order Line item. This example fails with the error MandatoryError: sales_order_details

s = [{
    'doctype': 'Sales Order',
    'name': 'tes name',
    'company': 'company',
    'customer': 'client',
    'notes': 'notes',
    'currency': 'EUR',
    'price_list_currency': 'EUR',
    'plc_conversion_rate,': '1.0',
    'selling_price_list': 'Standard Selling',
    'order_type': 'Sales',
    'transaction_date': '2013-09-11 00:00:00',
    'delivery_date': '2013-09-14 00:00:00',
    'fiscal_year': '2013-2014',
    'sales_order_details': [{
        'doctype': 'Sales Order Item',
        'item_code': 'ELTEST',
        'item_name': 'some name',
        'sales_order_details': 'foo',
        'description': 'humbug',
        'qty': 3,
        'export_rate': 2,
        }]
    }]
print(wn.insert(s))

Thanks all,
-Jev



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.
This one surely looks nicer :)

- Rushabh

On Tuesday, December 31, 2013 11:44:45 PM UTC+5:30, Jev Björsell wrote:
Using github.com/webnotes/wn-client

What is the correct way to pass in child records when creating a new object? The below example for creating a sales order, (I have tried many variations) with one Sales Order Line item. This example fails with the error MandatoryError: sales_order_details

s = [{
    'doctype': 'Sales Order',
    'name': 'tes name',
    'company': 'company',
    'customer': 'client',
    'notes': 'notes',
    'currency': 'EUR',
    'price_list_currency': 'EUR',
    'plc_conversion_rate,': '1.0',
    'selling_price_list': 'Standard Selling',
    'order_type': 'Sales',
    'transaction_date': '2013-09-11 00:00:00',
    'delivery_date': '2013-09-14 00:00:00',
    'fiscal_year': '2013-2014',
    'sales_order_details': [{
        'doctype': 'Sales Order Item',
        'item_code': 'ELTEST',
        'item_name': 'some name',
        'sales_order_details': 'foo',
        'description': 'humbug',
        'qty': 3,
        'export_rate': 2,
        }]
    }]
print(wn.insert(s))

Thanks all,
-Jev



Note:

 

If you are posting an issue,

  1. We should be able to replicate it at our end. So please give us as much information as you can. Please see it from the point of view of the person receiving the communication.
  2. Paste your code at http://pastebin.com or http://gist.github.com and send only the URL via email
  3. For sending images, use http://imgur.com or other similar services. Do not send images as attachments. Links are good. Same goes for any file you are going to send.

     

    End of Note



    You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.

    To unsubscribe from this group and stop receiving emails from it, send an email to erpnext-developer-forum+un...@googlegroups.com.

    For more options, visit https://groups.google.com/groups/opt_out.