There is a custom doctype called “document” this is to attach some documents against the project. Here we have to write a custom js script to disable the attachment Remove button and Attach button based on document submission.
The below code is in hooks.py. Here Document is the custom doctype, which doesn’t work on document form. I have migrated the site and all. but still no luck.
doctype_js = {"Project" : "public/js/project.js", "Document": "public/js/document.js"}
Inside document.js
frappe.ui.form.on('Document', {
before_submit(frm, cdt, cdn) {
if (!frm.attachments.get_attachments().length) {
//frappe.throw('You should have atleast one document in attachments');
frappe.msgprint('You should have atleast one document in attachments!')
frappe.validated = false
return false;
}
},
before_load(frm) {
console.log('from code')
console.log('from document page')
},
refresh(frm) {
if ($('li.attachment-row > a').has('.close') && frm.doc.docstatus === 1) {
console.log('has close button')
$("a.close").remove();
$('li > a.add-attachment').remove()
}
}
});
Please help.