From 80c97b107f8561c49fe54400e02be6404495af64 Mon Sep 17 00:00:00 2001 From: Corentin Forler <8860073-cforler_dokos@users.noreply.gitlab.com> Date: Tue, 16 Jan 2024 18:59:10 +0100 Subject: [PATCH] fix(ContactAddressQuickEntry): Don't make reqd if none is filled Don't make fields required until one of them is filled --- .../public/js/utils/contact_address_quick_entry.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/utils/contact_address_quick_entry.js b/erpnext/public/js/utils/contact_address_quick_entry.js index 84179442590..7d729658f78 100644 --- a/erpnext/public/js/utils/contact_address_quick_entry.js +++ b/erpnext/public/js/utils/contact_address_quick_entry.js @@ -6,6 +6,10 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm "mobile_number": "mobile_no", }; + map_mandatory_depends_on = { + Address: "eval:doc.address_line1", + }; + constructor(doctype, after_insert, init_callback, doc, force) { super(doctype, after_insert, init_callback, doc, force); this.skip_redirect_on_error = true; @@ -48,10 +52,18 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm if (original_df) { const default_value = frappe.defaults.get_default(fieldname); Object.assign(m, { - "reqd": original_df.reqd, "hidden": m.hidden ? 1 : original_df.hidden, "default": default_value, }); + + if (default_value) { + this.doc[fieldname] = default_value; + } + + // Don't make fields required until one of them is filled + if (this.map_mandatory_depends_on[dt] && original_df.reqd) { + m.mandatory_depends_on = this.map_mandatory_depends_on[dt]; + } } } } -- GitLab