Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue occured when creating supplier with contact details (backport #38147) #39046

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions erpnext/selling/doctype/customer/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,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,
Expand All @@ -703,9 +707,10 @@ def make_contact(args, is_primary_contact=1):
values.update(
{
"first_name": args.get("customer_name"),
"company_name": args.get("customer_name"),
"company_name": args.get(party_name_key),
}
)

contact = frappe.get_doc(values)

if args.get("email_id"):
Expand Down Expand Up @@ -734,10 +739,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"),
Expand Down
Loading