From aaccfeb918d7427cc110626bc94a2eeb921be6a9 Mon Sep 17 00:00:00 2001 From: kunhi Date: Fri, 17 Nov 2023 11:22:08 +0400 Subject: [PATCH 1/3] fix: issue occured when creating supplier with contact details (cherry picked from commit 7842c9fba8b521b9ba7f65281c4f2384f62b06e1) --- erpnext/selling/doctype/customer/customer.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 27bb8845dd6d..ed9bc6dae862 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -644,8 +644,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, @@ -656,9 +660,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"): From 2b9448962ff9195bd6ffd535cee0f010876558d3 Mon Sep 17 00:00:00 2001 From: Kunhi Date: Fri, 17 Nov 2023 11:43:36 +0400 Subject: [PATCH 2/3] fix: Suppier name was not taken when creating address from supplier (cherry picked from commit 545ef3c23491e895bf288ddf7666ea80251b41e7) --- erpnext/selling/doctype/customer/customer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index ed9bc6dae862..ef42d8a6d446 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -692,10 +692,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"), From c29bc8c97fc57b65a214346123d1e12f6703f175 Mon Sep 17 00:00:00 2001 From: Deepesh Garg Date: Sun, 19 Nov 2023 19:20:06 +0530 Subject: [PATCH 3/3] chore: linting issues --- erpnext/selling/doctype/customer/customer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index ef42d8a6d446..7ef929fc222e 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -648,7 +648,7 @@ def make_contact(args, is_primary_contact=1): 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": + if party_type == "Individual": first, middle, last = parse_full_name(args.get(party_name_key)) values.update( {