[Dev Help] Get Child Items from Sales Order in Delivery Note

Currently, While using “Get Items From” button in Delivery Note using a Sales Order, there is no option to select child items of that document.

We can only select the parent “Sales Order” document and all items inside it are copied over to the Delivery Note. There should be an option to filter on items and get only selected items in the delivery note. As Sales Order generally contains a lots of items and delivery is made according to the operational constraints, so mostly what we have to do is copy all items from multiple Sales Order and then manually delete the ones that are not required. In our case, ERPNext is taking a lot of beating as we have multiple 7 pages long Sales order and doing this process is intensive for both ERPNext and our employees.

Fortunately, ERPNext does have a potential way to solve this. What we can do is, add a checkbox for “Select Sales Order Item” , similar to the checkbox in “Material Requests” multi-dialog while getting items in Purchase Order. According to me this check box should be there by default in the Sales Flow too. And as this would be optional it will keep the original flow intact, so no harm in adding it.

So Let’s Start

Firstly, we need to add the checkbox which will enable us to select child items from the sales order documents. When we select the “Get Items From” → “Sales Order” in Delivery Note, the dialog that pops up is a Multi-Select Dialog. Please Read this part thoroughly : Multi-Select Dialog
So this basically tells that there is a way to select child items.

I just searched “Get Items From” inside the delivery_note.js under erpnext->stock->doctype->delivery_note . After that we can add the lines which have been marked with red dots to enable child item selection.

After this you can see there is an option for selecting the child item under the sales order multi select dialog.

This is what I exactly wanted. But this is just the UI part. We actually want to be able to select these items and get it linked to the delivery note. And in this part I need some help from the community. I am currently still exploring how this could be done, for reference you can check how is it being done inside material request case. If anyone has any hints for me that would be great and this could be a small but valuable utility to use in the ERPNext Sales Flow.

I will keep this section updated with my findings.