feat(Contacts): Multiple Emails in a Contact (#18675)
* feat: render multiple addresses * feat: move to newer contacts structure * fix: iterate over valid variable * fix: use primary label instead of bold letters * fix: call popup get contact name from number * fix: make contact structure call popup compatible * fix: query * fix: add city, state and country * fix: display address * fix: get address in single line * fix: review fixes * fix: translation strings * fix: fix query for contacts * fix: remove references of mobile_no
This commit is contained in:
parent
e26b55265f
commit
fffdb6f575
@ -227,8 +227,8 @@ def get_contacts(customers):
|
|||||||
customers = [frappe._dict({'name': customers})]
|
customers = [frappe._dict({'name': customers})]
|
||||||
|
|
||||||
for data in customers:
|
for data in customers:
|
||||||
contact = frappe.db.sql(""" select email_id, phone, mobile_no from `tabContact`
|
contact = frappe.db.sql(""" select email_id, phone from `tabContact`
|
||||||
where is_primary_contact =1 and name in
|
where is_primary_contact=1 and name in
|
||||||
(select parent from `tabDynamic Link` where link_doctype = 'Customer' and link_name = %s
|
(select parent from `tabDynamic Link` where link_doctype = 'Customer' and link_name = %s
|
||||||
and parenttype = 'Contact')""", data.name, as_dict=1)
|
and parenttype = 'Contact')""", data.name, as_dict=1)
|
||||||
if contact:
|
if contact:
|
||||||
|
@ -816,7 +816,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
contact = me.contacts[data.name];
|
contact = me.contacts[data.name];
|
||||||
if(reg.test(data.name.toLowerCase())
|
if(reg.test(data.name.toLowerCase())
|
||||||
|| reg.test(data.customer_name.toLowerCase())
|
|| reg.test(data.customer_name.toLowerCase())
|
||||||
|| (contact && reg.test(contact["mobile_no"]))
|
|
||||||
|| (contact && reg.test(contact["phone"]))
|
|| (contact && reg.test(contact["phone"]))
|
||||||
|| (data.customer_group && reg.test(data.customer_group.toLowerCase()))){
|
|| (data.customer_group && reg.test(data.customer_group.toLowerCase()))){
|
||||||
return data;
|
return data;
|
||||||
@ -834,7 +833,6 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
if(contact && !c['phone']) {
|
if(contact && !c['phone']) {
|
||||||
c["phone"] = contact["phone"];
|
c["phone"] = contact["phone"];
|
||||||
c["email_id"] = contact["email_id"];
|
c["email_id"] = contact["email_id"];
|
||||||
c["mobile_no"] = contact["mobile_no"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
me.customers_mapper.push({
|
me.customers_mapper.push({
|
||||||
@ -844,10 +842,9 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
customer_group: c.customer_group,
|
customer_group: c.customer_group,
|
||||||
territory: c.territory,
|
territory: c.territory,
|
||||||
phone: contact ? contact["phone"] : '',
|
phone: contact ? contact["phone"] : '',
|
||||||
mobile_no: contact ? contact["mobile_no"] : '',
|
|
||||||
email_id: contact ? contact["email_id"] : '',
|
email_id: contact ? contact["email_id"] : '',
|
||||||
searchtext: ['customer_name', 'customer_group', 'name', 'value',
|
searchtext: ['customer_name', 'customer_group', 'name', 'value',
|
||||||
'label', 'email_id', 'phone', 'mobile_no']
|
'label', 'email_id', 'phone']
|
||||||
.map(key => c[key]).join(' ')
|
.map(key => c[key]).join(' ')
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
});
|
});
|
||||||
|
@ -73,6 +73,10 @@ def set_caller_information(doc, state):
|
|||||||
# contact_name or lead_name
|
# contact_name or lead_name
|
||||||
display_name_field = '{}_name'.format(fieldname)
|
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:
|
for number in numbers:
|
||||||
number = strip_number(number)
|
number = strip_number(number)
|
||||||
if not number: continue
|
if not number: continue
|
||||||
|
@ -45,15 +45,16 @@ class TestOpportunity(unittest.TestCase):
|
|||||||
|
|
||||||
# create new customer and create new contact against 'new.opportunity@example.com'
|
# create new customer and create new contact against 'new.opportunity@example.com'
|
||||||
customer = make_customer(opp_doc.party_name).insert(ignore_permissions=True)
|
customer = make_customer(opp_doc.party_name).insert(ignore_permissions=True)
|
||||||
frappe.get_doc({
|
contact = frappe.get_doc({
|
||||||
"doctype": "Contact",
|
"doctype": "Contact",
|
||||||
"email_id": new_lead_email_id,
|
|
||||||
"first_name": "_Test Opportunity Customer",
|
"first_name": "_Test Opportunity Customer",
|
||||||
"links": [{
|
"links": [{
|
||||||
"link_doctype": "Customer",
|
"link_doctype": "Customer",
|
||||||
"link_name": customer.name
|
"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)
|
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
|
||||||
self.assertTrue(opp_doc.party_name)
|
self.assertTrue(opp_doc.party_name)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
# import frappe
|
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import requests
|
import requests
|
||||||
import frappe
|
import frappe
|
||||||
|
@ -68,12 +68,13 @@ def make_contact(supplier):
|
|||||||
contact = frappe.get_doc({
|
contact = frappe.get_doc({
|
||||||
'doctype': 'Contact',
|
'doctype': 'Contact',
|
||||||
'first_name': supplier.supplier_name,
|
'first_name': supplier.supplier_name,
|
||||||
'email_id': supplier.supplier_email,
|
|
||||||
'is_primary_contact': 1,
|
'is_primary_contact': 1,
|
||||||
'links': [
|
'links': [
|
||||||
{'link_doctype': 'Supplier', 'link_name': supplier.supplier_name}
|
{'link_doctype': 'Supplier', 'link_name': supplier.supplier_name}
|
||||||
]
|
]
|
||||||
}).insert()
|
})
|
||||||
|
contact.add_email(supplier.supplier_email)
|
||||||
|
contact.insert()
|
||||||
else:
|
else:
|
||||||
contact = frappe.get_doc('Contact', contact_name)
|
contact = frappe.get_doc('Contact', contact_name)
|
||||||
|
|
||||||
|
@ -14,20 +14,33 @@
|
|||||||
style="margin-top:-3px; margin-right: -5px;">
|
style="margin-top:-3px; margin-right: -5px;">
|
||||||
{%= __("Edit") %}</a>
|
{%= __("Edit") %}</a>
|
||||||
</p>
|
</p>
|
||||||
{% if (contact_list[i].phone || contact_list[i].mobile_no ||
|
{% if (contact_list[i].phones || contact_list[i].email_ids) { %}
|
||||||
contact_list[i].email_id) { %}
|
|
||||||
<p>
|
<p>
|
||||||
{% if(contact_list[i].phone) { %}
|
{% if(contact_list[i].phone) { %}
|
||||||
{%= __("Phone") %}: {%= contact_list[i].phone %}<br>
|
{%= __("Phone") %}: {%= contact_list[i].phone %}<span class="text-muted"> ({%= __("Primary") %})</span><br>
|
||||||
{% } %}
|
{% endif %}
|
||||||
{% if(contact_list[i].mobile_no) { %}
|
{% if(contact_list[i].phone_nos) { %}
|
||||||
{%= __("Mobile No.") %}: {%= contact_list[i].mobile_no %}<br>
|
{% for(var j=0, k=contact_list[i].phone_nos.length; j<k; j++) { %}
|
||||||
{% } %}
|
{%= __("Phone") %}: {%= contact_list[i].phone_nos[j].phone %}<br>
|
||||||
{% if(contact_list[i].email_id) { %}
|
{% } %}
|
||||||
{%= __("Email Address") %}: {%= contact_list[i].email_id %}
|
{% endif %}
|
||||||
{% } %}
|
</p>
|
||||||
|
<p>
|
||||||
|
{% if(contact_list[i].email_id) { %}
|
||||||
|
{%= __("Email") %}: {%= contact_list[i].email_id %}<span class="text-muted"> ({%= __("Primary") %})</span><br>
|
||||||
|
{% endif %}
|
||||||
|
{% if(contact_list[i].email_ids) { %}
|
||||||
|
{% for(var j=0, k=contact_list[i].email_ids.length; j<k; j++) { %}
|
||||||
|
{%= __("Email") %}: {%= contact_list[i].email_ids[j].email_id %}<br>
|
||||||
|
{% } %}
|
||||||
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<p>
|
||||||
|
{% if (contact_list[i].address) { %}
|
||||||
|
{%= __("Address") %}: {%= contact_list[i].address %}<br>
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{% } %}
|
{% } %}
|
||||||
{% if(!contact_list.length) { %}
|
{% if(!contact_list.length) { %}
|
||||||
|
@ -337,14 +337,15 @@ def make_contact(args, is_primary_contact=1):
|
|||||||
contact = frappe.get_doc({
|
contact = frappe.get_doc({
|
||||||
'doctype': 'Contact',
|
'doctype': 'Contact',
|
||||||
'first_name': args.get('name'),
|
'first_name': args.get('name'),
|
||||||
'mobile_no': args.get('mobile_no'),
|
|
||||||
'email_id': args.get('email_id'),
|
|
||||||
'is_primary_contact': is_primary_contact,
|
'is_primary_contact': is_primary_contact,
|
||||||
'links': [{
|
'links': [{
|
||||||
'link_doctype': args.get('doctype'),
|
'link_doctype': args.get('doctype'),
|
||||||
'link_name': args.get('name')
|
'link_name': args.get('name')
|
||||||
}]
|
}]
|
||||||
}).insert()
|
})
|
||||||
|
contact.add_email(args.get('email_id'))
|
||||||
|
contact.add_phone(args.get('mobile_no'))
|
||||||
|
contact.insert()
|
||||||
|
|
||||||
return contact
|
return contact
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ class SMSCenter(Document):
|
|||||||
self.sales_partner.replace("'", "\'") or " and ifnull(dl.link_name, '') != ''"
|
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']:
|
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,'')),
|
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)
|
c.docstatus != 2 and dl.parent = c.name%s""" % where_clause)
|
||||||
|
|
||||||
elif self.send_to == 'All Lead (Open)':
|
elif self.send_to == 'All Lead (Open)':
|
||||||
|
Loading…
Reference in New Issue
Block a user