From 501b2cc6174593ca400b0e0e9e95b9a6d7598b8d Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 2 Jul 2014 18:01:30 +0530 Subject: [PATCH] duplicate name fix for customer --- erpnext/selling/doctype/customer/customer.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index 0d430e39c32..c065b54dbb8 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -56,6 +56,7 @@ class Customer(TransactionBase): (self.name, self.customer_name, self.lead_name)) lead = frappe.db.get_value("Lead", self.lead_name, ["lead_name", "email_id", "phone", "mobile_no"], as_dict=True) + c = frappe.new_doc('Contact') c.first_name = lead.lead_name c.email_id = lead.email_id @@ -65,10 +66,9 @@ class Customer(TransactionBase): c.customer_name = self.customer_name c.is_primary_contact = 1 c.ignore_permissions = getattr(self, "ignore_permissions", None) - try: - c.save() - except frappe.NameError: - pass + c.autoname() + if not frappe.db.exists("Contact", c.name): + c.insert() def on_update(self): self.validate_name_with_customer_group()