From 81ef7b4c00c02226b2c1f87add9fd022e40a24c6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 31 Dec 2023 18:06:47 +0530 Subject: [PATCH] fix: issue occured when creating supplier with contact details (backport #38147) (#39046) * fix: issue occured when creating supplier with contact details (cherry picked from commit 7842c9fba8b521b9ba7f65281c4f2384f62b06e1) # Conflicts: # erpnext/selling/doctype/customer/customer.py * fix: Suppier name was not taken when creating address from supplier (cherry picked from commit 545ef3c23491e895bf288ddf7666ea80251b41e7) * chore: fix conflicts * chore: fix linter issues --------- Co-authored-by: kunhi Co-authored-by: rohitwaghchaure --- erpnext/selling/doctype/customer/customer.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 56388a594a7..fea27da61b2 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -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, @@ -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"): @@ -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"),