ERPNext Conference 2019* ERPNext.com Blog

Want to show name on purchase order who make it


#1

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


#2

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: https://erpnext.com/docs/user/manual/en/customize-erpnext/customize-form


#3

Is there a way to add the “last updated by” user’s name on the PO? or the “Submitted by” user’s name ?


#4

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


#6

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


#7

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.


#8

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.


#9

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.


#10

{{ 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.


#11

Please explain step by step


#12

How will you customise the print format ?


#13

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® {
cur_frm.set_value(“field_name”, r.message[“full_name”]);
}
})
}
}


#14

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


#15

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”]);
}
})
}
}

#16

Dear,

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


#17

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


#18

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


#19

Dear Sir,

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


#20

Dear Sir,

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


#21

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