Restrict User to Delete/Attach File

i think a hook will work

doc_events = {
    "File": {
        "before_udpate": "custom_app_name.custom_module_name.file.before_submit"
        "on_trash": "custom_app_name.custom_module_name.file.before_submit"
    }
}




def on_update(doc, event=None):
    # Custom code to be executed after the document is updated
    # 'doc' contains the updated document object
    if doc.attached_to_doctype and doc.attached_to_name:
        doc = frappe.get_doc(doc.attached_to_doctype, doc.attached_to_name):
        if doc.docstatus == 1:
            # do whatever you want here
            pass
            
def on_trash(doc, event=None):
    on_update(doc, event=None)

sorry if syntax issue