Merge pull request #38147 from kunhimohamed/develop

fix: issue occured when creating supplier with contact details
This commit is contained in:
Deepesh Garg 2023-11-18 19:47:38 +05:30 committed by GitHub
commit 184848edf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -629,8 +629,12 @@ def make_contact(args, is_primary_contact=1):
"is_primary_contact": is_primary_contact,
"links": [{"link_doctype": args.get("doctype"), "link_name": args.get("name")}],
}
if args.customer_type == "Individual":
first, middle, last = parse_full_name(args.get("customer_name"))
party_type = args.customer_type if args.doctype == "Customer" else args.supplier_type
party_name_key = "customer_name" if args.doctype == "Customer" else "supplier_name"
if party_type == "Individual":
first, middle, last = parse_full_name(args.get(party_name_key))
values.update(
{
"first_name": first,
@ -641,9 +645,10 @@ def make_contact(args, is_primary_contact=1):
else:
values.update(
{
"company_name": args.get("customer_name"),
"company_name": args.get(party_name_key),
}
)
contact = frappe.get_doc(values)
if args.get("email_id"):
@ -672,10 +677,12 @@ def make_address(args, is_primary_address=1, is_shipping_address=1):
title=_("Missing Values Required"),
)
party_name_key = "customer_name" if args.doctype == "Customer" else "supplier_name"
address = frappe.get_doc(
{
"doctype": "Address",
"address_title": args.get("customer_name"),
"address_title": args.get(party_name_key),
"address_line1": args.get("address_line1"),
"address_line2": args.get("address_line2"),
"city": args.get("city"),