Quality Inspection show items available in stock entry

We want to make an Incoming Inspection report of items which are entered through material receipt or stock entry.

For this we have made a custom link field in the Quality Inspection Form which links it to Stock entry. We want to write a custom script such that as soon as we select a stock entry the item_code drop down field gets updated and it shows only those items which are present in that stock entry record and not all the items. Any help would greatly be appreciated. Thanks.

I think you should try to change result in this query erpnext.buying.doctype.quality_inspection.quality_inspection.item_query

1 Like

I was thinking of someway to populate a custom select box with child data records of material receipt entry (ie item). And as soon as we select the item in custom select box it should copy that selection to the standard item_code field.

I want to know the script to populate a selection box.

Thanks NMyshuk, I worked your way and copied the script from js file and modified it and then saved it in custom scripts now this code is working for me.

cur_frm.fields_dict[‘item_code’].get_query = function(doc, cdt, cdn) {
if (doc.purchase_receipt_no) {
return {
query: “erpnext.buying.doctype.quality_inspection.quality_inspection.item_query”,
filters: {
“from”: “Purchase Receipt Item”,
“parent”: doc.purchase_receipt_no
}
}
} else if (doc.delivery_note_no) {
return {
query: “erpnext.buying.doctype.quality_inspection.quality_inspection.item_query”,
filters: {
“from”: “Delivery Note Item”,
“parent”: doc.delivery_note_no
}
}
} else if (doc.stock_entry_no) {
return {
query: “erpnext.buying.doctype.quality_inspection.quality_inspection.item_query”,
filters: {
“from”: “Stock Entry Detail”,
“parent”: doc.stock_entry_no
}
}
}
}

1 Like

And does this script work like that way which you wanted?

yes it does. Thanks again for the pointer.