Fetch item code using custom barcode field in Stock Entry Detail ERPNext v4

Please, please, can someone help me with this; in v5+; we could use a custom field and a script to fetch for instance; the barcode in the item price screen, so its possible to add a barcode field and on selecting the item, we can see the barcode load along with the description.

We need to add a barcode field as is available in v5 in the stock entry details form (Items); such that on scanning the barcode; the item code gets filled with the item code and other details. I have tried the cur_rm.add_fetch(); it didn’t work; can someone please describe how we could add this custom script to the Stock Entry Detail form so that on scanning the barcode; the item code and other items get pulled in; then if item doesn’t exist item will be created. Just the same functionality of v5 using custom scripts. Thanks a lot.