diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py index e290b235a9..7e23793700 100755 --- a/erpnext/accounts/doctype/sales_invoice/pos.py +++ b/erpnext/accounts/doctype/sales_invoice/pos.py @@ -227,8 +227,8 @@ def get_contacts(customers): customers = [frappe._dict({'name': customers})] for data in customers: - contact = frappe.db.sql(""" select email_id, phone, mobile_no from `tabContact` - where is_primary_contact =1 and name in + contact = frappe.db.sql(""" select email_id, phone from `tabContact` + where is_primary_contact=1 and name in (select parent from `tabDynamic Link` where link_doctype = 'Customer' and link_name = %s and parenttype = 'Contact')""", data.name, as_dict=1) if contact: diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js index b5a02d0e49..0e7301204a 100755 --- a/erpnext/accounts/page/pos/pos.js +++ b/erpnext/accounts/page/pos/pos.js @@ -816,7 +816,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ contact = me.contacts[data.name]; if(reg.test(data.name.toLowerCase()) || reg.test(data.customer_name.toLowerCase()) - || (contact && reg.test(contact["mobile_no"])) || (contact && reg.test(contact["phone"])) || (data.customer_group && reg.test(data.customer_group.toLowerCase()))){ return data; @@ -834,7 +833,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ if(contact && !c['phone']) { c["phone"] = contact["phone"]; c["email_id"] = contact["email_id"]; - c["mobile_no"] = contact["mobile_no"]; } me.customers_mapper.push({ @@ -844,10 +842,9 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({ customer_group: c.customer_group, territory: c.territory, phone: contact ? contact["phone"] : '', - mobile_no: contact ? contact["mobile_no"] : '', email_id: contact ? contact["email_id"] : '', searchtext: ['customer_name', 'customer_group', 'name', 'value', - 'label', 'email_id', 'phone', 'mobile_no'] + 'label', 'email_id', 'phone'] .map(key => c[key]).join(' ') .toLowerCase() }); diff --git a/erpnext/communication/doctype/call_log/call_log.py b/erpnext/communication/doctype/call_log/call_log.py index 2343632719..35c31a0bf8 100644 --- a/erpnext/communication/doctype/call_log/call_log.py +++ b/erpnext/communication/doctype/call_log/call_log.py @@ -73,6 +73,10 @@ def set_caller_information(doc, state): # contact_name or lead_name display_name_field = '{}_name'.format(fieldname) + # Contact now has all the nos saved in child table + if doc.doctype == 'Contact': + numbers = [d.phone for d in doc.phone_nos] + for number in numbers: number = strip_number(number) if not number: continue diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py index 1a9f66ad9a..8f61edf00e 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({ + contact = 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) + }) + contact.add_email(new_lead_email_id) + contact.insert(ignore_permissions=True) opp_doc = frappe.get_doc(args).insert(ignore_permissions=True) self.assertTrue(opp_doc.party_name) diff --git a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py index 77de84ce5c..6a846efad7 100644 --- a/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py +++ b/erpnext/erpnext_integrations/doctype/exotel_settings/exotel_settings.py @@ -3,7 +3,6 @@ # For license information, please see license.txt from __future__ import unicode_literals -# import frappe from frappe.model.document import Document import requests import frappe 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/public/js/templates/contact_list.html b/erpnext/public/js/templates/contact_list.html index 893b4e0ec2..50fbfd9f12 100644 --- a/erpnext/public/js/templates/contact_list.html +++ b/erpnext/public/js/templates/contact_list.html @@ -14,20 +14,33 @@ style="margin-top:-3px; margin-right: -5px;"> {%= __("Edit") %}

- {% if (contact_list[i].phone || contact_list[i].mobile_no || - contact_list[i].email_id) { %} + {% if (contact_list[i].phones || contact_list[i].email_ids) { %}

- {% if(contact_list[i].phone) { %} - {%= __("Phone") %}: {%= contact_list[i].phone %}
- {% } %} - {% if(contact_list[i].mobile_no) { %} - {%= __("Mobile No.") %}: {%= contact_list[i].mobile_no %}
- {% } %} - {% if(contact_list[i].email_id) { %} - {%= __("Email Address") %}: {%= contact_list[i].email_id %} - {% } %} + {% if(contact_list[i].phone) { %} + {%= __("Phone") %}: {%= contact_list[i].phone %} ({%= __("Primary") %})
+ {% endif %} + {% if(contact_list[i].phone_nos) { %} + {% for(var j=0, k=contact_list[i].phone_nos.length; j + {% } %} + {% endif %} +

+

+ {% if(contact_list[i].email_id) { %} + {%= __("Email") %}: {%= contact_list[i].email_id %} ({%= __("Primary") %})
+ {% endif %} + {% if(contact_list[i].email_ids) { %} + {% for(var j=0, k=contact_list[i].email_ids.length; j + {% } %} + {% endif %}

{% endif %} +

+ {% if (contact_list[i].address) { %} + {%= __("Address") %}: {%= contact_list[i].address %}
+ {% endif %} +

{% } %} {% if(!contact_list.length) { %} 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 diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py index bb6ba1ffce..289b045e1c 100644 --- a/erpnext/selling/doctype/sms_center/sms_center.py +++ b/erpnext/selling/doctype/sms_center/sms_center.py @@ -31,7 +31,7 @@ class SMSCenter(Document): self.sales_partner.replace("'", "\'") or " and ifnull(dl.link_name, '') != ''" if self.send_to in ['All Contact', 'All Customer Contact', 'All Supplier Contact', 'All Sales Partner Contact']: rec = frappe.db.sql("""select CONCAT(ifnull(c.first_name,''), ' ', ifnull(c.last_name,'')), - c.mobile_no from `tabContact` c, `tabDynamic Link` dl where ifnull(c.mobile_no,'')!='' and + c.phone from `tabContact` c, `tabDynamic Link` dl where ifnull(c.phone,'')!='' and c.docstatus != 2 and dl.parent = c.name%s""" % where_clause) elif self.send_to == 'All Lead (Open)':