Merge pull request #14046 from shreyashah115/min-fix

[Minor] Fixes for Customer DocType
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index ed8e6c8..88e66ca 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -5,7 +5,6 @@
 	setup: function(frm) {
 		frm.add_fetch('lead_name', 'company_name', 'customer_name');
 		frm.add_fetch('default_sales_partner','commission_rate','default_commission_rate');
-
 		frm.set_query('customer_group', {'is_group': 0});
 		frm.set_query('default_price_list', { 'selling': 1});
 		frm.set_query('account', 'accounts', function(doc, cdt, cdn) {
@@ -19,12 +18,15 @@
 			if(doc.party_account_currency) {
 				$.extend(filters, {"account_currency": doc.party_account_currency});
 			}
-
 			return {
 				filters: filters
 			}
 		});
 
+		if (frm.doc.__islocal == 1) {
+			frm.set_value("represents_company", "");
+		}
+
 		frm.set_query('customer_primary_contact', function(doc) {
 			return {
 				query: "erpnext.selling.doctype.customer.customer.get_customer_primary_contact",
@@ -58,6 +60,16 @@
 			frm.set_value("primary_address", "");
 		}
 	},
+
+	is_internal_customer: function(frm) {
+		if (frm.doc.is_internal_customer == 1) {
+			frm.toggle_reqd("represents_company", true);
+		}
+		else {
+			frm.toggle_reqd("represents_company", false);
+		}
+	},
+
 	customer_primary_contact: function(frm){
 		if(!frm.doc.customer_primary_contact){
 			frm.set_value("mobile_no", "");
@@ -73,7 +85,6 @@
 		}
 
 		frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Customer'}
-
 		frm.toggle_display(['address_html','contact_html','primary_address_and_contact_detail'], !frm.doc.__islocal);
 
 		if(!frm.doc.__islocal) {
diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json
index e38f6b3..881a6a5 100644
--- a/erpnext/selling/doctype/customer/customer.json
+++ b/erpnext/selling/doctype/customer/customer.json
@@ -493,7 +493,7 @@
    "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
-   "reqd": 1, 
+   "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
    "translatable": 0, 
@@ -1625,7 +1625,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-04-19 12:19:35.311509", 
+ "modified": "2018-05-15 15:58:22.255321", 
  "modified_by": "Administrator", 
  "module": "Selling", 
  "name": "Customer",