Hi,
I want to create a Delivery Note using Client Script
frappe.db.insert({
'doctype': 'Delivery Note',
'customer': frm.doc.customer,
'set_warehouse': frm.doc.set_warehouse,
'selling_price_list': 'Standard Selling',
'items': frm.doc.items.map((item) => {
return {
'item_code' : item.item_code,
'item_name' : item.item_name,
'rate' : item.rate,
'qty':item.qty
};
})
}).then(doc => {
frappe.show_alert("Delivery Note is created successfully")
});
but the above code creates a delivery note without being connected with the current sales order, the result is
and I want to connected with sales Order
as following
you can try adding this
'sales_order': frm.doc.sales_order, // set the sales_order field to the name of the Sales Order
Or You can also use the set_value
method to set the sales_order
field after the Delivery Note
document has been inserted, like this:
// set the sales_order field of the newly inserted Delivery Note
frappe.model.set_value(doc.doctype, doc.name, 'sales_order', frm.doc.sales_order);
frappe.show_alert("Delivery Note is created successfully")
});
1 Like
Thanks you for helping, I try your way but is not working as I want,
in the last I find the solution is by using against_sales_orde
that put it in (Delivery Note Items), must be set it in
'items': frm.doc.items.map((item) => {
return {
'item_code' : item.item_code,
'item_name' : item.item_name,
'rate' : item.rate,
'qty':item.qty,
'against_sales_orde': frm.doc.name
};
})
2 Likes