Hello,
I hope you’re well.
I am trying to achieve an automatic creation of delivery note from sales order upon submission.
I have written this script but in order to link the docs, I need to populate the ‘items_to_load’ against the sales order.
The Script
items_to_load = [{“against_sales_order”:doc.name, “sales_order_item”:doc.items}]
for item in doc.items:
items_to_load.append({‘item_code’:item.item_code,‘rate’:item.rate,‘qty’:item.qty,‘uom’:item.uom})
#Create the Delivery Note
frappe.get_doc(dict(
doctype = ‘Delivery Note’,
title = doc.customer,
customer = doc.customer,
company = doc.company,
docstatus = 0,
items = items_to_load,
)).insert(ignore_permissions=True)
frappe.msgprint(msg=(f’Delivery Not for {doc.customer} has been created’),title=(‘Automation’), indicator=‘green’)