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
diff --git a/erpnext/accounts/doctype/sales_invoice/pos.py b/erpnext/accounts/doctype/sales_invoice/pos.py
index 261363c..7d4fc63 100755
--- a/erpnext/accounts/doctype/sales_invoice/pos.py
+++ b/erpnext/accounts/doctype/sales_invoice/pos.py
@@ -238,7 +238,7 @@
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)
diff --git a/erpnext/accounts/page/pos/pos.js b/erpnext/accounts/page/pos/pos.js
index ff0c265..8dc00f3 100755
--- a/erpnext/accounts/page/pos/pos.js
+++ b/erpnext/accounts/page/pos/pos.js
@@ -817,6 +817,7 @@
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 @@
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 @@
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()
});
diff --git a/erpnext/crm/doctype/opportunity/test_opportunity.py b/erpnext/crm/doctype/opportunity/test_opportunity.py
index 8f61edf..33d9007 100644
--- a/erpnext/crm/doctype/opportunity/test_opportunity.py
+++ b/erpnext/crm/doctype/opportunity/test_opportunity.py
@@ -53,7 +53,7 @@
"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)
diff --git a/erpnext/hub_node/legacy.py b/erpnext/hub_node/legacy.py
index 85eb1b2..b61b88b 100644
--- a/erpnext/hub_node/legacy.py
+++ b/erpnext/hub_node/legacy.py
@@ -73,7 +73,7 @@
{'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)
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index d49b9a9..a8e3ce4 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -350,8 +350,10 @@
'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
diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py
index 289b045..bb6ba1f 100644
--- a/erpnext/selling/doctype/sms_center/sms_center.py
+++ b/erpnext/selling/doctype/sms_center/sms_center.py
@@ -31,7 +31,7 @@
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)':
diff --git a/erpnext/tests/utils.py b/erpnext/tests/utils.py
index 7024b0d..dfd3ed7 100644
--- a/erpnext/tests/utils.py
+++ b/erpnext/tests/utils.py
@@ -10,27 +10,32 @@
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()