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:
@@ -238,7 +238,7 @@ 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 from `tabContact`
|
contact = frappe.db.sql(""" select email_id, phone, mobile_no 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)
|
||||||
|
|||||||
@@ -817,6 +817,7 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
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["phone"]))
|
|| (contact && reg.test(contact["phone"]))
|
||||||
|
|| (contact && reg.test(contact["mobile_no"]))
|
||||||
|| (data.customer_group && reg.test(data.customer_group.toLowerCase()))){
|
|| (data.customer_group && reg.test(data.customer_group.toLowerCase()))){
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -833,6 +834,7 @@ 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({
|
||||||
@@ -842,9 +844,10 @@ 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']
|
'label', 'email_id', 'phone', 'mobile_no']
|
||||||
.map(key => c[key]).join(' ')
|
.map(key => c[key]).join(' ')
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class TestOpportunity(unittest.TestCase):
|
|||||||
"link_name": customer.name
|
"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)
|
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)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ def make_contact(supplier):
|
|||||||
{'link_doctype': 'Supplier', 'link_name': supplier.supplier_name}
|
{'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()
|
contact.insert()
|
||||||
else:
|
else:
|
||||||
contact = frappe.get_doc('Contact', contact_name)
|
contact = frappe.get_doc('Contact', contact_name)
|
||||||
|
|||||||
@@ -350,8 +350,10 @@ def make_contact(args, is_primary_contact=1):
|
|||||||
'link_name': args.get('name')
|
'link_name': args.get('name')
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
contact.add_email(args.get('email_id'))
|
if args.get('email_id'):
|
||||||
contact.add_phone(args.get('mobile_no'))
|
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()
|
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.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)
|
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)':
|
||||||
|
|||||||
@@ -10,27 +10,32 @@ def create_test_contact_and_address():
|
|||||||
frappe.db.sql('delete from tabAddress')
|
frappe.db.sql('delete from tabAddress')
|
||||||
frappe.db.sql('delete from `tabDynamic Link`')
|
frappe.db.sql('delete from `tabDynamic Link`')
|
||||||
|
|
||||||
frappe.get_doc(dict(
|
frappe.get_doc({
|
||||||
doctype='Address',
|
"doctype": "Address",
|
||||||
address_title='_Test Address for Customer',
|
"address_title": "_Test Address for Customer",
|
||||||
address_type='Office',
|
"address_type": "Office",
|
||||||
address_line1='Station Road',
|
"address_line1": "Station Road",
|
||||||
city='_Test City',
|
"city": "_Test City",
|
||||||
state='Test State',
|
"state": "Test State",
|
||||||
country='India',
|
"country": "India",
|
||||||
links = [dict(
|
"links": [
|
||||||
link_doctype='Customer',
|
{
|
||||||
link_name='_Test Customer'
|
"link_doctype": "Customer",
|
||||||
)]
|
"link_name": "_Test Customer"
|
||||||
)).insert()
|
}
|
||||||
|
]
|
||||||
|
}).insert()
|
||||||
|
|
||||||
frappe.get_doc(dict(
|
contact = frappe.get_doc({
|
||||||
doctype='Contact',
|
"doctype": 'Contact',
|
||||||
email_id='test_contact_customer@example.com',
|
"first_name": "_Test Contact for _Test Customer",
|
||||||
phone='+91 0000000000',
|
"links": [
|
||||||
first_name='_Test Contact for _Test Customer',
|
{
|
||||||
links = [dict(
|
"link_doctype": "Customer",
|
||||||
link_doctype='Customer',
|
"link_name": "_Test Customer"
|
||||||
link_name='_Test Customer'
|
}
|
||||||
)]
|
]
|
||||||
)).insert()
|
})
|
||||||
|
contact.add_email("test_contact_customer@example.com", is_primary=True)
|
||||||
|
contact.add_phone("+91 0000000000", is_primary_phone=True)
|
||||||
|
contact.insert()
|
||||||
|
|||||||
Reference in New Issue
Block a user