When I am trying to attach files the form is getting automatically saved. i don’t need to save forms when I attach files. What to do with it?
Remove or comment the below line from the core code:
It is not working
please reload and again check.
Otherwise apply the command bench build --force
I also need to comment that line and try to command bench build --force in putty? Am I right?
Use this command where you have installed erpnext via command
While bench build --force command is given, It is telling to update latest node version. While trying to install it, error is rising as -N PREFIX NOT FOUND
It worked, but I’ve read in other threads not to touch the core modules as it will create merge conflicts for updates. Will this fix create any issues in future?
right @kashh,
This is a temporary solution. We do not recommend modifying the core module. Some users want a solution, so we are just sharing the path.
Thank you so much. Can we stop saving the form using any event when upload button is clicked?
For cases when we need to override some core code of frappe monkey patching is one of the cleanest solutions, here’s what worked for me in latest Frappe v15 for this customization:
Add the following code in your custom app’s public/js folder and then add the path in your hooks.py app_include_js. Like below:
app_include_js = ["assets/your_custom_app_name_here/js/control_attach_override.js"]
// Override the on_upload_complete method to prevent auto-save
frappe.ui.form.ControlAttach.prototype.on_upload_complete = async function(attachment) {
if (this.frm) {
await this.parse_validate_and_set_in_model(attachment.file_url);
this.frm.attachments.update_attachment(attachment);
// No auto-save - removed these lines:
// this.frm.doc.docstatus == 1 ? this.frm.save("Update") : this.frm.save();
frappe.show_alert({
message: __('File attached successfully. Please save the form to persist changes.'),
indicator: 'green'
}, 3);
}
this.set_value(attachment.file_url);
};
// Override the clear_attachment method to prevent auto-save on clear
frappe.ui.form.ControlAttach.prototype.clear_attachment = function() {
let me = this;
if (this.frm) {
me.parse_validate_and_set_in_model(null);
me.refresh();
me.frm.attachments.remove_attachment_by_filename(me.value, async () => {
await me.parse_validate_and_set_in_model(null);
me.refresh();
// No auto-save - removed these lines:
// me.frm.doc.docstatus == 1 ? me.frm.save("Update") : me.frm.save();
frappe.show_alert({
message: __('Attachment cleared. Please save the form to persist changes.'),
indicator: 'orange'
}, 3);
});
} else {
this.dataurl = null;
this.fileobj = null;
this.set_input(null);
this.parse_validate_and_set_in_model(null);
this.refresh();
}
};