diff --git a/erpnext/public/js/utils/contact_address_quick_entry.js b/erpnext/public/js/utils/contact_address_quick_entry.js index 841794425900e49addd60b76b2a20c54d4141a51..7d729658f7820e1bc8ba7e856a737e4282933e1b 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]; + } } } }