feat: Add first and last name fields to quick entry customer creation (backport #46281) (#50522)

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
Co-authored-by: maasanto <73234812+maasanto@users.noreply.github.com>
Co-authored-by: Diptanil Saha <diptanil@frappe.io>
This commit is contained in:
mergify[bot]
2025-11-13 21:58:34 +05:30
committed by GitHub
parent 182e84e94c
commit 8c98f1692a
3 changed files with 29 additions and 4 deletions

View File

@@ -16,11 +16,13 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm
insert() {
/**
* Using alias fieldnames because the doctype definition define "email_id" and "mobile_no" as readonly fields.
* Therefor, resulting in the fields being "hidden".
* This results in the fields being "hidden".
*/
const map_field_names = {
email_address: "email_id",
mobile_number: "mobile_no",
map_to_first_name: "first_name",
map_to_last_name: "last_name",
};
Object.entries(map_field_names).forEach(([fieldname, new_fieldname]) => {

View File

@@ -56,6 +56,8 @@
"customer_primary_contact",
"mobile_no",
"email_id",
"first_name",
"last_name",
"tax_tab",
"taxation_section",
"tax_id",
@@ -581,6 +583,20 @@
"no_copy": 1,
"options": "Prospect",
"print_hide": 1
},
{
"fetch_from": "customer_primary_contact.first_name",
"fieldname": "first_name",
"fieldtype": "Read Only",
"hidden": 1,
"label": "First Name"
},
{
"fetch_from": "customer_primary_contact.last_name",
"fieldname": "last_name",
"fieldtype": "Read Only",
"hidden": 1,
"label": "Last Name"
}
],
"icon": "fa fa-user",
@@ -594,7 +610,7 @@
"link_fieldname": "party"
}
],
"modified": "2024-06-17 03:24:59.612974",
"modified": "2025-03-05 10:01:47.885574",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",
@@ -672,6 +688,7 @@
}
],
"quick_entry": 1,
"row_format": "Dynamic",
"search_fields": "customer_group,territory, mobile_no,primary_address",
"show_name_in_global_search": 1,
"sort_field": "modified",
@@ -679,4 +696,4 @@
"states": [],
"title_field": "customer_name",
"track_changes": 1
}
}

View File

@@ -61,12 +61,14 @@ class Customer(TransactionBase):
disabled: DF.Check
dn_required: DF.Check
email_id: DF.ReadOnly | None
first_name: DF.ReadOnly | None
gender: DF.Link | None
image: DF.AttachImage | None
industry: DF.Link | None
is_frozen: DF.Check
is_internal_customer: DF.Check
language: DF.Link | None
last_name: DF.ReadOnly | None
lead_name: DF.Link | None
loyalty_program: DF.Link | None
loyalty_program_tier: DF.Data | None
@@ -248,7 +250,7 @@ class Customer(TransactionBase):
def create_primary_contact(self):
if not self.customer_primary_contact and not self.lead_name:
if self.mobile_no or self.email_id:
if self.mobile_no or self.email_id or self.first_name or self.last_name:
contact = make_contact(self)
self.db_set("customer_primary_contact", contact.name)
self.db_set("mobile_no", self.mobile_no)
@@ -736,6 +738,10 @@ def make_contact(args, is_primary_contact=1):
contact.add_email(args.get("email_id"), is_primary=True)
if args.get("mobile_no"):
contact.add_phone(args.get("mobile_no"), is_primary_mobile_no=True)
if args.get("first_name"):
contact.first_name = args.get("first_name")
if args.get("last_name"):
contact.last_name = args.get("last_name")
if flags := args.get("flags"):
contact.insert(ignore_permissions=flags.get("ignore_permissions"))