Merge pull request #14041 from manassolanki/deferred-account

Deferred account
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 1df3c7d..3eaf994 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -5,7 +5,7 @@
 from erpnext.hooks import regional_overrides
 from frappe.utils import getdate
 
-__version__ = '10.1.32'
+__version__ = '10.1.33'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py
index 5da0fbc..c2ccbd3 100644
--- a/erpnext/config/hr.py
+++ b/erpnext/config/hr.py
@@ -200,52 +200,14 @@
 				{
 					"type": "doctype",
 					"name": "Employee Promotion",
-				}
-			]
-		},
-		{
-			"label": _("Recruitment"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Job Applicant",
 				},
 				{
 					"type": "doctype",
-					"name": "Job Opening",
+					"name": "Employee Separation"
 				},
 				{
 					"type": "doctype",
-					"name": "Job Offer",
-				},
-			]
-		},
-		{
-			"label": _("Employee Lifecycle"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Employee Transfer",
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Promotion",
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Lifecycle Activity",
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Lifecycle Activity Type",
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Lifecycle Process Template",
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Lifecycle Process",
+					"name": "Employee Onboarding"
 				}
 			]
 		},
diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js
index b31bf0e..23d158c 100644
--- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js
+++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.js
@@ -11,14 +11,20 @@
 			}
 		});
 		frm.set_query('payroll_period', function() {
-			if(frm.doc.employee && frm.doc.company){
+			const fields = {'employee': 'Employee', 'company': 'Company'};
+
+			for (let [field, label] of Object.entries(fields)) {
+				if (!frm.doc[field]) {
+					frappe.msgprint(__("Please select {0}", [label]))
+				}
+			};
+
+			if (frm.doc.employee && frm.doc.company){
 				return {
 					filters: {
 						'company': frm.doc.company
 					}
 				}
-			}else {
-				frappe.msgprint(__("Please select Employee"));
 			}
 		});
 		frm.set_query('exemption_sub_category', 'declarations', function() {
diff --git a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json
index 3c361ee..9dee848 100644
--- a/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json
+++ b/erpnext/hr/doctype/employee_tax_exemption_declaration/employee_tax_exemption_declaration.json
@@ -42,6 +42,7 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
@@ -67,12 +68,13 @@
    "precision": "", 
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
-   "read_only": 1, 
+   "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
@@ -102,6 +104,7 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
@@ -133,6 +136,7 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
@@ -163,6 +167,7 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
@@ -192,6 +197,7 @@
    "reqd": 0, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }, 
   {
@@ -223,6 +229,7 @@
    "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
+   "translatable": 0, 
    "unique": 0
   }
  ], 
@@ -236,7 +243,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2018-05-10 13:26:25.241545", 
+ "modified": "2018-05-15 16:16:46.075493", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Employee Tax Exemption Declaration", 
@@ -245,7 +252,6 @@
  "permissions": [
   {
    "amend": 1, 
-   "apply_user_permissions": 0, 
    "cancel": 1, 
    "create": 1, 
    "delete": 1, 
@@ -265,7 +271,6 @@
   }, 
   {
    "amend": 1, 
-   "apply_user_permissions": 0, 
    "cancel": 1, 
    "create": 1, 
    "delete": 1, 
@@ -285,7 +290,6 @@
   }, 
   {
    "amend": 1, 
-   "apply_user_permissions": 0, 
    "cancel": 1, 
    "create": 1, 
    "delete": 1, 
@@ -305,7 +309,6 @@
   }, 
   {
    "amend": 1, 
-   "apply_user_permissions": 0, 
    "cancel": 1, 
    "create": 1, 
    "delete": 1, 
diff --git a/erpnext/hr/employee_property_update.js b/erpnext/hr/employee_property_update.js
index 473916c..60d06b4 100644
--- a/erpnext/hr/employee_property_update.js
+++ b/erpnext/hr/employee_property_update.js
@@ -57,7 +57,10 @@
 		primary_action_label: __('Add to Details'),
 		primary_action: () => {
 			d.get_primary_btn().attr('disabled', true);
-			if(d.data){
+			if(d.data) {
+				var input = $('[data-fieldname="field_html"] input');
+				d.data.new = input.val();
+				$(input).remove();
 				add_to_details(frm, d, table);
 			}
 		}
@@ -99,11 +102,6 @@
 	});
 	dynamic_field.make_input();
 	$(dynamic_field.label_area).text(__("New"));
-	dynamic_field.$input.on("change", function(e) {
-		d.data.new = e.target.value;
-	}).on("awesomplete-close", function(e) {
-		d.data.new = e.target.value;
-	});
 };
 
 var add_to_details = function(frm, d, table) {
diff --git a/erpnext/patches/v10_0/set_qty_in_transactions_based_on_serial_no_input.py b/erpnext/patches/v10_0/set_qty_in_transactions_based_on_serial_no_input.py
index 5dbcb1d..083b7f4 100644
--- a/erpnext/patches/v10_0/set_qty_in_transactions_based_on_serial_no_input.py
+++ b/erpnext/patches/v10_0/set_qty_in_transactions_based_on_serial_no_input.py
@@ -9,4 +9,13 @@
 
 	ss = frappe.get_doc("Stock Settings")
 	ss.set_qty_in_transactions_based_on_serial_no_input = 1
+
+	if ss.default_warehouse \
+		and not frappe.db.exists("Warehouse", ss.default_warehouse):
+			ss.default_warehouse = None
+
+	if ss.stock_uom and not frappe.db.exists("UOM", ss.stock_uom):
+		ss.stock_uom = None
+
+	ss.flags.ignore_mandatory = True
 	ss.save()
\ No newline at end of file
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",