[HELP ]Item name and Item code cannot be change once PO has been created. Similar restriction as UOM in Item Master

Hi All,

As mentioned at the title , Our Client Required us to have a custom validation to restrict someone to change the ITEM Name / Code once there is document created against it.

We saw there is a similar validation done for delete button , but we were unable to find where the code located.

If you have experience ,appreciate if you can share with me some of the code example or where should we look for ?


Hi @kennywong,
Please Try This Code
// make a field read-only after saving
frappe.ui.form.on(“Task”, {
refresh: function(frm) {
// use the __islocal value of doc, to check if the doc is saved or not
frm.set_df_property(“myfield”, “read_only”, frm.doc.__islocal ? 0 : 1);
use this Link


Thanks @sagar ,

Your example could be one of the alternative ,
Do you have an example when a user attempted to save and it prompt out an error message instead like this :-

Kenny Wong

Hi @kennywong,
please check the delete_doc.py file in frappe.


Write validation method in your app and call it via hooks on item validation event.

Check here for UOM validation code, erpnext/item.py at develop · frappe/erpnext · GitHub