From 7cfa5f0508be1c5247d03c61e621db0778b8f01a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 23 Jul 2015 12:39:44 +0530 Subject: [PATCH] [fix] contact name in setup wizard --- .../setup/page/setup_wizard/setup_wizard.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py index 4bb01d48d4..141b914d91 100644 --- a/erpnext/setup/page/setup_wizard/setup_wizard.py +++ b/erpnext/setup/page/setup_wizard/setup_wizard.py @@ -367,13 +367,8 @@ def create_customers(args): }).insert() if args.get("customer_contact_" + str(i)): - contact = args.get("customer_contact_" + str(i)).split(" ") - frappe.get_doc({ - "doctype":"Contact", - "customer": customer, - "first_name":contact[0], - "last_name": len(contact) > 1 and contact[1] or "" - }).insert() + create_contact(args.get("customer_contact_" + str(i)), + "customer", customer) except frappe.NameError: pass @@ -390,16 +385,21 @@ def create_suppliers(args): }).insert() if args.get("supplier_contact_" + str(i)): - contact = args.get("supplier_contact_" + str(i)).split(" ") - frappe.get_doc({ - "doctype":"Contact", - "supplier": supplier, - "first_name":contact[0], - "last_name": len(contact) > 1 and contact[1] or "" - }).insert() + create_contact(args.get("supplier_contact_" + str(i)), + "supplier", supplier) except frappe.NameError: pass +def create_contact(contact, party_type, party): + """Create contact based on given contact name""" + contact = contact.strip().split(" ") + + frappe.get_doc({ + "doctype":"Contact", + party_type: party, + "first_name":contact[0], + "last_name": len(contact) > 1 and contact[1] or "" + }).insert() def create_letter_head(args): if args.get("attach_letterhead"):