[V13][BUG] Path of Attach (field) not seen inside Child Table in second and further rows

ERPNext: v13.0.2 (version-13)
Frappe Framework: v13.0.3 (version-13)

Hi there is a problem to see Attachment PATH inside child table in second and further rows.

I created custom child table like this:

When i create Document and attach first attachment then i can see PATH of this attachment BUT when i add second one and further then i see nothing.
EXAMPLE:

I noticed that inside frappe-bench/apps/frappe/frappe/public/js/frappe/form/controls/attach.js:

	on_upload_complete: function(attachment) {
		if(this.frm) {
			this.parse_validate_and_set_in_model(attachment.file_url);
			this.frm.attachments.update_attachment(attachment);
			this.frm.doc.docstatus == 1 ? this.frm.save('Update') : this.frm.save();
		}
		this.set_value(attachment.file_url);
	},

when i changed it to:

	on_upload_complete: function(attachment) {
		if(this.frm) {
			this.parse_validate_and_set_in_model(attachment.file_url);
			this.frm.attachments.update_attachment(attachment);
			//this.frm.doc.docstatus == 1 ? this.frm.save('Update') : this.frm.save();
		}
		this.set_value(attachment.file_url);
	},

THEN i need to update Document “by hand” but after that, attachment PATH is visible in second row!

Could it be fixed somehow, please?

Thanks for finding this fix. To include this as a customization, include the following in a js file that is built and included in your app:

frappe.ui.form.ControlAttach.prototype.clear_attachment = function() {
	var me = this;
	if (this.frm) {
		me.parse_validate_and_set_in_model(null);
		me.refresh();
		me.frm.attachments.remove_attachment_by_filename(me.value, function () {
			me.parse_validate_and_set_in_model(null);
			me.refresh();
			// me.frm.doc.docstatus == 1 ? me.frm.save('Update') : me.frm.save();
		});
	} else {
		this.dataurl = null;
		this.fileobj = null;
		this.set_input(null);
		this.parse_validate_and_set_in_model(null);
		this.refresh();
	}
}

frappe.ui.form.ControlAttach.prototype.on_upload_complete = function (attachment) {
	if (this.frm) {
		this.parse_validate_and_set_in_model(attachment.file_url);
		this.frm.attachments.update_attachment(attachment);
		// this.frm.doc.docstatus == 1 ? this.frm.save('Update') : this.frm.save();
	}
	this.set_value(attachment.file_url);
}
1 Like