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

* feat: Add First and Last Name Fields to Quick Entry Customer Creation Form

* fix: added first and last_name fields to customer dt

* chore: linter issues

* chore: linter issue

* chore: linter issue

---------

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
maasanto
2025-03-07 06:01:45 +01:00
committed by GitHub
parent 98111dac17
commit faa340c8b5
3 changed files with 45 additions and 7 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]) => {
@@ -38,15 +40,28 @@ frappe.ui.form.ContactAddressQuickEntryForm = class ContactAddressQuickEntryForm
label: __("Primary Contact Details"),
collapsible: 1,
},
{
label: __("First Name"),
fieldname: "map_to_first_name",
fieldtype: "Data",
depends_on: "eval:doc.customer_type=='Company'",
},
{
label: __("Last Name"),
fieldname: "map_to_last_name",
fieldtype: "Data",
depends_on: "eval:doc.customer_type=='Company'",
},
{
fieldtype: "Column Break",
},
{
label: __("Email Id"),
fieldname: "email_address",
fieldtype: "Data",
options: "Email",
},
{
fieldtype: "Column Break",
},
{
label: __("Mobile Number"),
fieldname: "mobile_number",

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": "creation",
@@ -679,4 +696,4 @@
"states": [],
"title_field": "customer_name",
"track_changes": 1
}
}

View File

@@ -60,12 +60,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)
@@ -723,6 +725,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"))