How to add Doctype and fields in script report (Add Purchase Invoice in Stock Balance)?

Hello,

We need to add some fields from Purchase Invoice DocType in the Stock Balance report columns Can someone show what server side code is required to link Purchase Invoice Doctype and add the columns subsequently:

And:

Thanks in advance.

You cannot modify this report directly. You will have to make a copy of it and, once you check the prepare_stock_ledger_entries function, you will get some idea of how these Doctypes are added there in popup.