fix(Contact): mobile_no re-introduced and travis fixes (#19009)

* fix: mobile_no re-introduced

* fix: test cases

* fix: set email as primary

* fix: add primary email and phone

* fix: utils for contact creation

* chore: remove = from dict
This commit is contained in:
Himanshu 2019-09-30 10:08:15 +05:30 committed by Nabin Hait
parent 83b0b2adec
commit 25ab1e41df
7 changed files with 40 additions and 30 deletions

View File

@ -238,7 +238,7 @@ def get_contacts(customers):
customers = [frappe._dict({'name': customers})]
for data in customers:
contact = frappe.db.sql(""" select email_id, phone from `tabContact`
contact = frappe.db.sql(""" select email_id, phone, mobile_no 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)

View File

@ -817,6 +817,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
if(reg.test(data.name.toLowerCase())
|| reg.test(data.customer_name.toLowerCase())
|| (contact && reg.test(contact["phone"]))
|| (contact && reg.test(contact["mobile_no"]))
|| (data.customer_group && reg.test(data.customer_group.toLowerCase()))){
return data;
}
@ -833,6 +834,7 @@ 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({
@ -842,9 +844,10 @@ 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']
'label', 'email_id', 'phone', 'mobile_no']
.map(key => c[key]).join(' ')
.toLowerCase()
});

View File

@ -53,7 +53,7 @@ class TestOpportunity(unittest.TestCase):
"link_name": customer.name
}]
})
contact.add_email(new_lead_email_id)
contact.add_email(new_lead_email_id, is_primary=True)
contact.insert(ignore_permissions=True)
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)

View File

@ -73,7 +73,7 @@ def make_contact(supplier):
{'link_doctype': 'Supplier', 'link_name': supplier.supplier_name}
]
})
contact.add_email(supplier.supplier_email)
contact.add_email(supplier.supplier_email, is_primary=True)
contact.insert()
else:
contact = frappe.get_doc('Contact', contact_name)

View File

@ -350,8 +350,10 @@ def make_contact(args, is_primary_contact=1):
'link_name': args.get('name')
}]
})
contact.add_email(args.get('email_id'))
contact.add_phone(args.get('mobile_no'))
if args.get('email_id'):
contact.add_email(args.get('email_id'), is_primary=True)
if args.get('mobile_no'):
contact.add_phone(args.get('mobile_no'), is_primary_mobile_no=True)
contact.insert()
return contact

View File

@ -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.phone from `tabContact` c, `tabDynamic Link` dl where ifnull(c.phone,'')!='' and
c.mobile_no from `tabContact` c, `tabDynamic Link` dl where ifnull(c.mobile_no,'')!='' and
c.docstatus != 2 and dl.parent = c.name%s""" % where_clause)
elif self.send_to == 'All Lead (Open)':

View File

@ -10,27 +10,32 @@ def create_test_contact_and_address():
frappe.db.sql('delete from tabAddress')
frappe.db.sql('delete from `tabDynamic Link`')
frappe.get_doc(dict(
doctype='Address',
address_title='_Test Address for Customer',
address_type='Office',
address_line1='Station Road',
city='_Test City',
state='Test State',
country='India',
links = [dict(
link_doctype='Customer',
link_name='_Test Customer'
)]
)).insert()
frappe.get_doc({
"doctype": "Address",
"address_title": "_Test Address for Customer",
"address_type": "Office",
"address_line1": "Station Road",
"city": "_Test City",
"state": "Test State",
"country": "India",
"links": [
{
"link_doctype": "Customer",
"link_name": "_Test Customer"
}
]
}).insert()
frappe.get_doc(dict(
doctype='Contact',
email_id='test_contact_customer@example.com',
phone='+91 0000000000',
first_name='_Test Contact for _Test Customer',
links = [dict(
link_doctype='Customer',
link_name='_Test Customer'
)]
)).insert()
contact = frappe.get_doc({
"doctype": 'Contact',
"first_name": "_Test Contact for _Test Customer",
"links": [
{
"link_doctype": "Customer",
"link_name": "_Test Customer"
}
]
})
contact.add_email("test_contact_customer@example.com", is_primary=True)
contact.add_phone("+91 0000000000", is_primary_phone=True)
contact.insert()