Want to show name on purchase order who make it

I want settings in ERP that name must show on purchase order who make it

1 Like

You can add field to show the same. Goto Customize Form > Enter document name as ā€œPurchase Orderā€. Add a field in the table. To know more about the same, check the following link: Customize Form

Is there a way to add the ā€œlast updated byā€ userā€™s name on the PO? or the ā€œSubmitted byā€ userā€™s name ?

Yes! But you will have to write a custom script to achieve this. Kindly refer this link to more about custom scripts.

https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts

Need Setting that fetch user name in Purchase Order who make it.

Hello @sachin1. You can see the owner in the bottom most part of the doctype . However if you want to see the owner in the printout we can create a custom script for that.

Hello @Sachin1,
While creating Purchase Order you will see you have owner and modified_by i.e. standard fields. Using cur_frm.doc.owner you will get the owner of the doc . So with the custom script you can use this field to display the owner name or else required on the doc.

Dear Radhika.g,

Could you please give a brief with step by step explanation that where to create the custom script and how to create it.

{{ doc.owner }} will get you the email address of the owner. Using this you can fetch the name of the owner.

let me check and will advice you.

Please explain step by step

How will you customise the print format ?

Use this code in custom script just replace the field name with the field in your doctype
frappe.ui.form.on(ā€œPurchase Orderā€, {
refresh: function(frm){
set_lo(frm);
},
});
var set_lo = function(frm){
if(frm.doc.__islocal){
var u = frappe.session.user;
frappe.call({
method:ā€œfrappe.client.getā€,
args: {
doctype:ā€œUserā€,
filters: {ā€˜emailā€™: u
},
},
callback: function(r) {
cur_frm.set_value(ā€œfield_nameā€, r.message[ā€œfull_nameā€]);
}
})
}
}

i have created the custom script.
now what i have to do next?

Login to your ERP click on Explore Icon then click on Setup from the list at your side bar then click on Custom Script it will be under the heading called ā€œCustomizeā€
Click on Custom Script - Create New - Select your Doctype ā€œPurchase Orderā€ and paste the script below.
just replace the field name to your field in your doctype "cur_frm.set_value(ā€œfield_nameā€, r.message[ā€œfull_nameā€]); "

save the custom script login with any user other then administrator create purchase order your name will be apprear on the field which you added in doctype and in cur_frm.set_value

frappe.ui.form.on(ā€œPurchase Orderā€, {
refresh: function(frm){'
set_lo(frm);
},
});
var set_lo = function(frm){
if(frm.doc.__islocal){
var u = frappe.session.user;
frappe.call({
method:ā€œfrappe.client.getā€,
args: {
doctype:ā€œUserā€,
filters: {ā€˜emailā€™: u
},
},
callback: functionĀ® {
cur_frm.set_value(ā€œfield_nameā€, r.message[ā€œfull_nameā€]);
}
})
}
}

Dear,

Could you please explain with a short video, if possible.
That will help more because i am new to erpnext.

i have created a custom script for purchase order.
now how to apply for all users.

Write this custom Script for Purchase Order

    frappe.ui.form.on("Purchase Order", {
		refresh: function(frm){
				set_lo(frm);
		},
		product:function(frm){
			set_head(frm);
		}			
    });
    var set_lo = function(frm){
    if(frm.doc.__islocal){
		var u = frappe.session.user;
		frappe.call({
			method:"frappe.client.get",
			args: {
			doctype:"User",
			filters: {'email': u
		},
		},
	callback: function(r) {
		cur_frm.set_value("created_by", r.message["full_name"]);
	}
    })
    }
    }

Please see the link below a video for your help
https://drive.google.com/open?id=1BlwsWOLC_Wxr3VftBkP_lsogia0O4fuj

Dear Sir,

how to create and edit custom field in purchase order?
Please explain.

Dear Sir,

It works for me but i want the settings as the name fetch automatically who created the Purchase order

I have created the script and filed in purchase order but it is not showing in print format.