From a01967c182b351f65acfbc4ad0f49dc0dc1ef3f7 Mon Sep 17 00:00:00 2001 From: Ankush Menat Date: Tue, 16 Aug 2022 20:57:19 +0530 Subject: [PATCH] fix: incorrect attachment limit message (#17848) --- frappe/public/js/frappe/form/sidebar/attachments.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frappe/public/js/frappe/form/sidebar/attachments.js b/frappe/public/js/frappe/form/sidebar/attachments.js index a987d0d334..471b2db2ae 100644 --- a/frappe/public/js/frappe/form/sidebar/attachments.js +++ b/frappe/public/js/frappe/form/sidebar/attachments.js @@ -160,6 +160,12 @@ frappe.ui.form.Attachments = class Attachments { this.dialog.$wrapper.remove(); } + const restrictions = {}; + if (this.frm.meta.max_attachments) { + restrictions.max_number_of_files = + this.frm.meta.max_attachments - this.frm.attachments.get_attachments().length; + } + new frappe.ui.FileUploader({ doctype: this.frm.doctype, docname: this.frm.docname, @@ -168,10 +174,7 @@ frappe.ui.form.Attachments = class Attachments { on_success: (file_doc) => { this.attachment_uploaded(file_doc); }, - restrictions: { - max_number_of_files: - this.frm.meta.max_attachments - this.frm.attachments.get_attachments().length, - }, + restrictions, }); } get_args() {