How to make document to be read only after saving or submit?

Hello guys,

I want to make my custom doctype can record daily employee report.
But after saving, i want the record to be read only. If someone want to edit it, they must have the permission.

Hi @iqbalzahir,

the normal way to do this would be making it submittable and then only allow specific roles to cancel/amend submitted docs. To achive this, make your doctype submittable:

Alternatively, you might want to look into a custom script for your doctype, that makes the fields read-only, e.g. something like

// 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);
    }
}); 

Hope this helps.

Yes i’m looking something like this. I just did what you say, and it worked!
Thank you so much for your help @lasalesi

how to make all the fields read only at once