From f94d1832977516e726a9f71994c5b917ea521308 Mon Sep 17 00:00:00 2001 From: Himanshu Warekar Date: Thu, 8 Aug 2019 23:50:03 +0530 Subject: [PATCH] feat: move to newer contacts structure --- erpnext/crm/doctype/opportunity/test_opportunity.py | 7 ++++--- erpnext/hub_node/legacy.py | 5 +++-- erpnext/selling/doctype/customer/customer.py | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py index 1a9f66ad9a..8927d93027 100644 --- a/erpnext/crm/doctype/opportunity/test_opportunity.py +++ b/erpnext/crm/doctype/opportunity/test_opportunity.py @@ -45,15 +45,16 @@ class TestOpportunity(unittest.TestCase): # create new customer and create new contact against 'new.opportunity@example.com' customer = make_customer(opp_doc.party_name).insert(ignore_permissions=True) - frappe.get_doc({ + d = frappe.get_doc({ "doctype": "Contact", - "email_id": new_lead_email_id, "first_name": "_Test Opportunity Customer", "links": [{ "link_doctype": "Customer", "link_name": customer.name }] - }).insert(ignore_permissions=True) + }) + d.add_email(new_lead_email_id) + d.insert(ignore_permissions=True) opp_doc = frappe.get_doc(args).insert(ignore_permissions=True) self.assertTrue(opp_doc.party_name) diff --git a/erpnext/hub_node/legacy.py b/erpnext/hub_node/legacy.py index 95ada76a6a..85eb1b2bb0 100644 --- a/erpnext/hub_node/legacy.py +++ b/erpnext/hub_node/legacy.py @@ -68,12 +68,13 @@ def make_contact(supplier): contact = frappe.get_doc({ 'doctype': 'Contact', 'first_name': supplier.supplier_name, - 'email_id': supplier.supplier_email, 'is_primary_contact': 1, 'links': [ {'link_doctype': 'Supplier', 'link_name': supplier.supplier_name} ] - }).insert() + }) + contact.add_email(supplier.supplier_email) + contact.insert() else: contact = frappe.get_doc('Contact', contact_name) diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py index c946c47c59..d0b4ba0e65 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -337,14 +337,15 @@ def make_contact(args, is_primary_contact=1): contact = frappe.get_doc({ 'doctype': 'Contact', 'first_name': args.get('name'), - 'mobile_no': args.get('mobile_no'), - 'email_id': args.get('email_id'), 'is_primary_contact': is_primary_contact, 'links': [{ 'link_doctype': args.get('doctype'), 'link_name': args.get('name') }] - }).insert() + }) + contact.add_email(args.get('email_id')) + contact.add_phone(args.get('mobile_no')) + contact.insert() return contact