Restrict User to Delete/Attach File

Hi,

I want to write a script by which once the document is submitted no one either can submit/delete the document.

2 Likes

Great :slight_smile:

(I was hoping there would be a question)

2 Likes

So what is the best answer to that question?

looks like you never asked any before this

@ruchin78 I was pointing out that there was no question in your original post. You just made an assertion that you wanted to write a script for restricting.

Anyways, obviously there is an embedded question on how to write a script like this. I think will have to be written at the framework-level.

Ok rmehta, thanks a lot and I make a not for future will take care of it.

Hi
Is it possible in ERPNEXT to restrict permission to delete attached file, so only user can attach files but don’t allow them to delete, I tried the role permission manager but it’s not working.
Please fic this issue.

Scenario
If a user uploaded a Attachment in the Purchase invoice field then they should not allow to to modify/delete the attachment (pdf.) file.

Thank You

Hi
Is it possible in ERPNEXT to restrict permission to delete attached file, so only user can attach files but don’t allow them to delete,
Scenario
If a user uploaded a Attachment in the Purchase invoice field then they should not allow to to modify/delete the attachment (pdf.) file.

Thank You

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