[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 ?

Thanks
Kenny

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
https://frappe.github.io/erpnext/user/manual/en/customize-erpnext/custom-scripts/custom-script-examples/make-read-only-after-saving.html

Thanks

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 :-

Thanks
Regards,
Kenny Wong

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

Thanks

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

Check here for UOM validation code, https://github.com/frappe/erpnext/blob/develop/erpnext/stock/doctype/item/item.py#L73