Merge branch 'develop' of https://github.com/frappe/erpnext into show_address_in_online_pos
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 92734cc..55aaa02 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -33,7 +33,27 @@
}
}
})
+ frm.set_query('customer_primary_address', function(doc) {
+ return {
+ query: "erpnext.selling.doctype.customer.customer.get_customer_primary_address",
+ filters: {
+ 'customer': doc.name
+ }
+ }
+ })
},
+ customer_primary_address: function(frm){
+ if(!frm.doc.customer_primary_address){
+ frm.set_value("primary_address", "");
+ }
+ },
+ customer_primary_contact: function(frm){
+ if(!frm.doc.customer_primary_contact){
+ frm.set_value("mobile_no", "");
+ frm.set_value("email_id", "");
+ }
+ },
+
refresh: function(frm) {
if(frappe.defaults.get_default("cust_master_name")!="Naming Series") {
frm.toggle_display("naming_series", false);
@@ -43,7 +63,7 @@
frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Customer'}
- frm.toggle_display(['address_html','contact_html','primary_contact_detail'], !frm.doc.__islocal);
+ frm.toggle_display(['address_html','contact_html','primary_address_and_contact_detail'], !frm.doc.__islocal);
if(!frm.doc.__islocal) {
frappe.contacts.render_address_and_contact(frm);
diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json
index b2577d5..2c846cf 100644
--- a/erpnext/selling/doctype/customer/customer.json
+++ b/erpnext/selling/doctype/customer/customer.json
@@ -725,7 +725,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "primary_contact_detail",
+ "description": "Select, to make the customer searchable with these fields",
+ "fieldname": "primary_address_and_contact_detail",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -734,7 +735,7 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Primary Contact Detail",
+ "label": "Primary Address and Contact Detail",
"length": 0,
"no_copy": 0,
"permlevel": 0,
@@ -755,6 +756,7 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "description": "Reselect, if the chosen contact is edited after save",
"fieldname": "customer_primary_contact",
"fieldtype": "Link",
"hidden": 0,
@@ -786,6 +788,68 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
+ "fieldname": "mobile_no",
+ "fieldtype": "Read Only",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Mobile No",
+ "length": 0,
+ "no_copy": 0,
+ "options": "customer_primary_contact.mobile_no",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "fieldname": "email_id",
+ "fieldtype": "Read Only",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Email Id",
+ "length": 0,
+ "no_copy": 0,
+ "options": "customer_primary_contact.email_id",
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
+ },
+ {
+ "allow_bulk_edit": 0,
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
"fieldname": "column_break_26",
"fieldtype": "Column Break",
"hidden": 0,
@@ -815,8 +879,9 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "mobile_no",
- "fieldtype": "Read Only",
+ "description": "Reselect, if the chosen address is edited after save",
+ "fieldname": "customer_primary_address",
+ "fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
@@ -824,10 +889,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Mobile Number",
+ "label": "Customer Primary Address",
"length": 0,
"no_copy": 0,
- "options": "customer_primary_contact.mobile_no",
+ "options": "Address",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -846,7 +911,8 @@
"bold": 0,
"collapsible": 0,
"columns": 0,
- "fieldname": "email_id",
+ "default": "",
+ "fieldname": "primary_address",
"fieldtype": "Read Only",
"hidden": 0,
"ignore_user_permissions": 0,
@@ -855,10 +921,10 @@
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
- "label": "Email Id",
+ "label": "Primary Address",
"length": 0,
"no_copy": 0,
- "options": "customer_primary_contact.email_id",
+ "options": "customer_primary_address.complete_address",
"permlevel": 0,
"precision": "",
"print_hide": 0,
@@ -1383,7 +1449,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2018-01-30 11:52:05.497363",
+ "modified": "2018-02-02 16:07:11.052268",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",
@@ -1574,7 +1640,7 @@
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
- "search_fields": "customer_name,customer_group,territory, mobile_no",
+ "search_fields": "customer_name,customer_group,territory, mobile_no,primary_address",
"show_name_in_global_search": 1,
"sort_order": "ASC",
"title_field": "customer_name",
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 2284f85..6f25bf7 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -309,3 +309,15 @@
'customer': customer,
'txt': '%%%s%%' % txt
})
+
+def get_customer_primary_address(doctype, txt, searchfield, start, page_len, filters):
+ customer = frappe.db.escape(filters.get('customer'))
+ return frappe.db.sql("""
+ select `tabAddress`.name from `tabAddress`, `tabDynamic Link`
+ where `tabAddress`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
+ and `tabDynamic Link`.link_doctype = 'Customer' and `tabAddress`.is_primary_address = 1
+ and `tabAddress`.name like %(txt)s
+ """, {
+ 'customer': customer,
+ 'txt': '%%%s%%' % txt
+ })
\ No newline at end of file