Can I use a Custom script to achieve the following:
Delivery Note Item
has a custom field called po_number
On the New Delivery Note
, when I click From Sales Order
, my delivery note gets populated from the chosen Sales Order
.
I want my Custom Script to copy the tabSales Order
.po_number
to the tabDelivey Note Item
.po_number
custom field.
I achieved this in the past by patching the python source code, but this approach has numerous downsides.
-Jev
For the benefit of others; I ended up patching the update_item
method in apps/erpnext/erpnext/selling/doctype/sales_order/sales_order.py
.
I would still prefer to be able to do this with javascript in the future! 
Full method after patch;
def update_item(source, target, source_parent):
target.base_amount = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.base_rate)
target.amount = (flt(source.qty) - flt(source.delivered_qty)) * flt(source.rate)
target.qty = flt(source.qty) - flt(source.delivered_qty)
target.po_number = source_parent.po_number