Need to Fetch Project data from Purchase Order into Stock Entry

Hi all,

We have to fetch Project data from the Purchase order item table into stock entry document.
For that I have written code like below, but it doesn’t work. Kindly help us.
Here is code and screenshot,

frappe.ui.form.on(‘Stock Entry’, {
refresh: function(frm) {
frm.doc.purchase_order((data) => {
if((!data.project) && data.purchase_order) {
frappe.db.get_value(‘Purchase Order Item’, {name: data.purchase_order_item}, ‘project’, (r) => {
var project = r && r.project
frappe.model.set_value(data.doctype,, ‘project’, project)
frappe.model.set_value(data.doctype,, ‘project’, project)

in the Stock Entry Item table or main Stock Entry form?

If in the Item table, then won’t just creating a field with the same name as in the Purchase Order by just sufficient for data fetching? Please give it a try.


Just we need to fetch the project data from the purchase order to Stock entry, no matter either it is in Main stock entry form or Stock entry item table.

But currently the project field is in Purchase order item table in Purchase order document, so if we fetch the project data in Stock entry item table means better.