Merge branch 'develop' of github.com:frappe/erpnext into feature-pick-list
diff --git a/erpnext/accounts/doctype/account/account_tree.js b/erpnext/accounts/doctype/account/account_tree.js
index dc4c69d..b70c6d2 100644
--- a/erpnext/accounts/doctype/account/account_tree.js
+++ b/erpnext/accounts/doctype/account/account_tree.js
@@ -121,7 +121,7 @@
 	},
 	onrender: function(node) {
 		if(frappe.boot.user.can_read.indexOf("GL Entry") !== -1){
-			var dr_or_cr = node.data.balance < 0 ? "Cr" : "Dr";
+			var dr_or_cr = in_list(["Liability", "Income", "Equity"], node.data.root_type) ? "Cr" : "Dr";
 			if (node.data && node.data.balance!==undefined) {
 				$('<span class="balance-area pull-right text-muted small">'
 					+ (node.data.balance_in_account_currency ?
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js
index dd20632..ffb6d5e 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.js
@@ -10,6 +10,14 @@
 			});
 		}
 
+		frm.set_query('document_type', () => {
+			return {
+				filters: {
+					name: ['not in', ['Accounting Dimension', 'Project', 'Cost Center']]
+				}
+			};
+		});
+
 		let button = frm.doc.disabled ? "Enable" : "Disable";
 
 		frm.add_custom_button(__(button), function() {
@@ -33,10 +41,10 @@
 
 	document_type: function(frm) {
 		frm.set_value('label', frm.doc.document_type);
-		frm.set_value('fieldname', frappe.scrub(frm.doc.document_type));
+		frm.set_value('fieldname', frappe.model.scrub(frm.doc.document_type));
 
 		frappe.db.get_value('Accounting Dimension', {'document_type': frm.doc.document_type}, 'document_type', (r) => {
-			if (r.document_type) {
+			if (r && r.document_type) {
 				frm.set_df_property('document_type', 'description', "Document type is already set as dimension");
 			}
 		});
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json
index 57543a0..6a4dc5c 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.json
@@ -38,6 +38,7 @@
    "default": "0",
    "fieldname": "disabled",
    "fieldtype": "Check",
+   "hidden": 1,
    "label": "Disable",
    "read_only": 1
   },
@@ -54,7 +55,7 @@
    "label": "Mandatory For Profit and Loss Account"
   }
  ],
- "modified": "2019-07-07 18:56:19.517450",
+ "modified": "2019-07-14 17:25:01.307948",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Accounting Dimension",
diff --git a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
index 15ace72..3148498 100644
--- a/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
+++ b/erpnext/accounts/doctype/accounting_dimension/accounting_dimension.py
@@ -155,7 +155,7 @@
 	return doclist
 
 def get_accounting_dimensions(as_list=True):
-	accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["label", "fieldname", "mandatory_for_pl", "mandatory_for_bs", "disabled"])
+	accounting_dimensions = frappe.get_all("Accounting Dimension", fields=["label", "fieldname", "mandatory_for_pl", "mandatory_for_bs", "disabled"], filters={"disabled": 0})
 
 	if as_list:
 		return [d.fieldname for d in accounting_dimensions]
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
index c2372bd..4ff4212 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json
@@ -10,6 +10,7 @@
     "acc_frozen_upto",
     "frozen_accounts_modifier",
     "determine_address_tax_category_from",
+    "over_billing_allowance",
     "column_break_4",
     "credit_controller",
     "check_supplier_invoice_uniqueness",
@@ -168,12 +169,18 @@
      "fieldname": "automatically_fetch_payment_terms",
      "fieldtype": "Check",
      "label": "Automatically Fetch Payment Terms"
+    },
+    {
+     "description": "Percentage you are allowed to bill more against the amount ordered. For example: If the order value is $100 for an item and tolerance is set as 10% then you are allowed to bill for $110.",
+     "fieldname": "over_billing_allowance",
+     "fieldtype": "Currency",
+     "label": "Over Billing Allowance (%)"
     }
    ],
    "icon": "icon-cog",
    "idx": 1,
    "issingle": 1,
-   "modified": "2019-04-28 18:20:55.789946",
+   "modified": "2019-07-04 18:20:55.789946",
    "modified_by": "Administrator",
    "module": "Accounts",
    "name": "Accounts Settings",
@@ -200,4 +207,4 @@
    "quick_entry": 1,
    "sort_order": "ASC",
    "track_changes": 1
-  }
\ No newline at end of file
+  }
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js
index aea6080..40a97ae 100644
--- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.js
@@ -78,7 +78,6 @@
 
 var create_import_button = function(frm) {
 	frm.page.set_primary_action(__("Start Import"), function () {
-		setup_progress_bar(frm);
 		frappe.call({
 			method: "erpnext.accounts.doctype.chart_of_accounts_importer.chart_of_accounts_importer.import_coa",
 			args: {
@@ -86,11 +85,11 @@
 				company: frm.doc.company
 			},
 			freeze: true,
+			freeze_message: __("Creating Accounts..."),
 			callback: function(r) {
 				if(!r.exc) {
 					clearInterval(frm.page["interval"]);
 					frm.page.set_indicator(__('Import Successfull'), 'blue');
-					frappe.hide_progress();
 					create_reset_button(frm);
 				}
 			}
@@ -126,13 +125,3 @@
 		}
 	});
 };
-
-var setup_progress_bar = function(frm) {
-	frm.page["seconds_elapsed"] = 0;
-	frm.page["execution_time"] = (frm.page["total_accounts"] > 100) ? 100 : frm.page["total_accounts"];
-
-	frm.page["interval"] = setInterval(function()  {
-		frm.page["seconds_elapsed"] += 1;
-		frappe.show_progress(__('Creating Accounts'), frm.page["seconds_elapsed"], frm.page["execution_time"]);
-	}, 250);
-};
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
index 76efa48..4683c7a 100644
--- a/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
+++ b/erpnext/accounts/doctype/chart_of_accounts_importer/chart_of_accounts_importer.py
@@ -33,6 +33,9 @@
 
 def generate_data_from_csv(file_name, as_dict=False):
 	''' read csv file and return the generated nested tree '''
+	if not file_name.endswith('.csv'):
+		frappe.throw("Only CSV files can be used to for importing data. Please check the file format you are trying to upload")
+
 	file_doc = frappe.get_doc('File', {"file_url": file_name})
 	file_path = file_doc.get_full_path()
 
@@ -96,15 +99,27 @@
 				return [child] + return_parent(data, parent_account)
 
 	charts_map, paths = {}, []
+
+	line_no = 3
+	error_messages = []
+
 	for i in data:
 		account_name, _, account_number, is_group, account_type, root_type = i
+
+		if not account_name:
+			error_messages.append("Row {0}: Please enter Account Name".format(line_no))
+
 		charts_map[account_name] = {}
-		if is_group: charts_map[account_name]["is_group"] = is_group
+		if is_group == 1: charts_map[account_name]["is_group"] = is_group
 		if account_type: charts_map[account_name]["account_type"] = account_type
 		if root_type: charts_map[account_name]["root_type"] = root_type
 		if account_number: charts_map[account_name]["account_number"] = account_number
 		path = return_parent(data, account_name)[::-1]
 		paths.append(path) # List of path is created
+		line_no += 1
+
+	if error_messages:
+		frappe.throw("<br>".join(error_messages))
 
 	out = {}
 	for path in paths:
@@ -150,22 +165,27 @@
 	if len(roots) < 4:
 		return _("Number of root accounts cannot be less than 4")
 
+	error_messages = []
+
 	for account in roots:
-		if not account.get("root_type"):
-			return _("Please enter Root Type for - {0}").format(account.get("account_name"))
-		elif account.get("root_type") not in ("Asset", "Liability", "Expense", "Income", "Equity"):
-			return _('Root Type for "{0}" must be one of the Asset, Liability, Income, Expense and Equity').format(account.get("account_name"))
+		if not account.get("root_type") and account.get("account_name"):
+			error_messages.append("Please enter Root Type for account- {0}".format(account.get("account_name")))
+		elif account.get("root_type") not in ("Asset", "Liability", "Expense", "Income", "Equity") and account.get("account_name"):
+			error_messages.append("Root Type for {0} must be one of the Asset, Liability, Income, Expense and Equity".format(account.get("account_name")))
+
+	if error_messages:
+		return "<br>".join(error_messages)
 
 def validate_account_types(accounts):
 	account_types_for_ledger = ["Cost of Goods Sold", "Depreciation", "Fixed Asset", "Payable", "Receivable", "Stock Adjustment"]
-	account_types = [accounts[d]["account_type"] for d in accounts if not accounts[d]['is_group']]
+	account_types = [accounts[d]["account_type"] for d in accounts if not accounts[d]['is_group'] == 1]
 
 	missing = list(set(account_types_for_ledger) - set(account_types))
 	if missing:
 		return _("Please identify/create Account (Ledger) for type - {0}").format(' , '.join(missing))
 
 	account_types_for_group = ["Bank", "Cash", "Stock"]
-	account_groups = [accounts[d]["account_type"] for d in accounts if accounts[d]['is_group']]
+	account_groups = [accounts[d]["account_type"] for d in accounts if accounts[d]['is_group'] not in ('', 1)]
 
 	missing = list(set(account_types_for_group) - set(account_groups))
 	if missing:
diff --git a/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json b/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json
index 0d04b19..8d7ed74 100644
--- a/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json
+++ b/erpnext/accounts/doctype/discounted_invoice/discounted_invoice.json
@@ -1,177 +1,64 @@
 {
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
  "creation": "2019-03-07 12:07:09.416101",
- "custom": 0,
- "docstatus": 0,
  "doctype": "DocType",
- "document_type": "",
  "editable_grid": 1,
  "engine": "InnoDB",
+ "field_order": [
+  "sales_invoice",
+  "customer",
+  "column_break_3",
+  "posting_date",
+  "outstanding_amount"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "sales_invoice",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Invoice",
-   "length": 0,
-   "no_copy": 0,
    "options": "Sales Invoice",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fetch_from": "sales_invoice.customer",
    "fieldname": "customer",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Customer",
-   "length": 0,
-   "no_copy": 0,
    "options": "Customer",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fetch_from": "sales_invoice.posting_date",
    "fieldname": "posting_date",
    "fieldtype": "Date",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Date",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fetch_from": "sales_invoice.grand_total",
    "fieldname": "outstanding_amount",
    "fieldtype": "Currency",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Outstanding Amount",
-   "length": 0,
-   "no_copy": 0,
    "options": "Company:company:default_currency",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_3",
+   "fieldtype": "Column Break"
   }
  ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
  "istable": 1,
- "max_attachments": 0,
- "modified": "2019-03-07 16:38:03.622666",
+ "modified": "2019-05-30 19:27:29.436153",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Discounted Invoice",
- "name_case": "",
  "owner": "Administrator",
  "permissions": [],
  "quick_entry": 1,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
  "sort_field": "modified",
  "sort_order": "DESC",
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index c543225..84276ea 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -91,13 +91,13 @@
 			if account_type == "Profit and Loss" \
 				and dimension.mandatory_for_pl and not dimension.disabled:
 				if not self.get(dimension.fieldname):
-					frappe.throw(_("{0} is required for 'Profit and Loss' account {1}.")
+					frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Profit and Loss' account {1}.")
 						.format(dimension.label, self.account))
 
 			if account_type == "Balance Sheet" \
 				and dimension.mandatory_for_bs and not dimension.disabled:
 				if not self.get(dimension.fieldname):
-					frappe.throw(_("{0} is required for 'Balance Sheet' account {1}.")
+					frappe.throw(_("Accounting Dimension <b>{0}</b> is required for 'Balance Sheet' account {1}.")
 						.format(dimension.label, self.account))
 
 
diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json
index 8927ca7..3bfe259 100644
--- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json
+++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.json
@@ -1,744 +1,177 @@
 {
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
  "allow_import": 1,
- "allow_rename": 0,
  "autoname": "ACC-INV-DISC-.YYYY.-.#####",
- "beta": 0,
  "creation": "2019-03-07 12:01:56.296952",
- "custom": 0,
- "docstatus": 0,
  "doctype": "DocType",
- "document_type": "",
  "editable_grid": 1,
  "engine": "InnoDB",
+ "field_order": [
+  "posting_date",
+  "loan_start_date",
+  "loan_period",
+  "loan_end_date",
+  "column_break_3",
+  "status",
+  "company",
+  "section_break_5",
+  "invoices",
+  "section_break_7",
+  "total_amount",
+  "column_break_9",
+  "bank_charges",
+  "section_break_6",
+  "short_term_loan",
+  "bank_account",
+  "bank_charges_account",
+  "column_break_15",
+  "accounts_receivable_credit",
+  "accounts_receivable_discounted",
+  "accounts_receivable_unpaid",
+  "amended_from"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "default": "Today",
    "fieldname": "posting_date",
    "fieldtype": "Date",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Posting Date",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "loan_start_date",
    "fieldtype": "Date",
-   "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": "Loan Start Date",
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "label": "Loan Start Date"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "loan_period",
    "fieldtype": "Int",
-   "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": "Loan Period",
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "label": "Loan Period (Days)"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "loan_end_date",
    "fieldtype": "Date",
-   "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": "Loan End Date",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_3",
-   "fieldtype": "Column Break",
-   "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,
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "status",
    "fieldtype": "Select",
-   "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": "Status",
-   "length": 0,
    "no_copy": 1,
    "options": "Draft\nSanctioned\nDisbursed\nSettled\nCancelled",
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "company",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Company",
-   "length": 0,
-   "no_copy": 0,
    "options": "Company",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "section_break_5",
-   "fieldtype": "Section Break",
-   "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,
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Section Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "invoices",
    "fieldtype": "Table",
-   "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": "Invoices",
-   "length": 0,
-   "no_copy": 0,
    "options": "Discounted Invoice",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "section_break_7",
-   "fieldtype": "Section Break",
-   "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,
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Section Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "total_amount",
    "fieldtype": "Currency",
-   "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": "Total Amount",
-   "length": 0,
-   "no_copy": 0,
    "options": "Company:company:default_currency",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_9",
-   "fieldtype": "Column Break",
-   "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,
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "bank_charges",
    "fieldtype": "Currency",
-   "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": "Bank Charges",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Company:company:default_currency",
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "options": "Company:company:default_currency"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "section_break_6",
-   "fieldtype": "Section Break",
-   "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,
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Section Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "short_term_loan",
    "fieldtype": "Link",
-   "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": "Short Term Loan Account",
-   "length": 0,
-   "no_copy": 0,
    "options": "Account",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "bank_account",
    "fieldtype": "Link",
-   "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": "Bank Account",
-   "length": 0,
-   "no_copy": 0,
    "options": "Account",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "bank_charges_account",
    "fieldtype": "Link",
-   "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": "Bank Charges Account",
-   "length": 0,
-   "no_copy": 0,
    "options": "Account",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_15",
-   "fieldtype": "Column Break",
-   "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,
-   "length": 0,
-   "no_copy": 0,
-   "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,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "accounts_receivable_credit",
    "fieldtype": "Link",
-   "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": "Accounts Receivable Credit Account",
-   "length": 0,
-   "no_copy": 0,
    "options": "Account",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "accounts_receivable_discounted",
    "fieldtype": "Link",
-   "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": "Accounts Receivable Discounted Account",
-   "length": 0,
-   "no_copy": 0,
    "options": "Account",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "accounts_receivable_unpaid",
    "fieldtype": "Link",
-   "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": "Accounts Receivable Unpaid Account",
-   "length": 0,
-   "no_copy": 0,
    "options": "Account",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "amended_from",
    "fieldtype": "Link",
-   "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": "Amended From",
-   "length": 0,
    "no_copy": 1,
    "options": "Invoice Discounting",
-   "permlevel": 0,
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   }
  ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
  "is_submittable": 1,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2019-03-08 14:24:31.222027",
+ "modified": "2019-05-30 19:08:21.199759",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Invoice Discounting",
- "name_case": "",
  "owner": "Administrator",
  "permissions": [
   {
@@ -748,26 +181,17 @@
    "delete": 1,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
    "import": 1,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "System Manager",
-   "set_user_permissions": 0,
    "share": 1,
    "submit": 1,
    "write": 1
   }
  ],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
- "show_name_in_global_search": 0,
  "sort_field": "modified",
  "sort_order": "DESC",
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
index c8756af..29475d5 100644
--- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
+++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
@@ -28,18 +28,39 @@
 		self.total_amount = sum([flt(d.outstanding_amount) for d in self.invoices])
 
 	def on_submit(self):
+		self.update_sales_invoice()
 		self.make_gl_entries()
 
 	def on_cancel(self):
 		self.set_status()
+		self.update_sales_invoice()
 		self.make_gl_entries()
 
-	def set_status(self):
-		self.status = "Draft"
-		if self.docstatus == 1:
-			self.status = "Sanctioned"
-		elif self.docstatus == 2:
-			self.status = "Cancelled"
+	def set_status(self, status=None):
+		if status:
+			self.status = status
+			self.db_set("status", status)
+			for d in self.invoices:
+				frappe.get_doc("Sales Invoice", d.sales_invoice).set_status(update=True, update_modified=False)
+		else:
+			self.status = "Draft"
+			if self.docstatus == 1:
+				self.status = "Sanctioned"
+			elif self.docstatus == 2:
+				self.status = "Cancelled"
+
+	def update_sales_invoice(self):
+		for d in self.invoices:
+			if self.docstatus == 1:
+				is_discounted = 1
+			else:
+				discounted_invoice = frappe.db.exists({
+					"doctype": "Discounted Invoice",
+					"sales_invoice": d.sales_invoice,
+					"docstatus": 1
+				})
+				is_discounted = 1 if discounted_invoice else 0
+			frappe.db.set_value("Sales Invoice", d.sales_invoice, "is_discounted", is_discounted)
 
 	def make_gl_entries(self):
 		company_currency = frappe.get_cached_value('Company',  self.company, "default_currency")
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 8fbddb9..eb75d0d 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -105,24 +105,28 @@
 
 		invoice_discounting_list = list(set([d.reference_name for d in self.accounts if d.reference_type=="Invoice Discounting"]))
 		for inv_disc in invoice_discounting_list:
-			short_term_loan_account, id_status = frappe.db.get_value("Invoice Discounting", inv_disc, ["short_term_loan", "status"])
+			inv_disc_doc = frappe.get_doc("Invoice Discounting", inv_disc)
+			status = None
 			for d in self.accounts:
-				if d.account == short_term_loan_account and d.reference_name == inv_disc:
+				if d.account == inv_disc_doc.short_term_loan and d.reference_name == inv_disc:
 					if self.docstatus == 1:
 						if d.credit > 0:
-							_validate_invoice_discounting_status(inv_disc, id_status, "Sanctioned", d.idx)
+							_validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Sanctioned", d.idx)
 							status = "Disbursed"
 						elif d.debit > 0:
-							_validate_invoice_discounting_status(inv_disc, id_status, "Disbursed", d.idx)
+							_validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Disbursed", d.idx)
 							status = "Settled"
 					else:
 						if d.credit > 0:
-							_validate_invoice_discounting_status(inv_disc, id_status, "Disbursed", d.idx)
+							_validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Disbursed", d.idx)
 							status = "Sanctioned"
 						elif d.debit > 0:
-							_validate_invoice_discounting_status(inv_disc, id_status, "Settled", d.idx)
+							_validate_invoice_discounting_status(inv_disc, inv_disc_doc.status, "Settled", d.idx)
 							status = "Disbursed"
-					frappe.db.set_value("Invoice Discounting", inv_disc, "status", status)
+					break
+			if status:
+				inv_disc_doc.set_status(status=status)
+
 
 	def unlink_advance_entry_reference(self):
 		for d in self.get("accounts"):
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index 699f046..3683898 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -601,7 +601,7 @@
 		condition += " and company = {0}".format(frappe.db.escape(args.get("company")))
 
 	outstanding_invoices = get_outstanding_invoices(args.get("party_type"), args.get("party"),
-		args.get("party_account"), filters=args, condition=condition, limit=100)
+		args.get("party_account"), filters=args, condition=condition)
 
 	for d in outstanding_invoices:
 		d["exchange_rate"] = 1
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index c3c3e26..1fe6895 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -83,10 +83,14 @@
 				}
 			}
 
-			if (doc.outstanding_amount>0 && !cint(doc.is_return)) {
+			if (doc.outstanding_amount>0) {
 				cur_frm.add_custom_button(__('Payment Request'), function() {
 					me.make_payment_request();
 				}, __('Create'));
+
+				cur_frm.add_custom_button(__('Invoice Discounting'), function() {
+					cur_frm.events.create_invoice_discounting(cur_frm);
+				}, __('Create'));
 			}
 
 			if (doc.docstatus === 1) {
@@ -808,6 +812,13 @@
 			frm.set_df_property("patient_name", "hidden", 1);
 			frm.set_df_property("ref_practitioner", "hidden", 1);
 		}
+	},
+
+	create_invoice_discounting: function(frm) {
+		frappe.model.open_mapped_doc({
+			method: "erpnext.accounts.doctype.sales_invoice.sales_invoice.create_invoice_discounting",
+			frm: frm
+		});
 	}
 })
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 4aec1c8..1f57836 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -155,6 +155,7 @@
     "inter_company_invoice_reference",
     "customer_group",
     "campaign",
+    "is_discounted",
     "col_break23",
     "status",
     "source",
@@ -1325,6 +1326,13 @@
      "print_hide": 1
     },
     {
+     "fieldname": "is_discounted",
+     "fieldtype": "Check",
+     "label": "Is Discounted",
+     "no_copy": 1,
+     "read_only": 1
+    },
+    {
      "fieldname": "col_break23",
      "fieldtype": "Column Break",
      "width": "50%"
@@ -1336,7 +1344,7 @@
      "in_standard_filter": 1,
      "label": "Status",
      "no_copy": 1,
-     "options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled",
+     "options": "\nDraft\nReturn\nCredit Note Issued\nSubmitted\nPaid\nUnpaid\nUnpaid and Discounted\nOverdue and Discounted\nOverdue\nOverdue\nCancelled",
      "print_hide": 1,
      "read_only": 1
     },
@@ -1558,7 +1566,7 @@
    "icon": "fa fa-file-text",
    "idx": 181,
    "is_submittable": 1,
-   "modified": "2019-05-25 22:05:03.474745",
+   "modified": "2019-07-04 22:05:03.474745",
    "modified_by": "Administrator",
    "module": "Accounts",
    "name": "Sales Invoice",
@@ -1612,4 +1620,4 @@
    "title_field": "title",
    "track_changes": 1,
    "track_seen": 1
-  }
\ No newline at end of file
+  }
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index f8bb971..88ad6b3 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -1177,6 +1177,56 @@
 
 		self.set_missing_values(for_validate = True)
 
+	def get_discounting_status(self):
+		status = None
+		if self.is_discounted:
+			invoice_discounting_list = frappe.db.sql("""
+				select status
+				from `tabInvoice Discounting` id, `tabDiscounted Invoice` d
+				where
+					id.name = d.parent
+					and d.sales_invoice=%s
+					and id.docstatus=1
+					and status in ('Disbursed', 'Settled')
+			""", self.name)
+			for d in invoice_discounting_list:
+				status = d[0]
+				if status == "Disbursed":
+					break
+		return status
+
+	def set_status(self, update=False, status=None, update_modified=True):
+		if self.is_new():
+			if self.get('amended_from'):
+				self.status = 'Draft'
+			return
+
+		if not status:
+			if self.docstatus == 2:
+				status = "Cancelled"
+			elif self.docstatus == 1:
+				if flt(self.outstanding_amount) > 0 and getdate(self.due_date) < getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed':
+					self.status = "Overdue and Discounted"
+				elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) < getdate(nowdate()):
+					self.status = "Overdue"
+				elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.is_discounted and self.get_discounting_status()=='Disbursed':
+					self.status = "Unpaid and Discounted"
+				elif flt(self.outstanding_amount) > 0 and getdate(self.due_date) >= getdate(nowdate()):
+					self.status = "Unpaid"
+				elif flt(self.outstanding_amount) < 0 and self.is_return==0 and frappe.db.get_value('Sales Invoice', {'is_return': 1, 'return_against': self.name, 'docstatus': 1}):
+					self.status = "Credit Note Issued"
+				elif self.is_return == 1:
+					self.status = "Return"
+				elif flt(self.outstanding_amount)<=0:
+					self.status = "Paid"
+				else:
+					self.status = "Submitted"
+			else:
+				self.status = "Draft"
+
+		if update:
+			self.db_set('status', self.status, update_modified = update_modified)
+
 def validate_inter_company_party(doctype, party, company, inter_company_reference):
 	if not party:
 		return
@@ -1431,4 +1481,18 @@
 		frappe.db.set(customer, 'loyalty_program', lp_details[0])
 		return []
 	else:
-		return lp_details
\ No newline at end of file
+		return lp_details
+
+@frappe.whitelist()
+def create_invoice_discounting(source_name, target_doc=None):
+	invoice = frappe.get_doc("Sales Invoice", source_name)
+	invoice_discounting = frappe.new_doc("Invoice Discounting")
+	invoice_discounting.company = invoice.company
+	invoice_discounting.append("invoices", {
+		"sales_invoice": source_name,
+		"customer": invoice.customer,
+		"posting_date": invoice.posting_date,
+		"outstanding_amount": invoice.outstanding_amount
+	})
+
+	return invoice_discounting
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js
index 52d2924..05d49df 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js
@@ -6,17 +6,18 @@
 	add_fields: ["customer", "customer_name", "base_grand_total", "outstanding_amount", "due_date", "company",
 		"currency", "is_return"],
 	get_indicator: function(doc) {
-		if(flt(doc.outstanding_amount) < 0) {
-			return [__("Credit Note Issued"), "darkgrey", "outstanding_amount,<,0"]
-		} else if (flt(doc.outstanding_amount) > 0 && doc.due_date >= frappe.datetime.get_today()) {
-			return [__("Unpaid"), "orange", "outstanding_amount,>,0|due_date,>,Today"]
-		} else if (flt(doc.outstanding_amount) > 0 && doc.due_date < frappe.datetime.get_today()) {
-			return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<=,Today"]
-		} else if(cint(doc.is_return)) {
-			return [__("Return"), "darkgrey", "is_return,=,Yes"];
-		} else if(flt(doc.outstanding_amount)==0) {
-			return [__("Paid"), "green", "outstanding_amount,=,0"]
-		}
+		var status_color = {
+			"Draft": "grey",
+			"Unpaid": "orange",
+			"Paid": "green",
+			"Return": "darkgrey",
+			"Credit Note Issued": "darkgrey",
+			"Unpaid and Discounted": "orange",
+			"Overdue and Discounted": "red",
+			"Overdue": "red"
+
+		};
+		return [__(doc.status), status_color[doc.status], "status,=,"+doc.status];
 	},
 	right_column: "grand_total"
 };
diff --git a/erpnext/accounts/report/accounts_payable/accounts_payable.js b/erpnext/accounts/report/accounts_payable/accounts_payable.js
index f6a561f..cfcc575 100644
--- a/erpnext/accounts/report/accounts_payable/accounts_payable.js
+++ b/erpnext/accounts/report/accounts_payable/accounts_payable.js
@@ -89,6 +89,12 @@
 			}
 		},
 		{
+			"fieldname":"payment_terms_template",
+			"label": __("Payment Terms Template"),
+			"fieldtype": "Link",
+			"options": "Payment Terms Template"
+		},
+		{
 			"fieldname":"supplier_group",
 			"label": __("Supplier Group"),
 			"fieldtype": "Link",
diff --git a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
index ec4f0c9..006068a 100644
--- a/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
+++ b/erpnext/accounts/report/accounts_payable_summary/accounts_payable_summary.js
@@ -78,6 +78,12 @@
 			"options": "Supplier"
 		},
 		{
+			"fieldname":"payment_terms_template",
+			"label": __("Payment Terms Template"),
+			"fieldtype": "Link",
+			"options": "Payment Terms Template"
+		},
+		{
 			"fieldname":"supplier_group",
 			"label": __("Supplier Group"),
 			"fieldtype": "Link",
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
index 0cda2c1..ecf149b 100755
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py
@@ -541,6 +541,10 @@
 					where supplier_group=%s)""")
 				values.append(self.filters.get("supplier_group"))
 
+			if self.filters.get("payment_terms_template"):
+				conditions.append("party in (select name from tabSupplier where payment_terms=%s)")
+				values.append(self.filters.get("payment_terms_template"))
+
 		if self.filters.get("cost_center"):
 			lft, rgt = frappe.get_cached_value("Cost Center",
 				self.filters.get("cost_center"), ['lft', 'rgt'])
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py
index 75d99e7..cd3d8dc 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/cash_flow.py
@@ -69,7 +69,9 @@
 	add_total_row_account(data, data, _("Net Change in Cash"), period_list, company_currency)
 	columns = get_columns(filters.periodicity, period_list, filters.accumulated_values, filters.company)
 
-	return columns, data
+	chart = get_chart_data(columns, data)
+
+	return columns, data, None, chart
 
 def get_cash_flow_accounts():
 	operation_accounts = {
@@ -171,4 +173,21 @@
 			total_row["total"] += row["total"]
 
 	out.append(total_row)
-	out.append({})
\ No newline at end of file
+	out.append({})
+
+def get_chart_data(columns, data):
+	labels = [d.get("label") for d in columns[2:]]
+	datasets = [{'name':account.get('account').replace("'", ""), 'values': [account.get('total')]}  for account in data if account.get('parent_account') == None and account.get('currency')]
+	datasets = datasets[:-1]
+
+	chart = {
+		"data": {
+			'labels': labels,
+			'datasets': datasets
+		},
+		"type": "bar"
+	}
+	
+	chart["fieldtype"] = "Currency"
+
+	return chart
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index f7c0250..86fd108 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -11,6 +11,7 @@
 from erpnext.accounts.report.financial_statements import get_cost_centers_with_children
 from six import iteritems
 from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions
+from collections import OrderedDict
 
 def execute(filters=None):
 	if not filters:
@@ -274,7 +275,7 @@
 		return 'voucher_no'
 
 def initialize_gle_map(gl_entries, filters):
-	gle_map = frappe._dict()
+	gle_map = OrderedDict()
 	group_by = group_by_field(filters.get('group_by'))
 
 	for gle in gl_entries:
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 542c7e4..e41c74c 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -104,6 +104,9 @@
 		# get balance of all entries that exist
 		date = nowdate()
 
+	if account:
+		acc = frappe.get_doc("Account", account)
+
 	try:
 		year_start_date = get_fiscal_year(date, verbose=0)[1]
 	except FiscalYearError:
@@ -118,7 +121,7 @@
 
 	allow_cost_center_in_entry_of_bs_account = get_allow_cost_center_in_entry_of_bs_account()
 
-	if cost_center and allow_cost_center_in_entry_of_bs_account:
+	if cost_center and (allow_cost_center_in_entry_of_bs_account or acc.report_type =='Profit and Loss'):
 		cc = frappe.get_doc("Cost Center", cost_center)
 		if cc.is_group:
 			cond.append(""" exists (
@@ -132,20 +135,13 @@
 
 	if account:
 
-		acc = frappe.get_doc("Account", account)
-
 		if not frappe.flags.ignore_account_permission:
 			acc.check_permission("read")
 
-
-		if not allow_cost_center_in_entry_of_bs_account and acc.report_type == 'Profit and Loss':
+		if acc.report_type == 'Profit and Loss':
 			# for pl accounts, get balance within a fiscal year
 			cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \
 				% year_start_date)
-		elif allow_cost_center_in_entry_of_bs_account:
-			# for all accounts, get balance within a fiscal year if maintain cost center in balance account is checked
-			cond.append("posting_date >= '%s' and voucher_type != 'Period Closing Voucher'" \
-				% year_start_date)
 		# different filter for group and ledger - improved performance
 		if acc.is_group:
 			cond.append("""exists (
@@ -734,6 +730,7 @@
 	parent_fieldname = 'parent_' + doctype.lower().replace(' ', '_')
 	fields = [
 		'name as value',
+		'root_type',
 		'is_group as expandable'
 	]
 	filters = [['docstatus', '<', 2]]
@@ -741,7 +738,7 @@
 	filters.append(['ifnull(`{0}`,"")'.format(parent_fieldname), '=', '' if is_root else parent])
 
 	if is_root:
-		fields += ['root_type', 'report_type', 'account_currency'] if doctype == 'Account' else []
+		fields += ['report_type', 'account_currency'] if doctype == 'Account' else []
 		filters.append(['company', '=', company])
 
 	else:
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index be68594..ff0b65b 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import unittest
 import frappe
+import json
 import frappe.defaults
 from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
 from frappe.utils import flt, add_days, nowdate, getdate
@@ -15,7 +16,7 @@
 from erpnext.stock.doctype.material_request.material_request import make_purchase_order
 from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
 from erpnext.controllers.accounts_controller import update_child_qty_rate
-import json
+from erpnext.controllers.status_updater import OverAllowanceError
 
 class TestPurchaseOrder(unittest.TestCase):
 	def test_make_purchase_receipt(self):
@@ -41,7 +42,7 @@
 		po.load_from_db()
 		self.assertEqual(po.get("items")[0].received_qty, 4)
 
-		frappe.db.set_value('Item', '_Test Item', 'tolerance', 50)
+		frappe.db.set_value('Item', '_Test Item', 'over_delivery_receipt_allowance', 50)
 
 		pr = create_pr_against_po(po.name, received_qty=8)
 		self.assertEqual(get_ordered_qty(), existing_ordered_qty)
@@ -57,12 +58,12 @@
 
 	def test_ordered_qty_against_pi_with_update_stock(self):
 		existing_ordered_qty = get_ordered_qty()
-
 		po = create_purchase_order()
 
 		self.assertEqual(get_ordered_qty(), existing_ordered_qty + 10)
 
-		frappe.db.set_value('Item', '_Test Item', 'tolerance', 50)
+		frappe.db.set_value('Item', '_Test Item', 'over_delivery_receipt_allowance', 50)
+		frappe.db.set_value('Item', '_Test Item', 'over_billing_allowance', 20)
 
 		pi = make_pi_from_po(po.name)
 		pi.update_stock = 1
@@ -81,6 +82,11 @@
 		po.load_from_db()
 		self.assertEqual(po.get("items")[0].received_qty, 0)
 
+		frappe.db.set_value('Item', '_Test Item', 'over_delivery_receipt_allowance', 0)
+		frappe.db.set_value('Item', '_Test Item', 'over_billing_allowance', 0)
+		frappe.db.set_value("Accounts Settings", None, "over_billing_allowance", 0)
+
+
 	def test_update_child_qty_rate(self):
 		mr = make_material_request(qty=10)
 		po = make_purchase_order(mr.name)
diff --git a/erpnext/config/accounting.py b/erpnext/config/accounting.py
index ce1384a..ab75f21 100644
--- a/erpnext/config/accounting.py
+++ b/erpnext/config/accounting.py
@@ -6,11 +6,12 @@
 def get_data():
 	config = [
 		{
-			"label": _("Masters and Accounts"),
+			"label": _("Accounts Receivable"),
 			"items": [
 				{
 					"type": "doctype",
-					"name": "Item",
+					"name": "Sales Invoice",
+					"description": _("Bills raised to Customers."),
 					"onboard": 1,
 				},
 				{
@@ -21,12 +22,115 @@
 				},
 				{
 					"type": "doctype",
+					"name": "Payment Entry",
+					"description": _("Bank/Cash transactions against party or for internal transfer")
+				},
+				{
+					"type": "doctype",
+					"name": "Payment Request",
+					"description": _("Payment Request"),
+				},
+				{
+					"type": "report",
+					"name": "Accounts Receivable",
+					"doctype": "Sales Invoice",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Accounts Receivable Summary",
+					"doctype": "Sales Invoice",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Sales Register",
+					"doctype": "Sales Invoice",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Item-wise Sales Register",
+					"is_query_report": True,
+					"doctype": "Sales Invoice"
+				},
+				{
+					"type": "report",
+					"name": "Ordered Items To Be Billed",
+					"is_query_report": True,
+					"doctype": "Sales Invoice"
+				},
+				{
+					"type": "report",
+					"name": "Delivered Items To Be Billed",
+					"is_query_report": True,
+					"doctype": "Sales Invoice"
+				},
+			]
+		},
+		{
+			"label": _("Accounts Payable"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Purchase Invoice",
+					"description": _("Bills raised by Suppliers."),
+					"onboard": 1
+				},
+				{
+					"type": "doctype",
 					"name": "Supplier",
 					"description": _("Supplier database."),
 					"onboard": 1,
 				},
 				{
 					"type": "doctype",
+					"name": "Payment Entry",
+					"description": _("Bank/Cash transactions against party or for internal transfer")
+				},
+				{
+					"type": "report",
+					"name": "Accounts Payable",
+					"doctype": "Purchase Invoice",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Accounts Payable Summary",
+					"doctype": "Purchase Invoice",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Purchase Register",
+					"doctype": "Purchase Invoice",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Item-wise Purchase Register",
+					"is_query_report": True,
+					"doctype": "Purchase Invoice"
+				},
+				{
+					"type": "report",
+					"name": "Purchase Order Items To Be Billed",
+					"is_query_report": True,
+					"doctype": "Purchase Invoice"
+				},
+				{
+					"type": "report",
+					"name": "Received Items To Be Billed",
+					"is_query_report": True,
+					"doctype": "Purchase Invoice"
+				},
+			]
+		},
+		{
+			"label": _("Accounting Masters"),
+			"items": [
+				{
+					"type": "doctype",
 					"name": "Company",
 					"description": _("Company (not Customer or Supplier) master."),
 					"onboard": 1,
@@ -40,70 +144,9 @@
 					"description": _("Tree of financial accounts."),
 					"onboard": 1,
 				},
-			]
-		},
-		{
-			"label": _("Billing"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Sales Invoice",
-					"description": _("Bills raised to Customers."),
-					"onboard": 1,
-				},
-				{
-					"type": "doctype",
-					"name": "Purchase Invoice",
-					"description": _("Bills raised by Suppliers."),
-					"onboard": 1
-				},
-				{
-					"type": "doctype",
-					"name": "Payment Request",
-					"description": _("Payment Request"),
-				},
-				{
-					"type": "doctype",
-					"name": "Payment Term",
-					"description": _("Payment Terms based on conditions")
-				},
-
-				# Reports
-				{
-					"type": "report",
-					"name": "Ordered Items To Be Billed",
-					"is_query_report": True,
-					"reference_doctype": "Sales Invoice"
-				},
-				{
-					"type": "report",
-					"name": "Delivered Items To Be Billed",
-					"is_query_report": True,
-					"reference_doctype": "Sales Invoice"
-				},
-				{
-					"type": "report",
-					"name": "Purchase Order Items To Be Billed",
-					"is_query_report": True,
-					"reference_doctype": "Purchase Invoice"
-				},
-				{
-					"type": "report",
-					"name": "Received Items To Be Billed",
-					"is_query_report": True,
-					"reference_doctype": "Purchase Invoice"
-				},
-			]
-
-		},
-		{
-			"label": _("Settings"),
-			"icon": "fa fa-cog",
-			"items": [
 				{
 					"type": "doctype",
 					"name": "Accounts Settings",
-					"description": _("Default settings for accounting transactions.")
 				},
 				{
 					"type": "doctype",
@@ -112,129 +155,20 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Currency",
-					"description": _("Enable / disable currencies.")
-				},
-				{
-					"type": "doctype",
-					"name": "Currency Exchange",
-					"description": _("Currency exchange rate master.")
-				},
-				{
-					"type": "doctype",
-					"name": "Exchange Rate Revaluation",
-					"description": _("Exchange Rate Revaluation master.")
-				},
-				{
-					"type": "doctype",
-					"name": "Payment Gateway Account",
-					"description": _("Setup Gateway accounts.")
-				},
-				{
-					"type": "doctype",
-					"name": "Terms and Conditions",
-					"label": _("Terms and Conditions Template"),
-					"description": _("Template of terms or contract.")
-				},
-				{
-					"type": "doctype",
-					"name": "Mode of Payment",
-					"description": _("e.g. Bank, Cash, Credit Card")
-				},
-				{
-					"type": "doctype",
-					"name": "Auto Repeat",
-					"label": _("Auto Repeat"),
-					"description": _("To make recurring documents")
-				},
-				{
-					"type": "doctype",
-					"name": "C-Form",
-					"description": _("C-Form records"),
-					"country": "India"
-				},
-				{
-					"type": "doctype",
-					"name": "Cheque Print Template",
-					"description": _("Setup cheque dimensions for printing")
-				},
-				{
-					"type": "doctype",
 					"name": "Accounting Dimension",
-					"description": _("Setup custom dimensions for accounting")
 				},
 				{
 					"type": "doctype",
-					"name": "Opening Invoice Creation Tool",
-					"description": _("Create Opening Sales and Purchase Invoices")
-				}
-			]
-		},
-		{
-			"label": _("Accounting Entries"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Payment Entry",
-					"description": _("Bank/Cash transactions against party or for internal transfer")
+					"name": "Finance Book",
 				},
 				{
 					"type": "doctype",
-					"name": "Journal Entry",
-					"description": _("Accounting journal entries.")
-				}
-			]
-		},
-		{
-			"label": _("Financial Statements"),
-			"items": [
-				{
-					"type": "report",
-					"name": "General Ledger",
-					"doctype": "GL Entry",
-					"is_query_report": True,
+					"name": "Accounting Period",
 				},
 				{
-					"type": "report",
-					"name": "Accounts Receivable",
-					"doctype": "Sales Invoice",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Accounts Payable",
-					"doctype": "Purchase Invoice",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Trial Balance",
-					"doctype": "GL Entry",
-					"is_query_report": True,
-				},
-				{
-					"type": "report",
-					"name": "Balance Sheet",
-					"doctype": "GL Entry",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Cash Flow",
-					"doctype": "GL Entry",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Profit and Loss Statement",
-					"doctype": "GL Entry",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Consolidated Financial Statement",
-					"doctype": "GL Entry",
-					"is_query_report": True
+					"type": "doctype",
+					"name": "Payment Term",
+					"description": _("Payment Terms based on conditions")
 				},
 			]
 		},
@@ -243,44 +177,11 @@
 			"items": [
 				{
 					"type": "doctype",
-					"label": _("Bank"),
-					"name": "Bank",
+					"label": _("Match Payments with Invoices"),
+					"name": "Payment Reconciliation",
+					"description": _("Match non-linked Invoices and Payments.")
 				},
 				{
-					"type": "page",
-					"label": _("Reconcile payments and bank transactions"),
-					"name": "bank-reconciliation",
-					"description": _("Link bank transactions with payments.")
-				},
-				{
-					"type": "doctype",
-					"label": _("Bank Account"),
-					"name": "Bank Account",
-				},
-				{
-					"type": "doctype",
-					"label": _("Invoice Discounting"),
-					"name": "Invoice Discounting",
-				},
-				{
-					"type": "doctype",
-					"label": _("Bank Statement Transaction Entry List"),
-					"name": "Bank Statement Transaction Entry",
-					"route": "#List/Bank Statement Transaction Entry",
-				},
-				{
-					"type": "doctype",
-					"label": _("Bank Statement Transaction Entry Report"),
-					"name": "Bank Statement Transaction Entry",
-					"route": "#Report/Bank Statement Transaction Entry",
-				},
-				{
-					"type": "doctype",
-					"label": _("Bank Statement Settings"),
-					"name": "Bank Statement Settings",
-				},
-
-				{
 					"type": "doctype",
 					"label": _("Update Bank Transaction Dates"),
 					"name": "Bank Reconciliation",
@@ -288,9 +189,8 @@
 				},
 				{
 					"type": "doctype",
-					"label": _("Match Payments with Invoices"),
-					"name": "Payment Reconciliation",
-					"description": _("Match non-linked Invoices and Payments.")
+					"label": _("Invoice Discounting"),
+					"name": "Invoice Discounting",
 				},
 				{
 					"type": "report",
@@ -306,8 +206,75 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Bank Guarantee",
-					"doctype": "Bank Guarantee"
+					"name": "Bank Guarantee"
+				},
+				{
+					"type": "doctype",
+					"name": "Cheque Print Template",
+					"description": _("Setup cheque dimensions for printing")
+				},
+			]
+		},
+		{
+			"label": _("General Ledger"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Journal Entry",
+					"description": _("Accounting journal entries.")
+				},
+				{
+					"type": "report",
+					"name": "General Ledger",
+					"doctype": "GL Entry",
+					"is_query_report": True,
+				},
+				{
+					"type": "report",
+					"name": "Customer Ledger Summary",
+					"doctype": "Sales Invoice",
+					"is_query_report": True,
+				},
+				{
+					"type": "report",
+					"name": "Supplier Ledger Summary",
+					"doctype": "Sales Invoice",
+					"is_query_report": True,
+				}
+			]
+		},
+		{
+			"label": _("Taxes"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Sales Taxes and Charges Template",
+					"description": _("Tax template for selling transactions.")
+				},
+				{
+					"type": "doctype",
+					"name": "Purchase Taxes and Charges Template",
+					"description": _("Tax template for buying transactions.")
+				},
+				{
+					"type": "doctype",
+					"name": "Item Tax Template",
+					"description": _("Tax template for item tax rates.")
+				},
+				{
+					"type": "doctype",
+					"name": "Tax Category",
+					"description": _("Tax Category for overriding tax rates.")
+				},
+				{
+					"type": "doctype",
+					"name": "Tax Rule",
+					"description": _("Tax Rule for transactions.")
+				},
+				{
+					"type": "doctype",
+					"name": "Tax Withholding Category",
+					"description": _("Tax Withholding rates to be applied on transactions.")
 				},
 			]
 		},
@@ -328,6 +295,10 @@
 					"description": _("Define budget for a financial year.")
 				},
 				{
+					"type": "doctype",
+					"name": "Accounting Dimension",
+				},
+				{
 					"type": "report",
 					"name": "Budget Variance Report",
 					"is_query_report": True,
@@ -338,51 +309,106 @@
 					"name": "Monthly Distribution",
 					"description": _("Seasonality for setting budgets, targets etc.")
 				},
+			]
+		},
+		{
+			"label": _("Financial Statements"),
+			"items": [
+				{
+					"type": "report",
+					"name": "Trial Balance",
+					"doctype": "GL Entry",
+					"is_query_report": True,
+				},
+				{
+					"type": "report",
+					"name": "Profit and Loss Statement",
+					"doctype": "GL Entry",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Balance Sheet",
+					"doctype": "GL Entry",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Cash Flow",
+					"doctype": "GL Entry",
+					"is_query_report": True
+				},
+				{
+					"type": "report",
+					"name": "Consolidated Financial Statement",
+					"doctype": "GL Entry",
+					"is_query_report": True
+				},
+			]
+		},
+		{
+			"label": _("Opening and Closing"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Opening Invoice Creation Tool",
+				},
+				{
+					"type": "doctype",
+					"name": "Chart of Accounts Importer",
+				},
 				{
 					"type": "doctype",
 					"name": "Period Closing Voucher",
 					"description": _("Close Balance Sheet and book Profit or Loss.")
 				},
 			]
+
 		},
 		{
-			"label": _("Taxes"),
+			"label": _("Multi Currency"),
 			"items": [
 				{
 					"type": "doctype",
-					"name": "Tax Category",
-					"description": _("Tax Category for overriding tax rates.")
+					"name": "Currency",
+					"description": _("Enable / disable currencies.")
 				},
 				{
 					"type": "doctype",
-					"name": "Sales Taxes and Charges Template",
-					"description": _("Tax template for selling transactions.")
+					"name": "Currency Exchange",
+					"description": _("Currency exchange rate master.")
 				},
 				{
 					"type": "doctype",
-					"name": "Purchase Taxes and Charges Template",
-					"description": _("Tax template for buying transactions.")
+					"name": "Exchange Rate Revaluation",
+					"description": _("Exchange Rate Revaluation master.")
+				},
+			]
+		},
+		{
+			"label": _("Settings"),
+			"icon": "fa fa-cog",
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Payment Gateway Account",
+					"description": _("Setup Gateway accounts.")
 				},
 				{
 					"type": "doctype",
-					"name": "Item Tax Template",
-					"description": _("Tax template for item tax rates.")
+					"name": "Terms and Conditions",
+					"label": _("Terms and Conditions Template"),
+					"description": _("Template of terms or contract.")
 				},
 				{
 					"type": "doctype",
-					"name": "Tax Rule",
-					"description": _("Tax Rule for transactions.")
-				},
-				{
-					"type": "doctype",
-					"name": "Tax Withholding Category",
-					"description": _("Tax Withholding rates to be applied on transactions.")
+					"name": "Mode of Payment",
+					"description": _("e.g. Bank, Cash, Credit Card")
 				},
 			]
 		},
 		{
 			"label": _("Subscription Management"),
-			"icon": "fa fa-microchip ",
 			"items": [
 				{
 					"type": "doctype",
@@ -403,7 +429,31 @@
 			]
 		},
 		{
-			"label": _("Key Reports"),
+			"label": _("Bank Statement"),
+			"items": [
+				{
+					"type": "doctype",
+					"label": _("Bank"),
+					"name": "Bank",
+				},
+				{
+					"type": "doctype",
+					"label": _("Bank Account"),
+					"name": "Bank Account",
+				},
+				{
+					"type": "doctype",
+					"name": "Bank Statement Transaction Entry",
+				},
+				{
+					"type": "doctype",
+					"label": _("Bank Statement Settings"),
+					"name": "Bank Statement Settings",
+				},
+			]
+		},
+		{
+			"label": _("Profitability"),
 			"items": [
 				{
 					"type": "report",
@@ -413,21 +463,9 @@
 				},
 				{
 					"type": "report",
-					"name": "Sales Register",
-					"doctype": "Sales Invoice",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Purchase Register",
-					"doctype": "Purchase Invoice",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Purchase Invoice Trends",
+					"name": "Profitability Analysis",
+					"doctype": "GL Entry",
 					"is_query_report": True,
-					"doctype": "Purchase Invoice"
 				},
 				{
 					"type": "report",
@@ -437,38 +475,14 @@
 				},
 				{
 					"type": "report",
-					"name": "Item-wise Sales Register",
-					"is_query_report": True,
-					"doctype": "Sales Invoice"
-				},
-				{
-					"type": "report",
-					"name": "Item-wise Purchase Register",
+					"name": "Purchase Invoice Trends",
 					"is_query_report": True,
 					"doctype": "Purchase Invoice"
 				},
-				{
-					"type": "report",
-					"name": "Profitability Analysis",
-					"doctype": "GL Entry",
-					"is_query_report": True,
-				},
-				{
-					"type": "report",
-					"name": "Customer Ledger Summary",
-					"doctype": "Sales Invoice",
-					"is_query_report": True,
-				},
-				{
-					"type": "report",
-					"name": "Supplier Ledger Summary",
-					"doctype": "Sales Invoice",
-					"is_query_report": True,
-				}
 			]
 		},
 		{
-			"label": _("Other Reports"),
+			"label": _("Reports"),
 			"icon": "fa fa-table",
 			"items": [
 				{
@@ -491,18 +505,6 @@
 				},
 				{
 					"type": "report",
-					"name": "Accounts Receivable Summary",
-					"doctype": "Sales Invoice",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
-					"name": "Accounts Payable Summary",
-					"doctype": "Purchase Invoice",
-					"is_query_report": True
-				},
-				{
-					"type": "report",
 					"is_query_report": True,
 					"name": "Customer Credit Balance",
 					"doctype": "Customer"
@@ -549,27 +551,7 @@
 				}
 			]
 		},
-		{
-			"label": _("Help"),
-			"icon": "fa fa-facetime-video",
-			"items": [
-				{
-					"type": "help",
-					"label": _("Chart of Accounts"),
-					"youtube_id": "DyR-DST-PyA"
-				},
-				{
-					"type": "help",
-					"label": _("Opening Accounting Balance"),
-					"youtube_id": "kdgM20Q-q68"
-				},
-				{
-					"type": "help",
-					"label": _("Setting up Taxes"),
-					"youtube_id": "nQ1zZdPgdaQ"
-				}
-			]
-		}
+
 	]
 
 	gst = {
@@ -617,6 +599,12 @@
 				"name": "GST Itemised Purchase Register",
 				"is_query_report": True
 			},
+			{
+				"type": "doctype",
+				"name": "C-Form",
+				"description": _("C-Form records"),
+				"country": "India"
+			},
 		]
 	}
 
@@ -624,6 +612,6 @@
 	countries = frappe.get_all("Company", fields="country")
 	countries = [country["country"] for country in countries]
 	if "India" in countries:
-		config.insert(7, gst)
+		config.insert(9, gst)
 	domains = frappe.get_active_domains()
 	return config
diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py
index ba34923..e0f4be9 100644
--- a/erpnext/config/buying.py
+++ b/erpnext/config/buying.py
@@ -228,29 +228,5 @@
 				}
 			]
 		},
-		{
-			"label": _("Help"),
-			"items": [
-				{
-					"type": "help",
-					"label": _("Customer and Supplier"),
-					"youtube_id": "anoGi_RpQ20"
-				},
-				{
-					"type": "help",
-					"label": _("Material Request to Purchase Order"),
-					"youtube_id": "4TN9kPyfIqM"
-				},
-				{
-					"type": "help",
-					"label": _("Purchase Order to Payment"),
-					"youtube_id": "EK65tLdVUDk"
-				},
-				{
-					"type": "help",
-					"label": _("Managing Subcontracting"),
-					"youtube_id": "ThiMCC2DtKo"
-				},
-			]
-		},
+		
 	]
diff --git a/erpnext/config/healthcare.py b/erpnext/config/healthcare.py
index 1311111..756d22e 100644
--- a/erpnext/config/healthcare.py
+++ b/erpnext/config/healthcare.py
@@ -26,8 +26,8 @@
 				},
 				{
 					"type": "page",
-					"name": "medical_record",
-					"label": _("Patient Medical Record"),
+					"name": "patient_history",
+					"label": _("Patient History"),
 				},
 				{
 					"type": "page",
diff --git a/erpnext/config/hr.py b/erpnext/config/hr.py
index 21e6a50..261edaf 100644
--- a/erpnext/config/hr.py
+++ b/erpnext/config/hr.py
@@ -4,7 +4,7 @@
 def get_data():
 	return [
 		{
-			"label": _("Employee and Attendance"),
+			"label": _("Employee"),
 			"items": [
 				{
 					"type": "doctype",
@@ -13,120 +13,6 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Employee Attendance Tool",
-					"hide_count": True,
-					"onboard": 1,
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Group",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Attendance",
-					"onboard": 1,
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Attendance Request",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Upload Attendance",
-					"hide_count": True,
-					"dependencies": ["Employee"]
-				},
-								{
-					"type": "doctype",
-					"name": "Employee Checkin",
-					"hide_count": True,
-					"onboard": 1,
-					"dependencies": ["Employee"]
-				},
-			]
-		},
-		{
-			"label": _("Payroll"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Salary Structure",
-					"onboard": 1,
-				},
-				{
-					"type": "doctype",
-					"name": "Salary Structure Assignment",
-					"onboard": 1,
-					"dependencies": ["Salary Structure", "Employee"],
-				},
-				{
-					"type": "doctype",
-					"name": "Salary Slip",
-					"onboard": 1,
-				},
-				{
-					"type": "doctype",
-					"name": "Payroll Entry",
-					"onboard": 1,
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Benefit Application",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Benefit Claim",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Additional Salary",
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Tax Exemption Declaration",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Tax Exemption Proof Submission",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Incentive",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Retention Bonus",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Payroll Period",
-				},
-				{
-					"type": "doctype",
-					"name": "Salary Component",
-				},
-			]
-		},
-		{
-			"label": _("Settings"),
-			"icon": "fa fa-cog",
-			"items": [
-				{
-					"type": "doctype",
-					"name": "HR Settings",
-				},
-				{
-					"type": "doctype",
 					"name": "Employment Type",
 				},
 				{
@@ -147,19 +33,56 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Daily Work Summary Group"
+					"name": "Employee Group",
+					"dependencies": ["Employee"]
 				},
 				{
 					"type": "doctype",
 					"name": "Employee Health Insurance"
 				},
-				{
-					"type": "doctype",
-					"name": "Staffing Plan",
-				}
 			]
 		},
-
+		{
+			"label": _("Attendance"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Employee Attendance Tool",
+					"hide_count": True,
+					"onboard": 1,
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Attendance",
+					"onboard": 1,
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Attendance Request",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Upload Attendance",
+					"hide_count": True,
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Checkin",
+					"hide_count": True,
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "report",
+					"is_query_report": True,
+					"name": "Monthly Attendance Sheet",
+					"doctype": "Attendance"
+				},
+			]
+		},
 		{
 			"label": _("Leaves"),
 			"items": [
@@ -175,13 +98,8 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Compensatory Leave Request",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Leave Encashment",
-					"dependencies": ["Employee"]
+					"name": "Leave Policy",
+					"dependencies": ["Leave Type"]
 				},
 				{
 					"type": "doctype",
@@ -194,39 +112,169 @@
 				},
 				{
 					"type": "doctype",
-					"name": "Leave Policy",
-					"dependencies": ["Leave Type"]
+					"name": "Holiday List",
 				},
 				{
 					"type": "doctype",
-					"name": "Holiday List",
+					"name": "Compensatory Leave Request",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Leave Encashment",
+					"dependencies": ["Employee"]
 				},
 				{
 					"type": "doctype",
 					"name": "Leave Block List",
 				},
+				{
+					"type": "report",
+					"is_query_report": True,
+					"name": "Employee Leave Balance",
+					"doctype": "Leave Application"
+				},
 			]
 		},
 		{
-			"label": _("Recruitment and Training"),
+			"label": _("Payroll"),
 			"items": [
 				{
 					"type": "doctype",
-					"name": "Job Applicant",
+					"name": "Salary Structure",
 					"onboard": 1,
 				},
 				{
 					"type": "doctype",
+					"name": "Salary Structure Assignment",
+					"onboard": 1,
+					"dependencies": ["Salary Structure", "Employee"],
+				},
+				{
+					"type": "doctype",
+					"name": "Payroll Entry",
+					"onboard": 1,
+				},
+				{
+					"type": "doctype",
+					"name": "Salary Slip",
+					"onboard": 1,
+				},
+				{
+					"type": "doctype",
+					"name": "Salary Component",
+				},
+				{
+					"type": "doctype",
+					"name": "Additional Salary",
+				},
+				{
+					"type": "doctype",
+					"name": "Retention Bonus",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Incentive",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "report",
+					"is_query_report": True,
+					"name": "Salary Register",
+					"doctype": "Salary Slip"
+				},
+			]
+		},
+		{
+			"label": _("Employee Tax and Benefits"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Employee Tax Exemption Declaration",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Tax Exemption Proof Submission",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Benefit Application",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Benefit Claim",
+					"dependencies": ["Employee"]
+				},
+			]
+		},
+		{
+			"label": _("Employee Lifecycle"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Employee Onboarding",
+					"dependencies": ["Job Applicant"],
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Promotion",
+					"dependencies": ["Employee"],
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Transfer",
+					"dependencies": ["Employee"],
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Separation",
+					"dependencies": ["Employee"],
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Onboarding Template",
+					"dependencies": ["Employee"]
+				},
+				{
+					"type": "doctype",
+					"name": "Employee Separation Template",
+					"dependencies": ["Employee"]
+				},
+			]
+		},
+		{
+			"label": _("Recruitment"),
+			"items": [
+				{
+					"type": "doctype",
 					"name": "Job Opening",
 					"onboard": 1,
 				},
 				{
 					"type": "doctype",
+					"name": "Job Applicant",
+					"onboard": 1,
+				},
+				{
+					"type": "doctype",
 					"name": "Job Offer",
 					"onboard": 1,
 				},
 				{
 					"type": "doctype",
+					"name": "Staffing Plan",
+				},
+			]
+		},
+		{
+			"label": _("Training"),
+			"items": [
+				{
+					"type": "doctype",
 					"name": "Training Program"
 				},
 				{
@@ -244,42 +292,7 @@
 			]
 		},
 		{
-			"label": _("Employee Lifecycle"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Employee Transfer",
-					"dependencies": ["Employee"],
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Promotion",
-					"dependencies": ["Employee"],
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Separation",
-					"dependencies": ["Employee"],
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Onboarding",
-					"dependencies": ["Job Applicant"],
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Separation Template",
-					"dependencies": ["Employee"]
-				},
-				{
-					"type": "doctype",
-					"name": "Employee Onboarding Template",
-					"dependencies": ["Employee"]
-				}
-			]
-		},
-		{
-			"label": _("Appraisals, Expense Claims and Loans"),
+			"label": _("Performance"),
 			"items": [
 				{
 					"type": "doctype",
@@ -290,24 +303,39 @@
 					"name": "Appraisal Template",
 				},
 				{
-					"type": "page",
-					"name": "team-updates",
-					"label": _("Team Updates")
+					"type": "doctype",
+					"name": "Energy Point Rule",
 				},
 				{
 					"type": "doctype",
-					"name": "Employee Advance",
-					"dependencies": ["Employee"]
+					"name": "Energy Point Log",
 				},
 				{
+					"type": "link",
+					"doctype": "Energy Point Log",
+					"label": _("Energy Point Leaderboard"),
+					"route": "#social/users"
+				},
+			]
+		},
+		{
+			"label": _("Expense Claims"),
+			"items": [
+				{
 					"type": "doctype",
 					"name": "Expense Claim",
 					"dependencies": ["Employee"]
 				},
 				{
 					"type": "doctype",
-					"name": "Loan Type",
+					"name": "Employee Advance",
+					"dependencies": ["Employee"]
 				},
+			]
+		},
+		{
+			"label": _("Loans"),
+			"items": [
 				{
 					"type": "doctype",
 					"name": "Loan Application",
@@ -316,7 +344,66 @@
 				{
 					"type": "doctype",
 					"name": "Loan"
-				}
+				},
+				{
+					"type": "doctype",
+					"name": "Loan Type",
+				},
+			]
+		},
+		{
+			"label": _("Shift Management"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Shift Type",
+				},
+				{
+					"type": "doctype",
+					"name": "Shift Request",
+				},
+				{
+					"type": "doctype",
+					"name": "Shift Assignment",
+				},
+			]
+		},
+		{
+			"label": _("Fleet Management"),
+			"items": [
+				{
+					"type": "doctype",
+					"name": "Vehicle"
+				},
+				{
+					"type": "doctype",
+					"name": "Vehicle Log"
+				},
+				{
+					"type": "report",
+					"is_query_report": True,
+					"name": "Vehicle Expenses",
+					"doctype": "Vehicle"
+				},
+			]
+		},
+		{
+			"label": _("Settings"),
+			"icon": "fa fa-cog",
+			"items": [
+				{
+					"type": "doctype",
+					"name": "HR Settings",
+				},
+				{
+					"type": "doctype",
+					"name": "Daily Work Summary Group"
+				},
+				{
+					"type": "page",
+					"name": "team-updates",
+					"label": _("Team Updates")
+				},
 			]
 		},
 		{
@@ -326,12 +413,6 @@
 				{
 					"type": "report",
 					"is_query_report": True,
-					"name": "Employee Leave Balance",
-					"doctype": "Leave Application"
-				},
-				{
-					"type": "report",
-					"is_query_report": True,
 					"name": "Employee Birthday",
 					"doctype": "Employee"
 				},
@@ -343,79 +424,10 @@
 				},
 				{
 					"type": "report",
-					"name": "Employee Information",
-					"doctype": "Employee"
-				},
-				{
-					"type": "report",
-					"is_query_report": True,
-					"name": "Salary Register",
-					"doctype": "Salary Slip"
-				},
-				{
-					"type": "report",
-					"is_query_report": True,
-					"name": "Monthly Attendance Sheet",
-					"doctype": "Attendance"
-				},
-				{
-					"type": "report",
-					"is_query_report": True,
-					"name": "Vehicle Expenses",
-					"doctype": "Vehicle"
-				},
-				{
-					"type": "report",
 					"is_query_report": True,
 					"name": "Department Analytics",
 					"doctype": "Employee"
 				},
 			]
 		},
-		{
-			"label": _("Shifts and Fleet Management"),
-			"items": [
-				{
-					"type": "doctype",
-					"name": "Shift Type",
-				},
-				{
-					"type": "doctype",
-					"name": "Shift Request",
-				},
-				{
-					"type": "doctype",
-					"name": "Shift Assignment",
-				},
-				{
-					"type": "doctype",
-					"name": "Vehicle"
-				},
-				{
-					"type": "doctype",
-					"name": "Vehicle Log"
-				},
-			]
-		},
-		# {
-		# 	"label": _("Help"),
-		# 	"icon": "fa fa-facetime-video",
-		# 	"items": [
-		# 		{
-		# 			"type": "help",
-		# 			"label": _("Setting up Employees"),
-		# 			"youtube_id": "USfIUdZlUhw"
-		# 		},
-		# 		{
-		# 			"type": "help",
-		# 			"label": _("Leave Management"),
-		# 			"youtube_id": "fc0p_AXebc8"
-		# 		},
-		# 		{
-		# 			"type": "help",
-		# 			"label": _("Expense Claims"),
-		# 			"youtube_id": "5SZHJF--ZFY"
-		# 		}
-		# 	]
-		# },
 	]
diff --git a/erpnext/config/projects.py b/erpnext/config/projects.py
index 5a907ff..47700d1 100644
--- a/erpnext/config/projects.py
+++ b/erpnext/config/projects.py
@@ -88,17 +88,14 @@
 					"doctype": "Project",
 					"dependencies": ["Project"],
 				},
-			]
-		},
-		{
-			"label": _("Help"),
-			"icon": "fa fa-facetime-video",
-			"items": [
 				{
-					"type": "help",
-					"label": _("Managing Projects"),
-					"youtube_id": "egxIGwtoKI4"
+					"type": "report",
+					"is_query_report": True,
+					"name": "Project Billing Summary",
+					"doctype": "Project",
+					"dependencies": ["Project"],
 				},
 			]
 		},
+		
 	]
diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py
index f18aadb..844710d 100644
--- a/erpnext/config/selling.py
+++ b/erpnext/config/selling.py
@@ -318,41 +318,5 @@
 				}
 			]
 		},
-		{
-			"label": _("SMS"),
-			"icon": "fa fa-wrench",
-			"items": [
-				{
-					"type": "doctype",
-					"name": "SMS Center",
-					"description":_("Send mass SMS to your contacts"),
-				},
-				{
-					"type": "doctype",
-					"name": "SMS Log",
-					"description":_("Logs for maintaining sms delivery status"),
-				},
-
-			]
-		},
-		{
-			"label": _("Help"),
-			"items": [
-				{
-					"type": "help",
-					"label": _("Customer and Supplier"),
-					"youtube_id": "anoGi_RpQ20"
-				},
-				{
-					"type": "help",
-					"label": _("Sales Order to Payment"),
-					"youtube_id": "1eP90MWoDQM"
-				},
-				{
-					"type": "help",
-					"label": _("Point-of-Sale"),
-					"youtube_id": "4WkelWkbP_c"
-				},
-			]
-		},
+		
 	]
diff --git a/erpnext/config/stock.py b/erpnext/config/stock.py
index f5e48b3..7d66df2 100644
--- a/erpnext/config/stock.py
+++ b/erpnext/config/stock.py
@@ -329,45 +329,5 @@
 				}
 			]
 		},
-		{
-			"label": _("Help"),
-			"icon": "fa fa-facetime-video",
-			"items": [
-				{
-					"type": "help",
-					"label": _("Items and Pricing"),
-					"youtube_id": "qXaEwld4_Ps"
-				},
-				{
-					"type": "help",
-					"label": _("Item Variants"),
-					"youtube_id": "OGBETlCzU5o"
-				},
-				{
-					"type": "help",
-					"label": _("Opening Stock Balance"),
-					"youtube_id": "0yPgrtfeCTs"
-				},
-				{
-					"type": "help",
-					"label": _("Making Stock Entries"),
-					"youtube_id": "Njt107hlY3I"
-				},
-				{
-					"type": "help",
-					"label": _("Serialized Inventory"),
-					"youtube_id": "gvOVlEwFDAk"
-				},
-				{
-					"type": "help",
-					"label": _("Batch Inventory"),
-					"youtube_id": "J0QKl7ABPKM"
-				},
-				{
-					"type": "help",
-					"label": _("Managing Subcontracting"),
-					"youtube_id": "ThiMCC2DtKo"
-				},
-			]
-		}
+			
 	]
diff --git a/erpnext/config/support.py b/erpnext/config/support.py
index 36b4214..151c4f7 100644
--- a/erpnext/config/support.py
+++ b/erpnext/config/support.py
@@ -21,13 +21,7 @@
 					"type": "doctype",
 					"name": "Issue Priority",
 					"description": _("Issue Priority."),
-				},
-				{
-					"type": "doctype",
-					"name": "Communication",
-					"description": _("Communication log."),
-					"onboard": 1,
-				},
+				}
 			]
 		},
 		{
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index f5ecaeb..47f56cb 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -475,21 +475,20 @@
 			order_doctype = "Purchase Order"
 
 		order_list = list(set([d.get(order_field)
-							   for d in self.get("items") if d.get(order_field)]))
+			for d in self.get("items") if d.get(order_field)]))
 
 		journal_entries = get_advance_journal_entries(party_type, party, party_account,
-													  amount_field, order_doctype, order_list, include_unallocated)
+			amount_field, order_doctype, order_list, include_unallocated)
 
 		payment_entries = get_advance_payment_entries(party_type, party, party_account,
-													  order_doctype, order_list, include_unallocated)
+			order_doctype, order_list, include_unallocated)
 
 		res = journal_entries + payment_entries
 
 		return res
 
 	def is_inclusive_tax(self):
-		is_inclusive = cint(frappe.db.get_single_value("Accounts Settings",
-													   "show_inclusive_tax_in_print"))
+		is_inclusive = cint(frappe.db.get_single_value("Accounts Settings", "show_inclusive_tax_in_print"))
 
 		if is_inclusive:
 			is_inclusive = 0
@@ -501,7 +500,7 @@
 	def validate_advance_entries(self):
 		order_field = "sales_order" if self.doctype == "Sales Invoice" else "purchase_order"
 		order_list = list(set([d.get(order_field)
-							   for d in self.get("items") if d.get(order_field)]))
+			for d in self.get("items") if d.get(order_field)]))
 
 		if not order_list: return
 
@@ -513,7 +512,7 @@
 				if not advance_entries_against_si or d.reference_name not in advance_entries_against_si:
 					frappe.msgprint(_(
 						"Payment Entry {0} is linked against Order {1}, check if it should be pulled as advance in this invoice.")
-									.format(d.reference_name, d.against_order))
+							.format(d.reference_name, d.against_order))
 
 	def update_against_document_in_jv(self):
 		"""
@@ -551,9 +550,9 @@
 					'unadjusted_amount': flt(d.advance_amount),
 					'allocated_amount': flt(d.allocated_amount),
 					'exchange_rate': (self.conversion_rate
-									  if self.party_account_currency != self.company_currency else 1),
+						if self.party_account_currency != self.company_currency else 1),
 					'grand_total': (self.base_grand_total
-									if self.party_account_currency == self.company_currency else self.grand_total),
+						if self.party_account_currency == self.company_currency else self.grand_total),
 					'outstanding_amount': self.outstanding_amount
 				})
 				lst.append(args)
@@ -576,36 +575,37 @@
 				unlink_ref_doc_from_payment_entries(self)
 
 	def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
-		from erpnext.controllers.status_updater import get_tolerance_for
-		item_tolerance = {}
-		global_tolerance = None
+		from erpnext.controllers.status_updater import get_allowance_for
+		item_allowance = {}
+		global_qty_allowance, global_amount_allowance = None, None
 
 		for item in self.get("items"):
 			if item.get(item_ref_dn):
 				ref_amt = flt(frappe.db.get_value(ref_dt + " Item",
-												  item.get(item_ref_dn), based_on), self.precision(based_on, item))
+					item.get(item_ref_dn), based_on), self.precision(based_on, item))
 				if not ref_amt:
 					frappe.msgprint(
-						_("Warning: System will not check overbilling since amount for Item {0} in {1} is zero").format(
-							item.item_code, ref_dt))
+						_("Warning: System will not check overbilling since amount for Item {0} in {1} is zero")
+							.format(item.item_code, ref_dt))
 				else:
-					already_billed = frappe.db.sql("""select sum(%s) from `tab%s`
-						where %s=%s and docstatus=1 and parent != %s""" %
-												   (based_on, self.doctype + " Item", item_ref_dn, '%s', '%s'),
-												   (item.get(item_ref_dn), self.name))[0][0]
+					already_billed = frappe.db.sql("""
+						select sum(%s)
+						from `tab%s`
+						where %s=%s and docstatus=1 and parent != %s
+					""" % (based_on, self.doctype + " Item", item_ref_dn, '%s', '%s'),
+					   (item.get(item_ref_dn), self.name))[0][0]
 
 					total_billed_amt = flt(flt(already_billed) + flt(item.get(based_on)),
-										   self.precision(based_on, item))
+						self.precision(based_on, item))
 
-					tolerance, item_tolerance, global_tolerance = get_tolerance_for(item.item_code,
-																					item_tolerance, global_tolerance)
+					allowance, item_allowance, global_qty_allowance, global_amount_allowance = \
+						get_allowance_for(item.item_code, item_allowance, global_qty_allowance, global_amount_allowance, "amount")
 
-					max_allowed_amt = flt(ref_amt * (100 + tolerance) / 100)
+					max_allowed_amt = flt(ref_amt * (100 + allowance) / 100)
 
 					if total_billed_amt - max_allowed_amt > 0.01:
-						frappe.throw(_(
-							"Cannot overbill for Item {0} in row {1} more than {2}. To allow over-billing, please set in Stock Settings").format(
-							item.item_code, item.idx, max_allowed_amt))
+						frappe.throw(_("Cannot overbill for Item {0} in row {1} more than {2}. To allow over-billing, please set in Stock Settings")
+							.format(item.item_code, item.idx, max_allowed_amt))
 
 	def get_company_default(self, fieldname):
 		from erpnext.accounts.utils import get_company_default
@@ -615,9 +615,10 @@
 		stock_items = []
 		item_codes = list(set(item.item_code for item in self.get("items")))
 		if item_codes:
-			stock_items = [r[0] for r in frappe.db.sql("""select name
-				from `tabItem` where name in (%s) and is_stock_item=1""" % \
-													   (", ".join((["%s"] * len(item_codes))),), item_codes)]
+			stock_items = [r[0] for r in frappe.db.sql("""
+				select name from `tabItem`
+				where name in (%s) and is_stock_item=1
+			""" % (", ".join((["%s"] * len(item_codes))),), item_codes)]
 
 		return stock_items
 
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index b193ac2..2da0f03 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -7,6 +7,8 @@
 from frappe import _
 from frappe.model.document import Document
 
+class OverAllowanceError(frappe.ValidationError): pass
+
 def validate_status(status, options):
 	if status not in options:
 		frappe.throw(_("Status must be one of {0}").format(comma_or(options)))
@@ -43,16 +45,6 @@
 		["Closed", "eval:self.status=='Closed'"],
 		["On Hold", "eval:self.status=='On Hold'"],
 	],
-	"Sales Invoice": [
-		["Draft", None],
-		["Submitted", "eval:self.docstatus==1"],
-		["Paid", "eval:self.outstanding_amount==0 and self.docstatus==1"],
-		["Return", "eval:self.is_return==1 and self.docstatus==1"],
-		["Credit Note Issued", "eval:self.outstanding_amount < 0 and self.docstatus==1"],
-		["Unpaid", "eval:self.outstanding_amount > 0 and getdate(self.due_date) >= getdate(nowdate()) and self.docstatus==1"],
-		["Overdue", "eval:self.outstanding_amount > 0 and getdate(self.due_date) < getdate(nowdate()) and self.docstatus==1"],
-		["Cancelled", "eval:self.docstatus==2"],
-	],
 	"Purchase Invoice": [
 		["Draft", None],
 		["Submitted", "eval:self.docstatus==1"],
@@ -154,8 +146,9 @@
 
 	def validate_qty(self):
 		"""Validates qty at row level"""
-		self.tolerance = {}
-		self.global_tolerance = None
+		self.item_allowance = {}
+		self.global_qty_allowance = None
+		self.global_amount_allowance = None
 
 		for args in self.status_updater:
 			if "target_ref_field" not in args:
@@ -186,32 +179,41 @@
 
 						# if not item[args['target_ref_field']]:
 						# 	msgprint(_("Note: System will not check over-delivery and over-booking for Item {0} as quantity or amount is 0").format(item.item_code))
-						if args.get('no_tolerance'):
+						if args.get('no_allowance'):
 							item['reduce_by'] = item[args['target_field']] - item[args['target_ref_field']]
 							if item['reduce_by'] > .01:
 								self.limits_crossed_error(args, item)
 
 						elif item[args['target_ref_field']]:
-							self.check_overflow_with_tolerance(item, args)
+							self.check_overflow_with_allowance(item, args)
 
-	def check_overflow_with_tolerance(self, item, args):
+	def check_overflow_with_allowance(self, item, args):
 		"""
-			Checks if there is overflow condering a relaxation tolerance
+			Checks if there is overflow condering a relaxation allowance
 		"""
-		# check if overflow is within tolerance
-		tolerance, self.tolerance, self.global_tolerance = get_tolerance_for(item['item_code'],
-			self.tolerance, self.global_tolerance)
+		qty_or_amount = "qty" if "qty" in args['target_ref_field'] else "amount"
+
+		# check if overflow is within allowance
+		allowance, self.item_allowance, self.global_qty_allowance, self.global_amount_allowance = \
+			get_allowance_for(item['item_code'], self.item_allowance,
+				self.global_qty_allowance, self.global_amount_allowance, qty_or_amount)
+
 		overflow_percent = ((item[args['target_field']] - item[args['target_ref_field']]) /
 		 	item[args['target_ref_field']]) * 100
 
-		if overflow_percent - tolerance > 0.01:
-			item['max_allowed'] = flt(item[args['target_ref_field']] * (100+tolerance)/100)
+		if overflow_percent - allowance > 0.01:
+			item['max_allowed'] = flt(item[args['target_ref_field']] * (100+allowance)/100)
 			item['reduce_by'] = item[args['target_field']] - item['max_allowed']
 
-			self.limits_crossed_error(args, item)
+			self.limits_crossed_error(args, item, qty_or_amount)
 
-	def limits_crossed_error(self, args, item):
+	def limits_crossed_error(self, args, item, qty_or_amount):
 		'''Raise exception for limits crossed'''
+		if qty_or_amount == "qty":
+			action_msg = _('To allow over receipt / delivery, update "Over Receipt/Delivery Allowance" in Stock Settings or the Item.')
+		else:
+			action_msg = _('To allow over billing, update "Over Billing Allowance" in Accounts Settings or the Item.')
+
 		frappe.throw(_('This document is over limit by {0} {1} for item {4}. Are you making another {3} against the same {2}?')
 			.format(
 				frappe.bold(_(item["target_ref_field"].title())),
@@ -219,9 +221,7 @@
 				frappe.bold(_(args.get('target_dt'))),
 				frappe.bold(_(self.doctype)),
 				frappe.bold(item.get('item_code'))
-			) + '<br><br>' +
-				_('To allow over-billing or over-ordering, update "Allowance" in Stock Settings or the Item.'),
-			title = _('Limit Crossed'))
+			) + '<br><br>' + action_msg, OverAllowanceError, title = _('Limit Crossed'))
 
 	def update_qty(self, update_modified=True):
 		"""Updates qty or amount at row level
@@ -358,19 +358,34 @@
 			ref_doc.db_set("per_billed", per_billed)
 			ref_doc.set_status(update=True)
 
-def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None):
+def get_allowance_for(item_code, item_allowance={}, global_qty_allowance=None, global_amount_allowance=None, qty_or_amount="qty"):
 	"""
-		Returns the tolerance for the item, if not set, returns global tolerance
+		Returns the allowance for the item, if not set, returns global allowance
 	"""
-	if item_tolerance.get(item_code):
-		return item_tolerance[item_code], item_tolerance, global_tolerance
+	if qty_or_amount == "qty":
+		if item_allowance.get(item_code, frappe._dict()).get("qty"):
+			return item_allowance[item_code].qty, item_allowance, global_qty_allowance, global_amount_allowance
+	else:
+		if item_allowance.get(item_code, frappe._dict()).get("amount"):
+			return item_allowance[item_code].amount, item_allowance, global_qty_allowance, global_amount_allowance
 
-	tolerance = flt(frappe.db.get_value('Item',item_code,'tolerance') or 0)
+	qty_allowance, over_billing_allowance = \
+		frappe.db.get_value('Item', item_code, ['over_delivery_receipt_allowance', 'over_billing_allowance'])
 
-	if not tolerance:
-		if global_tolerance == None:
-			global_tolerance = flt(frappe.db.get_value('Stock Settings', None, 'tolerance'))
-		tolerance = global_tolerance
+	if qty_or_amount == "qty" and not qty_allowance:
+		if global_qty_allowance == None:
+			global_qty_allowance = flt(frappe.db.get_single_value('Stock Settings', 'over_delivery_receipt_allowance'))
+		qty_allowance = global_qty_allowance
+	elif qty_or_amount == "amount" and not over_billing_allowance:
+		if global_amount_allowance == None:
+			global_amount_allowance = flt(frappe.db.get_single_value('Accounts Settings', 'over_billing_allowance'))
+		over_billing_allowance = global_amount_allowance
 
-	item_tolerance[item_code] = tolerance
-	return tolerance, item_tolerance, global_tolerance
+	if qty_or_amount == "qty":
+		allowance = qty_allowance
+		item_allowance.setdefault(item_code, frappe._dict()).setdefault("qty", qty_allowance)
+	else:
+		allowance = over_billing_allowance
+		item_allowance.setdefault(item_code, frappe._dict()).setdefault("amount", over_billing_allowance)
+
+	return allowance, item_allowance, global_qty_allowance, global_amount_allowance
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index ebbe3d9..8e1510a 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -15,6 +15,9 @@
 		self.calculate()
 
 	def calculate(self):
+		if not len(self.doc.get("items")):
+			return
+
 		self.discount_amount_applied = False
 		self._calculate()
 
diff --git a/erpnext/crm/doctype/opportunity/opportunity.js b/erpnext/crm/doctype/opportunity/opportunity.js
index 9dcd0c4..90a12b7 100644
--- a/erpnext/crm/doctype/opportunity/opportunity.js
+++ b/erpnext/crm/doctype/opportunity/opportunity.js
@@ -19,6 +19,10 @@
 				}
 			}
 		});
+
+		if (frm.doc.opportunity_from && frm.doc.party_name){
+			frm.trigger('set_contact_link');
+		}
 	},
 
 	onload_post_render: function(frm) {
diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js
index 1692814..1a34fe8 100644
--- a/erpnext/healthcare/doctype/patient/patient.js
+++ b/erpnext/healthcare/doctype/patient/patient.js
@@ -21,9 +21,9 @@
 			});
 		}
 		if (frm.doc.patient_name && frappe.user.has_role("Physician")) {
-			frm.add_custom_button(__('Medical Record'), function () {
+			frm.add_custom_button(__('Patient History'), function () {
 				frappe.route_options = { "patient": frm.doc.name };
-				frappe.set_route("medical_record");
+				frappe.set_route("patient_history");
 			},"View");
 		}
 		if (!frm.doc.__islocal && (frappe.user.has_role("Nursing User") || frappe.user.has_role("Physician"))) {
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
index b3cbd1f..858145e 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
@@ -30,9 +30,9 @@
 			};
 		});
 		if(frm.doc.patient){
-			frm.add_custom_button(__('Medical Record'), function() {
+			frm.add_custom_button(__('Patient History'), function() {
 				frappe.route_options = {"patient": frm.doc.patient};
-				frappe.set_route("medical_record");
+				frappe.set_route("patient_history");
 			},__("View"));
 		}
 		if(frm.doc.status == "Open"){
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
index 7ea4568..088bc81 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
@@ -41,10 +41,10 @@
 				}
 			});
 		}
-		frm.add_custom_button(__('Medical Record'), function() {
+		frm.add_custom_button(__('Patient History'), function() {
 			if (frm.doc.patient) {
 				frappe.route_options = {"patient": frm.doc.patient};
-				frappe.set_route("medical_record");
+				frappe.set_route("patient_history");
 			} else {
 				frappe.msgprint(__("Please select Patient"));
 			}
diff --git a/erpnext/healthcare/page/medical_record/__init__.py b/erpnext/healthcare/page/medical_record/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/erpnext/healthcare/page/medical_record/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/healthcare/page/medical_record/medical_record.js b/erpnext/healthcare/page/medical_record/medical_record.js
deleted file mode 100644
index df19d8f..0000000
--- a/erpnext/healthcare/page/medical_record/medical_record.js
+++ /dev/null
@@ -1,182 +0,0 @@
-frappe.provide("frappe.medical_record");
-frappe.pages['medical_record'].on_page_load = function(wrapper) {
-	var me = this;
-	var page = frappe.ui.make_app_page({
-		parent: wrapper,
-		title: 'Medical Record',
-	});
-
-	frappe.breadcrumbs.add("Medical");
-
-	page.main.html(frappe.render_template("patient_select", {}));
-	var patient = frappe.ui.form.make_control({
-		parent: page.main.find(".patient"),
-		df: {
-			fieldtype: "Link",
-			options: "Patient",
-			fieldname: "patient",
-			change: function(){
-				page.main.find(".frappe-list").html("");
-				draw_page(patient.get_value(), me);
-			}
-		},
-		only_input: true,
-	});
-	patient.refresh();
-
-
-	this.page.main.on("click", ".medical_record-message", function() {
-		var	doctype = $(this).attr("data-doctype"),
-			docname = $(this).attr("data-docname");
-
-		if (doctype && docname) {
-			frappe.route_options = {
-				scroll_to: { "doctype": doctype, "name": docname }
-			};
-			frappe.set_route(["Form", doctype, docname]);
-		}
-	});
-
-	this.page.sidebar.on("click", ".edit-details", function() {
-		patient = patient.get_value();
-		if (patient) {
-			frappe.set_route(["Form", "Patient", patient]);
-		}
-	});
-
-};
-
-frappe.pages['medical_record'].refresh = function() {
-	var me = this;
-
-	if(frappe.route_options) {
-		if(frappe.route_options.patient){
-			me.page.main.find(".frappe-list").html("");
-			var patient = frappe.route_options.patient;
-			draw_page(patient,me);
-			me.page.main.find("[data-fieldname='patient']").val(patient);
-			frappe.route_options = null;
-		}
-	}
-};
-var show_patient_info = function(patient, me){
-	frappe.call({
-		"method": "erpnext.healthcare.doctype.patient.patient.get_patient_detail",
-		args: {
-			patient: patient
-		},
-		callback: function (r) {
-			var data = r.message;
-			var details = "";
-			if(data.email) details += "<br><b>Email :</b> " + data.email;
-			if(data.mobile) details += "<br><b>Mobile :</b> " + data.mobile;
-			if(data.occupation) details += "<br><b>Occupation :</b> " + data.occupation;
-			if(data.blood_group) details += "<br><b>Blood group : </b> " + data.blood_group;
-			if(data.allergies) details +=  "<br><br><b>Allergies : </b> "+  data.allergies;
-			if(data.medication) details +=  "<br><b>Medication : </b> "+  data.medication;
-			if(data.alcohol_current_use) details +=  "<br><br><b>Alcohol use : </b> "+  data.alcohol_current_use;
-			if(data.alcohol_past_use) details +=  "<br><b>Alcohol past use : </b> "+  data.alcohol_past_use;
-			if(data.tobacco_current_use) details +=  "<br><b>Tobacco use : </b> "+  data.tobacco_current_use;
-			if(data.tobacco_past_use) details +=  "<br><b>Tobacco past use : </b> "+  data.tobacco_past_use;
-			if(data.medical_history) details +=  "<br><br><b>Medical history : </b> "+  data.medical_history;
-			if(data.surgical_history) details +=  "<br><b>Surgical history : </b> "+  data.surgical_history;
-			if(data.surrounding_factors) details +=  "<br><br><b>Occupational hazards : </b> "+  data.surrounding_factors;
-			if(data.other_risk_factors) details += "<br><b>Other risk factors : </b> " + data.other_risk_factors;
-			if(data.patient_details) details += "<br><br><b>More info : </b> " + data.patient_details;
-
-			if(details){
-				details = "<div style='padding-left:10px; font-size:13px;' align='center'></br><b class='text-muted'>Patient Details</b>" + details + "</div>";
-			}
-
-			var vitals = "";
-			if(data.temperature) vitals += "<br><b>Temperature :</b> " + data.temperature;
-			if(data.pulse) vitals += "<br><b>Pulse :</b> " + data.pulse;
-			if(data.respiratory_rate) vitals += "<br><b>Respiratory Rate :</b> " + data.respiratory_rate;
-			if(data.bp) vitals += "<br><b>BP :</b> " + data.bp;
-			if(data.bmi) vitals += "<br><b>BMI :</b> " + data.bmi;
-			if(data.height) vitals += "<br><b>Height :</b> " + data.height;
-			if(data.weight) vitals += "<br><b>Weight :</b> " + data.weight;
-			if(data.signs_date) vitals += "<br><b>Date :</b> " + data.signs_date;
-
-			if(vitals){
-				vitals = "<div style='padding-left:10px; font-size:13px;' align='center'></br><b class='text-muted'>Vital Signs</b>" + vitals + "<br></div>";
-				details = vitals + details;
-			}
-			if(details) details += "<div align='center'><br><a class='btn btn-default btn-sm edit-details'>Edit Details</a></b> </div>";
-
-			me.page.sidebar.addClass("col-sm-3");
-			me.page.sidebar.html(details);
-			me.page.wrapper.find(".layout-main-section-wrapper").addClass("col-sm-9");
-		}
-	});
-};
-var draw_page = function(patient, me){
-	frappe.model.with_doctype("Patient Medical Record", function() {
-		me.page.list = new frappe.ui.BaseList({
-			hide_refresh: true,
-			page: me.page,
-			method: 'erpnext.healthcare.page.medical_record.medical_record.get_feed',
-			args: {name: patient},
-			parent: $("<div></div>").appendTo(me.page.main),
-			render_view: function(values) {
-				var me = this;
-				var wrapper = me.page.main.find(".result-list").get(0);
-				values.map(function (value) {
-					var row = $('<div class="list-row">').data("data", value).appendTo($(wrapper)).get(0);
-					new frappe.medical_record.Feed(row, value);
-				});
-			},
-			show_filters: true,
-			doctype: "Patient Medical Record",
-		});
-		show_patient_info(patient, me);
-		me.page.list.run();
-	});
-};
-
-frappe.medical_record.last_feed_date = false;
-frappe.medical_record.Feed = Class.extend({
-	init: function(row, data) {
-		this.scrub_data(data);
-		this.add_date_separator(row, data);
-		if(!data.add_class)
-			data.add_class = "label-default";
-
-		data.link = "";
-		if (data.reference_doctype && data.reference_name) {
-			data.link = frappe.format(data.reference_name, {fieldtype: "Link", options: data.reference_doctype},
-				{label: __(data.reference_doctype)});
-		}
-
-		$(row)
-			.append(frappe.render_template("medical_record_row", data))
-			.find("a").addClass("grey");
-	},
-	scrub_data: function(data) {
-		data.by = frappe.user.full_name(data.owner);
-		data.imgsrc = frappe.utils.get_file_link(frappe.user_info(data.owner).image);
-
-		data.icon = "icon-flag";
-	},
-	add_date_separator: function(row, data) {
-		var date = frappe.datetime.str_to_obj(data.creation);
-		var last = frappe.medical_record.last_feed_date;
-
-		if((last && frappe.datetime.obj_to_str(last) != frappe.datetime.obj_to_str(date)) || (!last)) {
-			var diff = frappe.datetime.get_day_diff(frappe.datetime.get_today(), frappe.datetime.obj_to_str(date));
-			if(diff < 1) {
-				var pdate = 'Today';
-			} else if(diff < 2) {
-				pdate = 'Yesterday';
-			} else {
-				pdate = frappe.datetime.global_date_format(date);
-			}
-			data.date_sep = pdate;
-			data.date_class = pdate=='Today' ? "date-indicator blue" : "date-indicator";
-		} else {
-			data.date_sep = null;
-			data.date_class = "";
-		}
-		frappe.medical_record.last_feed_date = date;
-	}
-});
diff --git a/erpnext/healthcare/page/medical_record/medical_record.json b/erpnext/healthcare/page/medical_record/medical_record.json
deleted file mode 100644
index ca30c3b..0000000
--- a/erpnext/healthcare/page/medical_record/medical_record.json
+++ /dev/null
@@ -1,25 +0,0 @@
-{
- "content": null, 
- "creation": "2016-06-09 11:33:14.025787", 
- "docstatus": 0, 
- "doctype": "Page", 
- "icon": "icon-play", 
- "idx": 0, 
- "modified": "2018-08-06 11:40:39.705660", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "medical_record", 
- "owner": "Administrator", 
- "page_name": "medical_record", 
- "restrict_to_domain": "Healthcare", 
- "roles": [
-  {
-   "role": "Physician"
-  }
- ], 
- "script": null, 
- "standard": "Yes", 
- "style": null, 
- "system_page": 0, 
- "title": "Medical Record"
-}
\ No newline at end of file
diff --git a/erpnext/healthcare/page/medical_record/medical_record.py b/erpnext/healthcare/page/medical_record/medical_record.py
deleted file mode 100644
index 22c5852..0000000
--- a/erpnext/healthcare/page/medical_record/medical_record.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015, ESS LLP and contributors
-# For license information, please see license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.utils import cint
-
-@frappe.whitelist()
-def get_feed(start, page_length, name):
-	"""get feed"""
-	result = frappe.db.sql("""select name, owner, modified, creation,
-			reference_doctype, reference_name, subject
-		from `tabPatient Medical Record`
-		where patient=%(patient)s
-		order by creation desc
-		limit %(start)s, %(page_length)s""",
-		{
-			"start": cint(start),
-			"page_length": cint(page_length),
-			"patient": name
-		}, as_dict=True)
-
-	return result
diff --git a/erpnext/healthcare/page/medical_record/medical_record_row.html b/erpnext/healthcare/page/medical_record/medical_record_row.html
deleted file mode 100644
index 9a670c9..0000000
--- a/erpnext/healthcare/page/medical_record/medical_record_row.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<div class="row medical_record-row" data-creation="{%= creation.split(" ")[0] + " 00:00:00" %}">
-	<div class="col-xs-3 text-right medical_record-date"><span class="{%= date_class %}">
-		{%= date_sep || "" %}</span>
-	</div>
-	<div class="col-xs-9 medical_record-message"
-		data-doctype="{%= reference_doctype %}"
-		data-docname="{%= reference_name %}"
-		title="{%= by %} / {%= frappe.datetime.str_to_user(creation) %}">
-		<span class="avatar avatar-small">
-			<div class="avatar-frame" style="background-image: url({{ imgsrc }});"></div>
-			<!-- <img src="{%= imgsrc %}"> -->
-		</span>
-		<span class="small">
-		{% if (reference_doctype && reference_name) { %}
-			{%= __("{0}: {1}", [link, "<strong>" + subject + "</strong>"]) %}
-		{% } else { %}
-			{%= subject %}
-		{% } %}
-	</span>
-	</div>
-</div>
diff --git a/erpnext/healthcare/page/medical_record/patient_select.html b/erpnext/healthcare/page/medical_record/patient_select.html
deleted file mode 100644
index 321baf7..0000000
--- a/erpnext/healthcare/page/medical_record/patient_select.html
+++ /dev/null
@@ -1,5 +0,0 @@
-<div class="text-center col-sm-9" style="padding: 40px;">
-
-    	<p>{%= __("Select Patient") %}</p>
-	<p class="patient" style="margin: auto; max-width: 300px; margin-bottom: 20px;"></p>
-</div>
diff --git a/erpnext/healthcare/page/patient_history/__init__.py b/erpnext/healthcare/page/patient_history/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/healthcare/page/patient_history/__init__.py
diff --git a/erpnext/healthcare/page/medical_record/medical_record.css b/erpnext/healthcare/page/patient_history/patient_history.css
similarity index 62%
rename from erpnext/healthcare/page/medical_record/medical_record.css
rename to erpnext/healthcare/page/patient_history/patient_history.css
index 977625b..865d6ab 100644
--- a/erpnext/healthcare/page/medical_record/medical_record.css
+++ b/erpnext/healthcare/page/patient_history/patient_history.css
@@ -14,6 +14,10 @@
 	margin-bottom: -4px;
 }
 
+.medical_record-row > * {
+	z-index: -999;
+}
+
 .date-indicator {
     background:none;
     font-size:12px;
@@ -35,6 +39,61 @@
 	color: #5e64ff;
 }
 
+.div-bg-color {
+	background: #fafbfc;
+}
+
+.bg-color-white {
+	background: #FFFFFF;
+}
+
+.d-flex {
+	display: flex;
+}
+
+.width-full {
+	width: 100%;
+}
+
+.p-3 {
+	padding: 16px;
+}
+
+.mt-2 {
+	margin-top: 8px;
+}
+
+.mr-3 {
+	margin-right: 16px;
+}
+
+.Box {
+	background-color: #fff;
+	border: 1px solid #d1d5da;
+	border-radius: 3px;
+}
+
+.flex-column {
+	flex-direction: column;
+}
+
+.avatar {
+	display: inline-block;
+	overflow: hidden;
+	line-height: 1;
+	vertical-align: middle;
+	border-radius: 3px;
+}
+
+.py-3 {
+	padding-top: 16px;
+	padding-bottom: 16px;
+}
+
+.border-bottom {
+	border-bottom: 1px #e1e4e8 solid;
+}
+
 .date-indicator.blue::after {
 	background: #5e64ff;
 }
@@ -65,8 +124,3 @@
 #page-medical_record .list-filters {
 	display: none ;
 }
-
-#page-medical_record .octicon-heart {
-	color: #ff5858;
-	margin: 0px 5px;
-}
diff --git a/erpnext/healthcare/page/patient_history/patient_history.html b/erpnext/healthcare/page/patient_history/patient_history.html
new file mode 100644
index 0000000..7a9446d
--- /dev/null
+++ b/erpnext/healthcare/page/patient_history/patient_history.html
@@ -0,0 +1,20 @@
+<div class="col-sm-12">
+	<div class="col-sm-3">
+	<p class="text-center">{%= __("Select Patient") %}</p>
+	<p class="patient" style="margin: auto; max-width: 300px; margin-bottom: 20px;"></p>
+	<div class="patient_details" style="z-index=0"></div>
+	</div>
+	<div class="col-sm-9 patient_documents">
+		<div class="col-sm-12">
+			<div class="col-sm-12 show_chart_btns" align="center">
+			</div>
+			<div id="chart" class="col-sm-12 patient_vital_charts">
+			</div>
+		</div>
+		<div class="col-sm-12 patient_documents_list">
+		</div>
+		<div class="col-sm-12 text-center py-3">
+			<a class="btn btn-sm btn-default btn-get-records" style="display:none">More..</a>
+		</div>
+	</div>
+</div>
\ No newline at end of file
diff --git a/erpnext/healthcare/page/patient_history/patient_history.js b/erpnext/healthcare/page/patient_history/patient_history.js
new file mode 100644
index 0000000..87fe7ed
--- /dev/null
+++ b/erpnext/healthcare/page/patient_history/patient_history.js
@@ -0,0 +1,300 @@
+frappe.provide("frappe.patient_history");
+frappe.pages['patient_history'].on_page_load = function(wrapper) {
+	var me = this;
+	var page = frappe.ui.make_app_page({
+		parent: wrapper,
+		title: 'Patient History',
+		single_column: true
+	});
+
+	frappe.breadcrumbs.add("Healthcare");
+	let pid = '';
+	page.main.html(frappe.render_template("patient_history", {}));
+	var patient = frappe.ui.form.make_control({
+		parent: page.main.find(".patient"),
+		df: {
+			fieldtype: "Link",
+			options: "Patient",
+			fieldname: "patient",
+			change: function(){
+				if(pid != patient.get_value() && patient.get_value()){
+					me.start = 0;
+					me.page.main.find(".patient_documents_list").html("");
+					get_documents(patient.get_value(), me);
+					show_patient_info(patient.get_value(), me);
+					show_patient_vital_charts(patient.get_value(), me, "bp", "mmHg", "Blood Pressure");
+				}
+				pid = patient.get_value();
+			}
+		},
+		only_input: true,
+	});
+	patient.refresh();
+
+	if (frappe.route_options){
+		patient.set_value(frappe.route_options.patient);
+	}
+
+	this.page.main.on("click", ".btn-show-chart", function() {
+		var	btn_show_id = $(this).attr("data-show-chart-id"), pts = $(this).attr("data-pts");
+		var title = $(this).attr("data-title");
+		show_patient_vital_charts(patient.get_value(), me, btn_show_id, pts, title);
+	});
+
+	this.page.main.on("click", ".btn-more", function() {
+		var	doctype = $(this).attr("data-doctype"), docname = $(this).attr("data-docname");
+		if(me.page.main.find("."+docname).parent().find('.document-html').attr('data-fetched') == "1"){
+			me.page.main.find("."+docname).hide();
+			me.page.main.find("."+docname).parent().find('.document-html').show();
+		}else{
+			if(doctype && docname){
+				let exclude = ["patient", "patient_name", 'patient_sex', "encounter_date"];
+				frappe.call({
+					method: "erpnext.healthcare.utils.render_doc_as_html",
+					args:{
+						doctype: doctype,
+						docname: docname,
+						exclude_fields: exclude
+					},
+					callback: function(r) {
+						if (r.message){
+							me.page.main.find("."+docname).hide();
+							me.page.main.find("."+docname).parent().find('.document-html').html(r.message.html+"\
+							<div align='center'><a class='btn octicon octicon-chevron-up btn-default btn-xs\
+							btn-less' data-doctype='"+doctype+"' data-docname='"+docname+"'></a></div>");
+							me.page.main.find("."+docname).parent().find('.document-html').show();
+							me.page.main.find("."+docname).parent().find('.document-html').attr('data-fetched', "1");
+						}
+					},
+					freeze: true
+				});
+			}
+		}
+	});
+
+	this.page.main.on("click", ".btn-less", function() {
+		var docname = $(this).attr("data-docname");
+		me.page.main.find("."+docname).parent().find('.document-id').show();
+		me.page.main.find("."+docname).parent().find('.document-html').hide();
+	});
+	me.start = 0;
+	me.page.main.on("click", ".btn-get-records", function(){
+		get_documents(patient.get_value(), me);
+	});
+};
+
+var get_documents = function(patient, me){
+	frappe.call({
+		"method": "erpnext.healthcare.page.patient_history.patient_history.get_feed",
+		args: {
+			name: patient,
+			start: me.start,
+			page_length: 20
+		},
+		callback: function (r) {
+			var data = r.message;
+			if(data.length){
+				add_to_records(me, data);
+			}else{
+				me.page.main.find(".patient_documents_list").append("<div class='text-muted' align='center'><br><br>No more records..<br><br></div>");
+				me.page.main.find(".btn-get-records").hide();
+			}
+		}
+	});
+};
+
+var add_to_records = function(me, data){
+	var details = "<ul class='nav nav-pills nav-stacked'>";
+	var i;
+	for(i=0; i<data.length; i++){
+		if(data[i].reference_doctype){
+			let label = '';
+			if(data[i].subject){
+				label += "<br/>"+data[i].subject;
+			}
+			data[i] = add_date_separator(data[i]);
+			if(frappe.user_info(data[i].owner).image){
+				data[i].imgsrc = frappe.utils.get_file_link(frappe.user_info(data[i].owner).image);
+			}
+			else{
+				data[i].imgsrc = false;
+			}
+			var time_line_heading = data[i].practitioner ? `${data[i].practitioner} ` : ``;
+			time_line_heading += data[i].reference_doctype + " - "+ data[i].reference_name;
+			details += `<li data-toggle='pill' class='patient_doc_menu'
+			data-doctype='${data[i].reference_doctype}' data-docname='${data[i].reference_name}'>
+			<div class='col-sm-12 d-flex border-bottom py-3'>`;
+			if (data[i].imgsrc){
+				details += `<span class='mr-3'>
+					<img class='avtar' src='${data[i].imgsrc}' width='32' height='32'>
+					</img>
+			</span>`;
+			}else{
+				details += `<span class='mr-3 avatar avatar-small' style='width:32px; height:32px;'><div align='center' class='standard-image'
+					style='background-color: #fafbfc;'>${data[i].practitioner ? data[i].practitioner.charAt(0) : "U"}</div></span>`;
+			}
+			details += `<div class='d-flex flex-column width-full'>
+					<div>
+						`+time_line_heading+` on
+							<span>
+								${data[i].date_sep}
+							</span>
+					</div>
+					<div class='Box p-3 mt-2'>
+						<span class='${data[i].reference_name} document-id'>${label}
+							<div align='center'>
+								<a class='btn octicon octicon-chevron-down btn-default btn-xs btn-more'
+									data-doctype='${data[i].reference_doctype}' data-docname='${data[i].reference_name}'>
+								</a>
+							</div>
+						</span>
+						<span class='document-html' hidden  data-fetched="0">
+						</span>
+					</div>
+				</div>
+			</div>
+			</li>`;
+		}
+	}
+	details += "</ul>";
+	me.page.main.find(".patient_documents_list").append(details);
+	me.start += data.length;
+	if(data.length===20){
+		me.page.main.find(".btn-get-records").show();
+	}else{
+		me.page.main.find(".btn-get-records").hide();
+		me.page.main.find(".patient_documents_list").append("<div class='text-muted' align='center'><br><br>No more records..<br><br></div>");
+	}
+};
+
+var add_date_separator = function(data) {
+	var date = frappe.datetime.str_to_obj(data.creation);
+
+	var diff = frappe.datetime.get_day_diff(frappe.datetime.get_today(), frappe.datetime.obj_to_str(date));
+	if(diff < 1) {
+		var pdate = 'Today';
+	} else if(diff < 2) {
+		pdate = 'Yesterday';
+	} else {
+		pdate = frappe.datetime.global_date_format(date);
+	}
+	data.date_sep = pdate;
+	return data;
+};
+
+var show_patient_info = function(patient, me){
+	frappe.call({
+		"method": "erpnext.healthcare.doctype.patient.patient.get_patient_detail",
+		args: {
+			patient: patient
+		},
+		callback: function (r) {
+			var data = r.message;
+			var details = "";
+			if(data.image){
+				details += "<div><img class='thumbnail' width=75% src='"+data.image+"'></div>";
+			}
+			details += "<b>" + data.patient_name +"</b><br>" + data.sex;
+			if(data.email) details += "<br>" + data.email;
+			if(data.mobile) details += "<br>" + data.mobile;
+			if(data.occupation) details += "<br><br><b>Occupation :</b> " + data.occupation;
+			if(data.blood_group) details += "<br><b>Blood group : </b> " + data.blood_group;
+			if(data.allergies) details +=  "<br><br><b>Allergies : </b> "+  data.allergies.replace("\n", "<br>");
+			if(data.medication) details +=  "<br><b>Medication : </b> "+  data.medication.replace("\n", "<br>");
+			if(data.alcohol_current_use) details +=  "<br><br><b>Alcohol use : </b> "+  data.alcohol_current_use;
+			if(data.alcohol_past_use) details +=  "<br><b>Alcohol past use : </b> "+  data.alcohol_past_use;
+			if(data.tobacco_current_use) details +=  "<br><b>Tobacco use : </b> "+  data.tobacco_current_use;
+			if(data.tobacco_past_use) details +=  "<br><b>Tobacco past use : </b> "+  data.tobacco_past_use;
+			if(data.medical_history) details +=  "<br><br><b>Medical history : </b> "+  data.medical_history.replace("\n", "<br>");
+			if(data.surgical_history) details +=  "<br><b>Surgical history : </b> "+  data.surgical_history.replace("\n", "<br>");
+			if(data.surrounding_factors) details +=  "<br><br><b>Occupational hazards : </b> "+  data.surrounding_factors.replace("\n", "<br>");
+			if(data.other_risk_factors) details += "<br><b>Other risk factors : </b> " + data.other_risk_factors.replace("\n", "<br>");
+			if(data.patient_details) details += "<br><br><b>More info : </b> " + data.patient_details.replace("\n", "<br>");
+
+			if(details){
+				details = "<div style='padding-left:10px; font-size:13px;' align='center'>" + details + "</div>";
+			}
+			me.page.main.find(".patient_details").html(details);
+		}
+	});
+};
+
+var show_patient_vital_charts = function(patient, me, btn_show_id, pts, title) {
+	frappe.call({
+		method: "erpnext.healthcare.utils.get_patient_vitals",
+		args:{
+			patient: patient
+		},
+		callback: function(r) {
+			if (r.message){
+				var show_chart_btns_html = "<div style='padding-top:5px;'><a class='btn btn-default btn-xs btn-show-chart' \
+				data-show-chart-id='bp' data-pts='mmHg' data-title='Blood Pressure'>Blood Pressure</a>\
+				<a class='btn btn-default btn-xs btn-show-chart' data-show-chart-id='pulse_rate' \
+				data-pts='per Minutes' data-title='Respiratory/Pulse Rate'>Respiratory/Pulse Rate</a>\
+				<a class='btn btn-default btn-xs btn-show-chart' data-show-chart-id='temperature' \
+				data-pts='°C or °F' data-title='Temperature'>Temperature</a>\
+				<a class='btn btn-default btn-xs btn-show-chart' data-show-chart-id='bmi' \
+				data-pts='bmi' data-title='BMI'>BMI</a></div>";
+				me.page.main.find(".show_chart_btns").html(show_chart_btns_html);
+				var data = r.message;
+				let labels = [], datasets = [];
+				let bp_systolic = [], bp_diastolic = [], temperature = [];
+				let pulse = [], respiratory_rate = [], bmi = [], height = [], weight = [];
+				for(var i=0; i<data.length; i++){
+					labels.push(data[i].signs_date+"||"+data[i].signs_time);
+					if(btn_show_id=="bp"){
+						bp_systolic.push(data[i].bp_systolic);
+						bp_diastolic.push(data[i].bp_diastolic);
+					}
+					if(btn_show_id=="temperature"){
+						temperature.push(data[i].temperature);
+					}
+					if(btn_show_id=="pulse_rate"){
+						pulse.push(data[i].pulse);
+						respiratory_rate.push(data[i].respiratory_rate);
+					}
+					if(btn_show_id=="bmi"){
+						bmi.push(data[i].bmi);
+						height.push(data[i].height);
+						weight.push(data[i].weight);
+					}
+				}
+				if(btn_show_id=="temperature"){
+					datasets.push({name: "Temperature", values: temperature, chartType:'line'});
+				}
+				if(btn_show_id=="bmi"){
+					datasets.push({name: "BMI", values: bmi, chartType:'line'});
+					datasets.push({name: "Height", values: height, chartType:'line'});
+					datasets.push({name: "Weight", values: weight, chartType:'line'});
+				}
+				if(btn_show_id=="bp"){
+					datasets.push({name: "BP Systolic", values: bp_systolic, chartType:'line'});
+					datasets.push({name: "BP Diastolic", values: bp_diastolic, chartType:'line'});
+				}
+				if(btn_show_id=="pulse_rate"){
+					datasets.push({name: "Heart Rate / Pulse", values: pulse, chartType:'line'});
+					datasets.push({name: "Respiratory Rate", values: respiratory_rate, chartType:'line'});
+				}
+				new Chart( ".patient_vital_charts", {
+					data: {
+						labels: labels,
+						datasets: datasets
+					},
+
+					title: title,
+					type: 'axis-mixed', // 'axis-mixed', 'bar', 'line', 'pie', 'percentage'
+					height: 150,
+					colors: ['purple', '#ffa3ef', 'light-blue'],
+
+					tooltipOptions: {
+						formatTooltipX: d => (d + '').toUpperCase(),
+						formatTooltipY: d => d + ' ' + pts,
+					}
+				});
+			}else{
+				me.page.main.find(".patient_vital_charts").html("");
+				me.page.main.find(".show_chart_btns").html("");
+			}
+		}
+	});
+};
diff --git a/erpnext/healthcare/page/patient_history/patient_history.json b/erpnext/healthcare/page/patient_history/patient_history.json
new file mode 100644
index 0000000..b3892a4
--- /dev/null
+++ b/erpnext/healthcare/page/patient_history/patient_history.json
@@ -0,0 +1,28 @@
+{
+ "content": null, 
+ "creation": "2018-08-08 17:09:13.816199", 
+ "docstatus": 0, 
+ "doctype": "Page", 
+ "icon": "", 
+ "idx": 0, 
+ "modified": "2018-08-08 17:09:55.969424", 
+ "modified_by": "Administrator", 
+ "module": "Healthcare", 
+ "name": "patient_history", 
+ "owner": "Administrator", 
+ "page_name": "patient_history", 
+ "restrict_to_domain": "Healthcare", 
+ "roles": [
+  {
+   "role": "Healthcare Administrator"
+  }, 
+  {
+   "role": "Physician"
+  }
+ ], 
+ "script": null, 
+ "standard": "Yes", 
+ "style": null, 
+ "system_page": 0, 
+ "title": "Patient History"
+}
\ No newline at end of file
diff --git a/erpnext/healthcare/page/patient_history/patient_history.py b/erpnext/healthcare/page/patient_history/patient_history.py
new file mode 100644
index 0000000..772aa4e
--- /dev/null
+++ b/erpnext/healthcare/page/patient_history/patient_history.py
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2018, ESS LLP and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe.utils import cint
+from erpnext.healthcare.utils import render_docs_as_html
+
+@frappe.whitelist()
+def get_feed(name, start=0, page_length=20):
+	"""get feed"""
+	result = frappe.db.sql("""select name, owner, creation,
+		reference_doctype, reference_name, subject
+		from `tabPatient Medical Record`
+		where patient=%(patient)s
+		order by creation desc
+		limit %(start)s, %(page_length)s""",
+		{
+			"patient": name,
+			"start": cint(start),
+			"page_length": cint(page_length)
+		}, as_dict=True)
+	return result
+
+@frappe.whitelist()
+def get_feed_for_dt(doctype, docname):
+	"""get feed"""
+	result = frappe.db.sql("""select name, owner, modified, creation,
+			reference_doctype, reference_name, subject
+		from `tabPatient Medical Record`
+		where reference_name=%(docname)s and reference_doctype=%(doctype)s
+		order by creation desc""",
+		{
+			"docname": docname,
+			"doctype": doctype
+		}, as_dict=True)
+
+	return result
diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py
index 6a226d9..97bb98f 100644
--- a/erpnext/healthcare/utils.py
+++ b/erpnext/healthcare/utils.py
@@ -429,3 +429,116 @@
 					occupancy_msg = str(occupied) + " Occupied out of " + str(occupancy_total)
 			each["occupied_out_of_vacant"] = occupancy_msg
 	return hc_service_units
+
+@frappe.whitelist()
+def get_patient_vitals(patient, from_date=None, to_date=None):
+	if not patient: return
+	vitals = frappe.db.sql("""select * from `tabVital Signs` where \
+	docstatus=1 and patient=%s order by signs_date, signs_time""", \
+	(patient), as_dict=1)
+	if vitals and vitals[0]:
+		return vitals
+	else:
+		return False
+
+@frappe.whitelist()
+def render_docs_as_html(docs):
+	# docs key value pair {doctype: docname}
+	docs_html = "<div class='col-md-12 col-sm-12 text-muted'>"
+	for doc in docs:
+		docs_html += render_doc_as_html(doc['doctype'], doc['docname'])['html'] + "<br/>"
+		return {'html': docs_html}
+
+@frappe.whitelist()
+def render_doc_as_html(doctype, docname, exclude_fields = []):
+	#render document as html, three column layout will break
+	doc = frappe.get_doc(doctype, docname)
+	meta = frappe.get_meta(doctype)
+	doc_html = "<div class='col-md-12 col-sm-12'>"
+	section_html = ""
+	section_label = ""
+	html = ""
+	sec_on = False
+	col_on = 0
+	has_data = False
+	for df in meta.fields:
+		#on section break append append previous section and html to doc html
+		if df.fieldtype == "Section Break":
+			if has_data and col_on and sec_on:
+				doc_html += section_html + html + "</div>"
+			elif has_data and not col_on and sec_on:
+				doc_html += "<div class='col-md-12 col-sm-12'\
+				><div class='col-md-12 col-sm-12'>" \
+				+ section_html + html +"</div></div>"
+			while col_on:
+				doc_html += "</div>"
+				col_on -= 1
+			sec_on = True
+			has_data= False
+			col_on = 0
+			section_html = ""
+			html = ""
+			if df.label:
+				section_label = df.label
+			continue
+		#on column break append html to section html or doc html
+		if df.fieldtype == "Column Break":
+			if sec_on and has_data:
+				section_html += "<div class='col-md-12 col-sm-12'\
+				><div class='col-md-6 col\
+				-sm-6'><b>" + section_label + "</b>" + html + "</div><div \
+				class='col-md-6 col-sm-6'>"
+			elif has_data:
+				doc_html += "<div class='col-md-12 col-sm-12'><div class='col-m\
+				d-6 col-sm-6'>" + html + "</div><div class='col-md-6 col-sm-6'>"
+			elif sec_on and not col_on:
+				section_html += "<div class='col-md-6 col-sm-6'>"
+			html = ""
+			col_on += 1
+			if df.label:
+				html += '<br>' + df.label
+			continue
+		#on table iterate in items and create table based on in_list_view, append to section html or doc html
+		if df.fieldtype == "Table":
+			items = doc.get(df.fieldname)
+			if not items: continue
+			child_meta = frappe.get_meta(df.options)
+			if not has_data : has_data = True
+			table_head = ""
+			table_row = ""
+			create_head = True
+			for item in items:
+				table_row += '<tr>'
+				for cdf in child_meta.fields:
+					if cdf.in_list_view:
+						if create_head:
+							table_head += '<th>' + cdf.label + '</th>'
+						if item.get(cdf.fieldname):
+							table_row += '<td>' + str(item.get(cdf.fieldname)) \
+							+ '</td>'
+						else:
+							table_row += '<td></td>'
+				create_head = False
+				table_row += '</tr>'
+			if sec_on:
+				section_html += '<table class="table table-condensed \
+				bordered">' + table_head +  table_row + '</table>'
+			else:
+				html += '<table class="table table-condensed table-bordered">' \
+				+ table_head +  table_row + '</table>'
+			continue
+		#on other field types add label and value to html
+		if not df.hidden and not df.print_hide and doc.get(df.fieldname) and df.fieldname not in exclude_fields:
+			html +=  "<br>{0} : {1}".format(df.label or df.fieldname, \
+			doc.get(df.fieldname))
+			if not has_data : has_data = True
+	if sec_on and col_on and has_data:
+		doc_html += section_html + html + "</div></div>"
+	elif sec_on and not col_on and has_data:
+		doc_html += "<div class='col-md-12 col-sm-12'\
+		><div class='col-md-12 col-sm-12'>" \
+		+ section_html + html +"</div></div>"
+	if doc_html:
+		doc_html = "<div class='small'><div class='col-md-12 text-right'><a class='btn btn-default btn-xs' href='#Form/%s/%s'></a></div>" %(doctype, docname) + doc_html + "</div>"
+
+	return {'html': doc_html}
diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.js b/erpnext/hr/doctype/hr_settings/hr_settings.js
index 9e5effe..4004c1c 100644
--- a/erpnext/hr/doctype/hr_settings/hr_settings.js
+++ b/erpnext/hr/doctype/hr_settings/hr_settings.js
@@ -15,7 +15,7 @@
 		let policy = frm.doc.password_policy;
 		if (policy) {
 			if (policy.includes(' ') || policy.includes('--')) {
-				frappe.msgprint(_("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically"));
+				frappe.msgprint(__("Password policy cannot contain spaces or simultaneous hyphens. The format will be restructured automatically"));
 			}
 			frm.set_value('password_policy', policy.split(new RegExp(" |-", 'g')).filter((token) => token).join('-'));
 		}
diff --git a/erpnext/hr/doctype/loan_application/loan_application.py b/erpnext/hr/doctype/loan_application/loan_application.py
index 5dbcf15..67be9f2 100644
--- a/erpnext/hr/doctype/loan_application/loan_application.py
+++ b/erpnext/hr/doctype/loan_application/loan_application.py
@@ -29,9 +29,12 @@
 		if self.repayment_method == "Repay Fixed Amount per Period":
 			monthly_interest_rate = flt(self.rate_of_interest) / (12 *100)
 			if monthly_interest_rate:
-				self.repayment_periods = math.ceil((math.log(self.repayment_amount) -
-					math.log(self.repayment_amount - (self.loan_amount*monthly_interest_rate))) /
-					(math.log(1 + monthly_interest_rate)))
+				min_repayment_amount = self.loan_amount*monthly_interest_rate
+				if self.repayment_amount - min_repayment_amount < 0:
+					frappe.throw(_("Repayment Amount must be greater than " \
+						+ str(flt(min_repayment_amount, 2))))
+				self.repayment_periods = math.ceil(math.log(self.repayment_amount) -
+					math.log(self.repayment_amount - min_repayment_amount) /(math.log(1 + monthly_interest_rate)))
 			else:
 				self.repayment_periods = self.loan_amount / self.repayment_amount
 
diff --git a/erpnext/hr/doctype/loan_application/test_loan_application.py b/erpnext/hr/doctype/loan_application/test_loan_application.py
index 7644dd0..b08b522 100644
--- a/erpnext/hr/doctype/loan_application/test_loan_application.py
+++ b/erpnext/hr/doctype/loan_application/test_loan_application.py
@@ -31,21 +31,22 @@
 				"rate_of_interest": 9.2,
 				"loan_amount": 250000,
 				"repayment_method": "Repay Over Number of Periods",
-				"repayment_periods": 24
+				"repayment_periods": 18
 			})
 			loan_application.insert()
-	
+
 
 	def test_loan_totals(self):
 		loan_application = frappe.get_doc("Loan Application", {"applicant":self.applicant})
-		self.assertEquals(loan_application.repayment_amount, 11445)
-		self.assertEquals(loan_application.total_payable_interest, 24657)
-		self.assertEquals(loan_application.total_payable_amount, 274657)
 
-		loan_application.repayment_method = "Repay Fixed Amount per Period"
-		loan_application.repayment_amount = 15000
+		self.assertEqual(loan_application.total_payable_interest, 18599)
+		self.assertEqual(loan_application.total_payable_amount, 268599)
+		self.assertEqual(loan_application.repayment_amount, 14923)
+
+		loan_application.repayment_periods = 24
 		loan_application.save()
+		loan_application.reload()
 
-		self.assertEqual(loan_application.repayment_periods, 18)
-		self.assertEqual(loan_application.total_payable_interest, 18506)
-		self.assertEqual(loan_application.total_payable_amount, 268506)
\ No newline at end of file
+		self.assertEqual(loan_application.total_payable_interest, 24657)
+		self.assertEqual(loan_application.total_payable_amount, 274657)
+		self.assertEqual(loan_application.repayment_amount, 11445)
diff --git a/erpnext/hr/doctype/shift_type/shift_type.py b/erpnext/hr/doctype/shift_type/shift_type.py
index eaf6b1e..b98f445 100644
--- a/erpnext/hr/doctype/shift_type/shift_type.py
+++ b/erpnext/hr/doctype/shift_type/shift_type.py
@@ -22,7 +22,7 @@
 			'skip_auto_attendance':'0',
 			'attendance':('is', 'not set'),
 			'time':('>=', self.process_attendance_after),
-			'shift_actual_start': ('<', self.last_sync_of_checkin),
+			'shift_actual_end': ('<', self.last_sync_of_checkin),
 			'shift': self.name
 		}
 		logs = frappe.db.get_list('Employee Checkin', fields="*", filters=filters, order_by="employee,time")
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 766f675..6f63dcf 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -592,7 +592,6 @@
 				bom_item.idx,
 				item.item_name,
 				sum(bom_item.{qty_field}/ifnull(bom.quantity, 1)) * %(qty)s as qty,
-				item.description,
 				item.image,
 				bom.project,
 				item.stock_uom,
@@ -621,17 +620,22 @@
 			where_conditions="",
 			is_stock_item=is_stock_item,
 			qty_field="stock_qty",
-			select_columns = """, bom_item.source_warehouse, bom_item.operation, bom_item.include_item_in_manufacturing,
+			select_columns = """, bom_item.source_warehouse, bom_item.operation,
+				bom_item.include_item_in_manufacturing, bom_item.description,
 				(Select idx from `tabBOM Item` where item_code = bom_item.item_code and parent = %(parent)s limit 1) as idx""")
 
 		items = frappe.db.sql(query, { "parent": bom, "qty": qty, "bom": bom, "company": company }, as_dict=True)
 	elif fetch_scrap_items:
-		query = query.format(table="BOM Scrap Item", where_conditions="", select_columns=", bom_item.idx", is_stock_item=is_stock_item, qty_field="stock_qty")
+		query = query.format(table="BOM Scrap Item", where_conditions="",
+			select_columns=", bom_item.idx, item.description", is_stock_item=is_stock_item, qty_field="stock_qty")
+
 		items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
 	else:
 		query = query.format(table="BOM Item", where_conditions="", is_stock_item=is_stock_item,
 			qty_field="stock_qty" if fetch_qty_in_stock_uom else "qty",
-			select_columns = ", bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse, bom_item.idx, bom_item.operation, bom_item.include_item_in_manufacturing")
+			select_columns = """, bom_item.uom, bom_item.conversion_factor, bom_item.source_warehouse,
+				bom_item.idx, bom_item.operation, bom_item.include_item_in_manufacturing,
+				bom_item.description """)
 		items = frappe.db.sql(query, { "qty": qty, "bom": bom, "company": company }, as_dict=True)
 
 	for item in items:
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 571c2dc..0ba0818 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -505,6 +505,7 @@
 erpnext.patches.v10_0.set_student_party_type
 erpnext.patches.v10_0.update_project_in_sle
 erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
+erpnext.patches.v10_0.repost_requested_qty_for_non_stock_uom_items
 erpnext.patches.v11_0.merge_land_unit_with_location
 erpnext.patches.v11_0.add_index_on_nestedset_doctypes
 erpnext.patches.v11_0.remove_modules_setup_page
@@ -602,9 +603,11 @@
 erpnext.patches.v11_1.rename_depends_on_lwp
 execute:frappe.delete_doc("Report", "Inactive Items")
 erpnext.patches.v11_1.delete_scheduling_tool
+erpnext.patches.v12_0.rename_tolerance_fields
 erpnext.patches.v12_0.make_custom_fields_for_bank_remittance #14-06-2019
 execute:frappe.delete_doc_if_exists("Page", "support-analytics")
 erpnext.patches.v12_0.make_item_manufacturer
+erpnext.patches.v12_0.remove_patient_medical_record_page
 erpnext.patches.v11_1.move_customer_lead_to_dynamic_column
 erpnext.patches.v11_1.set_default_action_for_quality_inspection
 erpnext.patches.v11_1.delete_bom_browser
@@ -619,3 +622,4 @@
 erpnext.patches.v11_1.update_default_supplier_in_item_defaults
 erpnext.patches.v12_0.update_due_date_in_gle
 erpnext.patches.v12_0.add_default_buying_selling_terms_in_company
+erpnext.patches.v12_0.update_ewaybill_field_position
diff --git a/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py b/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py
new file mode 100644
index 0000000..4fe4e97
--- /dev/null
+++ b/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py
@@ -0,0 +1,21 @@
+# Copyright (c) 2019, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
+
+	count=0
+	for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse
+		from `tabMaterial Request Item` where docstatus = 1 and stock_uom<>uom"""):
+			try:
+				count += 1
+				update_bin_qty(item_code, warehouse, {
+					"indented_qty": get_indented_qty(item_code, warehouse),
+				})
+				if count % 200 == 0:
+					frappe.db.commit()
+			except:
+				frappe.db.rollback()
diff --git a/erpnext/patches/v12_0/remove_patient_medical_record_page.py b/erpnext/patches/v12_0/remove_patient_medical_record_page.py
new file mode 100644
index 0000000..904bfe4
--- /dev/null
+++ b/erpnext/patches/v12_0/remove_patient_medical_record_page.py
@@ -0,0 +1,7 @@
+# Copyright (c) 2019
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	frappe.delete_doc("Page", "medical_record")
diff --git a/erpnext/patches/v12_0/rename_tolerance_fields.py b/erpnext/patches/v12_0/rename_tolerance_fields.py
new file mode 100644
index 0000000..aa2fff4
--- /dev/null
+++ b/erpnext/patches/v12_0/rename_tolerance_fields.py
@@ -0,0 +1,15 @@
+import frappe
+from frappe.model.utils.rename_field import rename_field
+
+def execute():
+	frappe.reload_doc("stock", "doctype", "item")
+	frappe.reload_doc("stock", "doctype", "stock_settings")
+	frappe.reload_doc("accounts", "doctype", "accounts_settings")
+
+	rename_field('Stock Settings', "tolerance", "over_delivery_receipt_allowance")
+	rename_field('Item', "tolerance", "over_delivery_receipt_allowance")
+
+	qty_allowance = frappe.db.get_single_value("Stock Settings", "over_delivery_receipt_allowance")
+	frappe.db.set_value("Accounts Settings", None, "over_delivery_receipt_allowance", qty_allowance)
+
+	frappe.db.sql("update tabItem set over_billing_allowance=over_delivery_receipt_allowance")
\ No newline at end of file
diff --git a/erpnext/patches/v12_0/update_ewaybill_field_position.py b/erpnext/patches/v12_0/update_ewaybill_field_position.py
new file mode 100644
index 0000000..d0291d2
--- /dev/null
+++ b/erpnext/patches/v12_0/update_ewaybill_field_position.py
@@ -0,0 +1,27 @@
+from __future__ import unicode_literals
+import frappe
+from erpnext.regional.india.setup import make_custom_fields
+
+def execute():
+	company = frappe.get_all('Company', filters = {'country': 'India'})
+
+	if not company:
+		return
+
+	field = frappe.db.get_value("Custom Field", {"dt": "Sales Invoice", "fieldname": "ewaybill"})
+
+	ewaybill_field = frappe.get_doc("Custom Field", field)
+
+	ewaybill_field.flags.ignore_validate = True
+
+	ewaybill_field.update({
+		'fieldname': 'ewaybill',
+		'label': 'e-Way Bill No.',
+		'fieldtype': 'Data',
+		'depends_on': 'eval:(doc.docstatus === 1)',
+		'allow_on_submit': 1,
+		'insert_after': 'tax_id',
+		'translatable': 0
+	})
+
+	ewaybill_field.save()
\ No newline at end of file
diff --git a/erpnext/patches/v9_0/fix_subscription_next_date.py b/erpnext/patches/v9_0/fix_subscription_next_date.py
index 1789848..4595c8d 100644
--- a/erpnext/patches/v9_0/fix_subscription_next_date.py
+++ b/erpnext/patches/v9_0/fix_subscription_next_date.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.utils import getdate
-from frappe.desk.doctype.auto_repeat.auto_repeat import get_next_schedule_date
+from frappe.automation.doctype.auto_repeat.auto_repeat import get_next_schedule_date
 
 def execute():
 	frappe.reload_doc('accounts', 'doctype', 'subscription')
diff --git a/erpnext/projects/doctype/project/project.json b/erpnext/projects/doctype/project/project.json
index b4536c0..dc221bc 100644
--- a/erpnext/projects/doctype/project/project.json
+++ b/erpnext/projects/doctype/project/project.json
@@ -126,7 +126,8 @@
    "fieldname": "project_template",
    "fieldtype": "Link",
    "label": "From Template",
-   "options": "Project Template"
+   "options": "Project Template",
+   "set_only_once": 1
   },
   {
    "fieldname": "expected_start_date",
@@ -442,7 +443,7 @@
  "icon": "fa fa-puzzle-piece",
  "idx": 29,
  "max_attachments": 4,
- "modified": "2019-06-25 16:14:43.887151",
+ "modified": "2019-07-16 11:11:12.343658",
  "modified_by": "Administrator",
  "module": "Projects",
  "name": "Project",
@@ -481,6 +482,7 @@
  "quick_entry": 1,
  "search_fields": "customer, status, priority, is_active",
  "show_name_in_global_search": 1,
+ "sort_field": "modified",
  "sort_order": "DESC",
  "timeline_field": "customer",
  "track_seen": 1
diff --git a/erpnext/projects/doctype/project_user/project_user.json b/erpnext/projects/doctype/project_user/project_user.json
index 458028f..f0a70dd 100644
--- a/erpnext/projects/doctype/project_user/project_user.json
+++ b/erpnext/projects/doctype/project_user/project_user.json
@@ -1,333 +1,85 @@
 {
- "allow_copy": 0, 
- "allow_events_in_timeline": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 0, 
- "creation": "2016-03-25 02:52:19.283003", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
+ "creation": "2016-03-25 02:52:19.283003",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "user",
+  "email",
+  "image",
+  "column_break_2",
+  "full_name",
+  "welcome_email_sent",
+  "view_attachments",
+  "section_break_5",
+  "project_status"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "user", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "User", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "User", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "user",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "User",
+   "options": "User",
+   "reqd": 1,
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fetch_from": "user.email", 
-   "fieldname": "email", 
-   "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", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "user.email",
+   "fieldname": "email",
+   "fieldtype": "Read Only",
+   "label": "Email"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fetch_from": "user.user_image", 
-   "fieldname": "image", 
-   "fieldtype": "Read Only", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 1, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Image", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "user.user_image",
+   "fieldname": "image",
+   "fieldtype": "Read Only",
+   "hidden": 1,
+   "in_global_search": 1,
+   "label": "Image"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_2", 
-   "fieldtype": "Column Break", 
-   "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, 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_2",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "user.full_name", 
-   "fieldname": "full_name", 
-   "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": "Full Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "user.full_name",
+   "fieldname": "full_name",
+   "fieldtype": "Read Only",
+   "label": "Full Name"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "welcome_email_sent", 
-   "fieldtype": "Check", 
-   "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": "Welcome email sent", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "0",
+   "fieldname": "welcome_email_sent",
+   "fieldtype": "Check",
+   "label": "Welcome email sent"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 1, 
-   "fieldname": "view_attachments", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "View attachments", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "columns": 1,
+   "default": "0",
+   "fieldname": "view_attachments",
+   "fieldtype": "Check",
+   "in_list_view": 1,
+   "label": "View attachments"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "section_break_5", 
-   "fieldtype": "Section Break", 
-   "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, 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "section_break_5",
+   "fieldtype": "Section Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:parent.doctype == 'Project Update'", 
-   "fieldname": "project_status", 
-   "fieldtype": "Text", 
-   "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": "Project Status", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
+   "depends_on": "eval:parent.doctype == 'Project Update'",
+   "fieldname": "project_status",
+   "fieldtype": "Text",
+   "label": "Project Status"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2019-01-17 17:10:05.339735", 
- "modified_by": "Administrator", 
- "module": "Projects", 
- "name": "Project User", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 0, 
- "track_seen": 0, 
- "track_views": 0
+ ],
+ "istable": 1,
+ "modified": "2019-07-15 19:37:26.942294",
+ "modified_by": "Administrator",
+ "module": "Projects",
+ "name": "Project User",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "DESC"
 }
\ No newline at end of file
diff --git a/erpnext/projects/doctype/task/task.js b/erpnext/projects/doctype/task/task.js
index 489c7a3..5719276 100644
--- a/erpnext/projects/doctype/task/task.js
+++ b/erpnext/projects/doctype/task/task.js
@@ -42,20 +42,6 @@
 						frappe.set_route("List", "Expense Claim");
 					}, __("View"), true);
 				}
-
-				if (frm.perm[0].write) {
-					if (!["Closed", "Cancelled"].includes(frm.doc.status)) {
-						frm.add_custom_button(__("Close"), () => {
-							frm.set_value("status", "Closed");
-							frm.save();
-						});
-					} else {
-						frm.add_custom_button(__("Reopen"), () => {
-							frm.set_value("status", "Open");
-							frm.save();
-						});
-					}
-				}
 			}
 		}
 	},
diff --git a/erpnext/public/js/controllers/buying.js b/erpnext/public/js/controllers/buying.js
index 750900e..acc09ed 100644
--- a/erpnext/public/js/controllers/buying.js
+++ b/erpnext/public/js/controllers/buying.js
@@ -346,7 +346,7 @@
 	update_auto_repeat_reference: function(doc) {
 		if (doc.auto_repeat) {
 			frappe.call({
-				method:"frappe.desk.doctype.auto_repeat.auto_repeat.update_reference",
+				method:"frappe.automation.doctype.auto_repeat.auto_repeat.update_reference",
 				args:{
 					docname: doc.auto_repeat,
 					reference:doc.name
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 11fdb8b..844db99 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1424,11 +1424,14 @@
 				},
 				callback: function(r) {
 					if(!r.exc) {
-						me.frm.set_value("taxes", r.message);
+						if(me.frm.doc.shipping_rule && me.frm.doc.taxes) {
+							for (let tax of r.message) {
+								me.frm.add_child("taxes", tax);
+							}
 
-						if(me.frm.doc.shipping_rule) {
-							me.frm.script_manager.trigger("shipping_rule");
+							refresh_field("taxes");
 						} else {
+							me.frm.set_value("taxes", r.message);
 							me.calculate_taxes_and_totals();
 						}
 					}
diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js
index 560a561..84d2113 100644
--- a/erpnext/public/js/queries.js
+++ b/erpnext/public/js/queries.js
@@ -65,7 +65,7 @@
 				frappe.throw(__("Please set {0}",
 					[__(frappe.meta.get_label(doc.doctype, frappe.dynamic_link.fieldname, doc.name))]));
 			}
-
+			console.log(frappe.dynamic_link)
 			return {
 				query: 'frappe.contacts.doctype.address.address.address_query',
 				filters: {
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 0cd648e..0252f38 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -180,7 +180,7 @@
 
 	make_subscription: function(doctype, docname) {
 		frappe.call({
-			method: "frappe.desk.doctype.auto_repeat.auto_repeat.make_auto_repeat",
+			method: "frappe.automation.doctype.auto_repeat.auto_repeat.make_auto_repeat",
 			args: {
 				doctype: doctype,
 				docname: docname
diff --git a/erpnext/public/js/utils/party.js b/erpnext/public/js/utils/party.js
index 35185c9..a8d3888 100644
--- a/erpnext/public/js/utils/party.js
+++ b/erpnext/public/js/utils/party.js
@@ -145,7 +145,7 @@
 erpnext.utils.set_taxes = function(frm, triggered_from_field) {
 	if(frappe.meta.get_docfield(frm.doc.doctype, "taxes")) {
 		if(!erpnext.utils.validate_mandatory(frm, "Lead/Customer/Supplier",
-			frm.doc.customer || frm.doc.supplier || frm.doc.lead, triggered_from_field)) {
+			frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name, triggered_from_field)) {
 			return;
 		}
 
diff --git a/erpnext/quality_management/doctype/quality_feedback_parameter/quality_feedback_parameter.json b/erpnext/quality_management/doctype/quality_feedback_parameter/quality_feedback_parameter.json
index d0b368f..5bd8920 100644
--- a/erpnext/quality_management/doctype/quality_feedback_parameter/quality_feedback_parameter.json
+++ b/erpnext/quality_management/doctype/quality_feedback_parameter/quality_feedback_parameter.json
@@ -28,7 +28,7 @@
    "fieldtype": "Select",
    "in_list_view": 1,
    "label": "Rating",
-   "options": "1\n2\n3\n4\n5",
+   "options": "\n1\n2\n3\n4\n5",
    "reqd": 1
   },
   {
@@ -44,7 +44,7 @@
   }
  ],
  "istable": 1,
- "modified": "2019-05-26 21:50:48.951264",
+ "modified": "2019-07-13 19:58:08.966141",
  "modified_by": "Administrator",
  "module": "Quality Management",
  "name": "Quality Feedback Parameter",
diff --git a/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json b/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json
index 6985632..0849fd7 100644
--- a/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json
+++ b/erpnext/quality_management/doctype/quality_meeting/quality_meeting.json
@@ -26,7 +26,7 @@
    "fieldname": "status",
    "fieldtype": "Select",
    "label": "Status",
-   "options": "Open\nClose"
+   "options": "Open\nClosed"
   },
   {
    "fieldname": "minutes",
@@ -55,7 +55,7 @@
    "label": "Minutes"
   }
  ],
- "modified": "2019-05-26 23:12:23.364357",
+ "modified": "2019-07-13 19:57:40.500541",
  "modified_by": "Administrator",
  "module": "Quality Management",
  "name": "Quality Meeting",
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index eeb314c..40b98ed 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -354,7 +354,7 @@
 			'fieldtype': 'Data',
 			'depends_on': 'eval:(doc.docstatus === 1)',
 			'allow_on_submit': 1,
-			'insert_after': 'project',
+			'insert_after': 'tax_id',
 			'translatable': 0
 		}
 	]
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index e9b310e..0c5188a 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -14,7 +14,7 @@
 from frappe.desk.notifications import clear_doctype_notifications
 from frappe.contacts.doctype.address.address import get_company_address
 from erpnext.controllers.selling_controller import SellingController
-from frappe.desk.doctype.auto_repeat.auto_repeat import get_next_schedule_date
+from frappe.automation.doctype.auto_repeat.auto_repeat import get_next_schedule_date
 from erpnext.selling.doctype.customer.customer import check_credit_limit
 from erpnext.stock.doctype.item.item import get_item_defaults
 from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
diff --git a/erpnext/selling/doctype/sales_order/sales_order_list.js b/erpnext/selling/doctype/sales_order/sales_order_list.js
index 15c9eb5..301ecde 100644
--- a/erpnext/selling/doctype/sales_order/sales_order_list.js
+++ b/erpnext/selling/doctype/sales_order/sales_order_list.js
@@ -34,7 +34,7 @@
 					"per_delivered,<,100|per_billed,=,100|status,!=,Closed"];
 			}
 
-		} else if ((flt(doc.per_delivered, 6) == 100)
+		} else if ((flt(doc.per_delivered, 6) === 100)
 			&& flt(doc.grand_total) !== 0 && flt(doc.per_billed, 6) < 100 && doc.status !== "Closed") {
 			// to bill
 
@@ -48,7 +48,7 @@
 
 			if(flt(doc.per_billed, 6) < 100 ){
 				return [__("To Deliver and Bill"), "orange", "per_delivered,=,100|per_billed,<,100|status,!=,Closed"];
-			}else if(flt(doc.per_billed, 6) == 100){
+			}else if(flt(doc.per_billed, 6) === 100){
 				return [__("To Deliver"), "orange", "per_delivered,=,100|per_billed,=,100|status,!=,Closed"];
 			}
 		}
diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py
index 569c53f..bd07841 100644
--- a/erpnext/selling/doctype/sales_order/test_sales_order.py
+++ b/erpnext/selling/doctype/sales_order/test_sales_order.py
@@ -192,8 +192,8 @@
 
 	def test_reserved_qty_for_over_delivery(self):
 		make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
-		# set over-delivery tolerance
-		frappe.db.set_value('Item', "_Test Item", 'tolerance', 50)
+		# set over-delivery allowance
+		frappe.db.set_value('Item', "_Test Item", 'over_delivery_receipt_allowance', 50)
 
 		existing_reserved_qty = get_reserved_qty()
 
@@ -209,8 +209,9 @@
 	def test_reserved_qty_for_over_delivery_via_sales_invoice(self):
 		make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
 
-		# set over-delivery tolerance
-		frappe.db.set_value('Item', "_Test Item", 'tolerance', 50)
+		# set over-delivery allowance
+		frappe.db.set_value('Item', "_Test Item", 'over_delivery_receipt_allowance', 50)
+		frappe.db.set_value('Item', "_Test Item", 'over_billing_allowance', 20)
 
 		existing_reserved_qty = get_reserved_qty()
 
@@ -291,8 +292,8 @@
 		make_stock_entry(target="_Test Warehouse - _TC", qty=10, rate=100)
 		make_stock_entry(item="_Test Item Home Desktop 100", target="_Test Warehouse - _TC", qty=10, rate=100)
 
-		# set over-delivery tolerance
-		frappe.db.set_value('Item', "_Test Product Bundle Item", 'tolerance', 50)
+		# set over-delivery allowance
+		frappe.db.set_value('Item', "_Test Product Bundle Item", 'over_delivery_receipt_allowance', 50)
 
 		existing_reserved_qty_item1 = get_reserved_qty("_Test Item")
 		existing_reserved_qty_item2 = get_reserved_qty("_Test Item Home Desktop 100")
diff --git a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js
index de8abdc..3a99eb0 100644
--- a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js
+++ b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.js
@@ -16,20 +16,6 @@
 			"label": __("Customer"),
 			"fieldtype": "Link",
 			"options": "Customer"
-		},
-		{
-			"fieldname":"cost_center",
-			"label": __("Cost Center"),
-			"fieldtype": "Link",
-			"options": "Cost Center",
-			get_query: () => {
-				var company = frappe.query_report.get_filter_value('company');
-				return {
-					filters: {
-						'company': company
-					}
-				}
-			}
-		},
+		}
 	]
 }
diff --git a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py
index a57d975..ee0d72b 100644
--- a/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py
+++ b/erpnext/selling/report/customer_credit_balance/customer_credit_balance.py
@@ -21,8 +21,7 @@
 		row = []
 
 		outstanding_amt = get_customer_outstanding(d.name, filters.get("company"),
-			ignore_outstanding_sales_order=d.bypass_credit_limit_check_at_sales_order,
-			cost_center=filters.get("cost_center"))
+			ignore_outstanding_sales_order=d.bypass_credit_limit_check_at_sales_order)
 
 		credit_limit = get_credit_limit(d.name, filters.get("company"))
 
@@ -66,3 +65,4 @@
 	return frappe.db.sql("""select name, customer_name,
 		bypass_credit_limit_check_at_sales_order, is_frozen, disabled from `tabCustomer` %s
 	""" % conditions, filters, as_dict=1)
+
diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.js b/erpnext/selling/report/sales_analytics/sales_analytics.js
index fbe045b..149c923 100644
--- a/erpnext/selling/report/sales_analytics/sales_analytics.js
+++ b/erpnext/selling/report/sales_analytics/sales_analytics.js
@@ -8,7 +8,7 @@
 			fieldname: "tree_type",
 			label: __("Tree Type"),
 			fieldtype: "Select",
-			options: ["Customer Group","Customer","Item Group","Item","Territory"],
+			options: ["Customer Group","Customer","Item Group","Item","Territory","Order Type"],
 			default: "Customer",
 			reqd: 1
 		},
diff --git a/erpnext/selling/report/sales_analytics/sales_analytics.py b/erpnext/selling/report/sales_analytics/sales_analytics.py
index 3239fc6..8a5e50a 100644
--- a/erpnext/selling/report/sales_analytics/sales_analytics.py
+++ b/erpnext/selling/report/sales_analytics/sales_analytics.py
@@ -23,15 +23,15 @@
 		self.get_columns()
 		self.get_data()
 		self.get_chart_data()
-		return self.columns, self.data , None, self.chart
+		return self.columns, self.data, None, self.chart
 
 	def get_columns(self):
-		self.columns =[{
+		self.columns = [{
 				"label": _(self.filters.tree_type + " ID"),
-				"options": self.filters.tree_type,
+				"options": self.filters.tree_type if self.filters.tree_type != "Order Type" else "",
 				"fieldname": "entity",
-				"fieldtype": "Link",
-				"width": 140
+				"fieldtype": "Link" if self.filters.tree_type != "Order Type" else "Data",
+				"width": 140 if self.filters.tree_type != "Order Type" else 200
 			}]
 		if self.filters.tree_type in ["Customer", "Supplier", "Item"]:
 			self.columns.append({
@@ -73,6 +73,28 @@
 			self.get_sales_transactions_based_on_item_group()
 			self.get_rows_by_group()
 
+		elif self.filters.tree_type == "Order Type":
+			if self.filters.doc_type != "Sales Order":
+				self.data = []
+				return
+			self.get_sales_transactions_based_on_order_type()
+			self.get_rows_by_group()
+
+	def get_sales_transactions_based_on_order_type(self):
+		if self.filters["value_quantity"] == 'Value':
+			value_field = "base_net_total"
+		else:
+			value_field = "total_qty"
+
+		self.entries = frappe.db.sql(""" select s.order_type as entity, s.{value_field} as value_field, s.{date_field}
+			from `tab{doctype}` s where s.docstatus = 1 and s.company = %s and s.{date_field} between %s and %s
+			and ifnull(s.order_type, '') != '' order by s.order_type
+		"""
+		.format(date_field=self.date_field, value_field=value_field, doctype=self.filters.doc_type),
+		(self.filters.company, self.filters.from_date, self.filters.to_date), as_dict=1)
+
+		self.get_teams()
+
 	def get_sales_transactions_based_on_customers_or_suppliers(self):
 		if self.filters["value_quantity"] == 'Value':
 			value_field = "base_net_total as value_field"
@@ -88,7 +110,7 @@
 
 		self.entries = frappe.get_all(self.filters.doc_type,
 			fields=[entity, entity_name, value_field, self.date_field],
-			filters = {
+			filters={
 				"docstatus": 1,
 				"company": self.filters.company,
 				self.date_field: ('between', [self.filters.from_date, self.filters.to_date])
@@ -112,7 +134,7 @@
 			where s.name = i.parent and i.docstatus = 1 and s.company = %s
 			and s.{date_field} between %s and %s
 		"""
-		.format(date_field=self.date_field, value_field = value_field, doctype=self.filters.doc_type),
+		.format(date_field=self.date_field, value_field=value_field, doctype=self.filters.doc_type),
 		(self.filters.company, self.filters.from_date, self.filters.to_date), as_dict=1)
 
 		self.entity_names = {}
@@ -135,7 +157,7 @@
 
 		self.entries = frappe.get_all(self.filters.doc_type,
 			fields=[entity_field, value_field, self.date_field],
-			filters = {
+			filters={
 				"docstatus": 1,
 				"company": self.filters.company,
 				self.date_field: ('between', [self.filters.from_date, self.filters.to_date])
@@ -154,13 +176,13 @@
 			from `tab{doctype} Item` i , `tab{doctype}` s
 			where s.name = i.parent and i.docstatus = 1 and s.company = %s
 			and s.{date_field} between %s and %s
-		""".format(date_field=self.date_field, value_field = value_field, doctype=self.filters.doc_type),
+		""".format(date_field=self.date_field, value_field=value_field, doctype=self.filters.doc_type),
 		(self.filters.company, self.filters.from_date, self.filters.to_date), as_dict=1)
 
 		self.get_groups()
 
 	def get_rows(self):
-		self.data=[]
+		self.data = []
 		self.get_periodic_data()
 
 		for entity, period_data in iteritems(self.entity_periodic_data):
@@ -192,7 +214,7 @@
 				period = self.get_period(end_date)
 				amount = flt(self.entity_periodic_data.get(d.name, {}).get(period, 0.0))
 				row[scrub(period)] = amount
-				if d.parent:
+				if d.parent and (self.filters.tree_type != "Order Type" or d.parent == "Order Types"):
 					self.entity_periodic_data.setdefault(d.parent, frappe._dict()).setdefault(period, 0.0)
 					self.entity_periodic_data[d.parent][period] += amount
 				total += amount
@@ -216,7 +238,7 @@
 		elif self.filters.range == 'Monthly':
 			period = str(self.months[posting_date.month - 1]) + " " + str(posting_date.year)
 		elif self.filters.range == 'Quarterly':
-			period = "Quarter " + str(((posting_date.month-1)//3)+1) +" " + str(posting_date.year)
+			period = "Quarter " + str(((posting_date.month - 1) // 3) + 1) + " " + str(posting_date.year)
 		else:
 			year = get_fiscal_year(posting_date, company=self.filters.company)
 			period = str(year[0])
@@ -234,7 +256,7 @@
 		}.get(self.filters.range, 1)
 
 		if self.filters.range in ['Monthly', 'Quarterly']:
-			from_date = from_date.replace(day = 1)
+			from_date = from_date.replace(day=1)
 		elif self.filters.range == "Yearly":
 			from_date = get_fiscal_year(from_date)[1]
 		else:
@@ -270,7 +292,22 @@
 
 		self.group_entries = frappe.db.sql("""select name, lft, rgt , {parent} as parent
 			from `tab{tree}` order by lft"""
-			.format(tree=self.filters.tree_type, parent=parent), as_dict=1)
+		.format(tree=self.filters.tree_type, parent=parent), as_dict=1)
+
+		for d in self.group_entries:
+			if d.parent:
+				self.depth_map.setdefault(d.name, self.depth_map.get(d.parent) + 1)
+			else:
+				self.depth_map.setdefault(d.name, 0)
+
+	def get_teams(self):
+		self.depth_map = frappe._dict()
+
+		self.group_entries = frappe.db.sql(""" select * from (select "Order Types" as name, 0 as lft,
+			2 as rgt, '' as parent union select distinct order_type as name, 1 as lft, 1 as rgt, "Order Types" as parent
+			from `tab{doctype}` where ifnull(order_type, '') != '') as b order by lft, name
+		"""
+		.format(doctype=self.filters.doc_type), as_dict=1)
 
 		for d in self.group_entries:
 			if d.parent:
@@ -285,13 +322,13 @@
 		length = len(self.columns)
 
 		if self.filters.tree_type in ["Customer", "Supplier", "Item"]:
-			labels = [d.get("label") for d in self.columns[2:length-1]]
+			labels = [d.get("label") for d in self.columns[2:length - 1]]
 		else:
-			labels = [d.get("label") for d in self.columns[1:length-1]]
+			labels = [d.get("label") for d in self.columns[1:length - 1]]
 		self.chart = {
 			"data": {
 				'labels': labels,
-				'datasets':[]
+				'datasets': []
 			},
 			"type": "line"
-		}
\ No newline at end of file
+		}
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index a2bae56..000d666 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -428,7 +428,7 @@
 	update_auto_repeat_reference: function(doc) {
 		if (doc.auto_repeat) {
 			frappe.call({
-				method:"frappe.desk.doctype.auto_repeat.auto_repeat.update_reference",
+				method:"frappe.automation.doctype.auto_repeat.auto_repeat.update_reference",
 				args:{
 					docname: doc.auto_repeat,
 					reference:doc.name
diff --git a/erpnext/shopping_cart/cart.py b/erpnext/shopping_cart/cart.py
index 4019e07..62bde42 100644
--- a/erpnext/shopping_cart/cart.py
+++ b/erpnext/shopping_cart/cart.py
@@ -61,7 +61,7 @@
 	quotation.flags.ignore_permissions = True
 	quotation.submit()
 
-	if quotation.lead:
+	if quotation.quotation_to == 'Lead' and quotation.party_name:
 		# company used to create customer accounts
 		frappe.defaults.set_user_default("company", quotation.company)
 
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index ec7df2d..2de9b97 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -51,7 +51,7 @@
 			'source_field': 'qty',
 			'percent_join_field': 'against_sales_invoice',
 			'overflow_type': 'delivery',
-			'no_tolerance': 1
+			'no_allowance': 1
 		}]
 		if cint(self.is_return):
 			self.status_updater.append({
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 164ffa4..a142bb9 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -29,7 +29,8 @@
    "is_fixed_asset",
    "asset_category",
    "asset_naming_series",
-   "tolerance",
+   "over_delivery_receipt_allowance",
+   "over_billing_allowance",
    "image",
    "section_break_11",
    "brand",
@@ -285,14 +286,6 @@
     "label": "Asset Naming Series"
    },
    {
-    "depends_on": "eval:!doc.__islocal",
-    "fieldname": "tolerance",
-    "fieldtype": "Float",
-    "label": "Allow over delivery or receipt upto this percent",
-    "oldfieldname": "tolerance",
-    "oldfieldtype": "Currency"
-   },
-   {
     "fieldname": "image",
     "fieldtype": "Attach Image",
     "hidden": 1,
@@ -1021,6 +1014,26 @@
     "fieldtype": "Check",
     "label": "Synced With Hub",
     "read_only": 1
+   },
+   {
+    "fieldname": "manufacturers",
+    "fieldtype": "Table",
+    "label": "Manufacturers",
+    "options": "Item Manufacturer"
+   },
+   {
+    "depends_on": "eval:!doc.__islocal",
+    "fieldname": "over_delivery_receipt_allowance",
+    "fieldtype": "Float",
+    "label": "Over Delivery/Receipt Allowance (%)",
+    "oldfieldname": "tolerance",
+    "oldfieldtype": "Currency"
+   },
+   {
+    "fieldname": "over_billing_allowance",
+    "fieldtype": "Float",
+    "label": "Over Billing Allowance (%)",
+    "depends_on": "eval:!doc.__islocal"
    }
   ],
   "has_web_view": 1,
@@ -1028,7 +1041,7 @@
   "idx": 2,
   "image_field": "image",
   "max_attachments": 1,
-  "modified": "2019-07-05 12:18:13.977931",
+  "modified": "2019-07-12 12:18:13.977931",
   "modified_by": "Administrator",
   "module": "Stock",
   "name": "Item",
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 6484b93..03e903c 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -1007,7 +1007,7 @@
 
 	if item_code:
 		item_cache = ItemVariantsCacheManager(item_code)
-		item_cache.rebuild_cache()
+		item_cache.clear_cache()
 
 
 def check_stock_uom_with_bin(item, stock_uom):
diff --git a/erpnext/stock/doctype/manufacturer/manufacturer.js b/erpnext/stock/doctype/manufacturer/manufacturer.js
index 67df1bf..bb7e314 100644
--- a/erpnext/stock/doctype/manufacturer/manufacturer.js
+++ b/erpnext/stock/doctype/manufacturer/manufacturer.js
@@ -3,6 +3,14 @@
 
 frappe.ui.form.on('Manufacturer', {
 	refresh: function(frm) {
-
+		frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Manufacturer' };
+		if (frm.doc.__islocal) {
+			hide_field(['address_html','contact_html']);
+			frappe.contacts.clear_address_and_contact(frm);
+		}
+		else {
+			unhide_field(['address_html','contact_html']);
+			frappe.contacts.render_address_and_contact(frm);
+		}
 	}
 });
diff --git a/erpnext/stock/doctype/manufacturer/manufacturer.json b/erpnext/stock/doctype/manufacturer/manufacturer.json
index 5025917..3a64fbe 100644
--- a/erpnext/stock/doctype/manufacturer/manufacturer.json
+++ b/erpnext/stock/doctype/manufacturer/manufacturer.json
@@ -1,268 +1,120 @@
 {
- "allow_copy": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 1, 
- "allow_rename": 1, 
- "autoname": "field:short_name", 
- "beta": 0, 
- "creation": "2016-01-17 11:04:52.761731", 
- "custom": 0, 
- "description": "Manufacturers used in Items", 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Setup", 
- "editable_grid": 0, 
+ "allow_import": 1,
+ "allow_rename": 1,
+ "autoname": "field:short_name",
+ "creation": "2016-01-17 11:04:52.761731",
+ "description": "Manufacturers used in Items",
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "engine": "InnoDB",
+ "field_order": [
+  "short_name",
+  "full_name",
+  "website",
+  "country",
+  "logo",
+  "address_contacts",
+  "address_html",
+  "column_break_8",
+  "contact_html",
+  "section_break_10",
+  "notes"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "description": "Limited to 12 characters", 
-   "fieldname": "short_name", 
-   "fieldtype": "Data", 
-   "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": "Short Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "description": "Limited to 12 characters",
+   "fieldname": "short_name",
+   "fieldtype": "Data",
+   "label": "Short Name",
+   "reqd": 1,
+   "unique": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "full_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Full Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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
-  }, 
+   "fieldname": "full_name",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Full Name"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "website", 
-   "fieldtype": "Data", 
-   "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": "Website", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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
-  }, 
+   "fieldname": "website",
+   "fieldtype": "Data",
+   "label": "Website"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "country", 
-   "fieldtype": "Link", 
-   "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": "Country", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Country", 
-   "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
-  }, 
+   "fieldname": "country",
+   "fieldtype": "Link",
+   "label": "Country",
+   "options": "Country"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "logo", 
-   "fieldtype": "Attach Image", 
-   "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": "Logo", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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
-  }, 
+   "fieldname": "logo",
+   "fieldtype": "Attach Image",
+   "label": "Logo"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "notes", 
-   "fieldtype": "Small Text", 
-   "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": "Notes", 
-   "length": 0, 
-   "no_copy": 0, 
-   "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
+   "fieldname": "notes",
+   "fieldtype": "Small Text",
+   "label": "Notes"
+  },
+  {
+   "depends_on": "eval:!doc.__islocal",
+   "fieldname": "address_contacts",
+   "fieldtype": "Section Break",
+   "label": "Address and Contacts",
+   "options": "fa fa-map-marker"
+  },
+  {
+   "fieldname": "address_html",
+   "fieldtype": "HTML",
+   "label": "Address HTML",
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_8",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "contact_html",
+   "fieldtype": "HTML",
+   "label": "Contact HTML",
+   "read_only": 1
+  },
+  {
+   "fieldname": "section_break_10",
+   "fieldtype": "Section Break"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "icon": "fa fa-certificate", 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2017-08-03 06:27:57.182666", 
- "modified_by": "Administrator", 
- "module": "Stock", 
- "name": "Manufacturer", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "icon": "fa fa-certificate",
+ "modified": "2019-07-06 13:06:47.237014",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Manufacturer",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0, 
-   "apply_user_permissions": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Stock Manager", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Stock Manager",
+   "share": 1,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "apply_user_permissions": 0, 
-   "cancel": 0, 
-   "create": 0, 
-   "delete": 0, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Stock User", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
-   "write": 0
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Stock User",
+   "share": 1
   }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "search_fields": "short_name, full_name", 
- "show_name_in_global_search": 1, 
- "sort_field": "", 
- "sort_order": "DESC", 
- "title_field": "short_name", 
- "track_changes": 0, 
- "track_seen": 0
+ ],
+ "search_fields": "short_name, full_name",
+ "show_name_in_global_search": 1,
+ "sort_order": "DESC",
+ "title_field": "short_name"
 }
\ No newline at end of file
diff --git a/erpnext/stock/doctype/manufacturer/manufacturer.py b/erpnext/stock/doctype/manufacturer/manufacturer.py
index 7b85b05..b624f73 100644
--- a/erpnext/stock/doctype/manufacturer/manufacturer.py
+++ b/erpnext/stock/doctype/manufacturer/manufacturer.py
@@ -4,7 +4,10 @@
 
 from __future__ import unicode_literals
 import frappe
+from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
 from frappe.model.document import Document
 
 class Manufacturer(Document):
-	pass
+	def onload(self):
+		"""Load address and contacts in `__onload`"""
+		load_address_and_contact(self)
diff --git a/erpnext/stock/doctype/quality_inspection/quality_inspection.json b/erpnext/stock/doctype/quality_inspection/quality_inspection.json
index 94d4794..a9f3cd0 100644
--- a/erpnext/stock/doctype/quality_inspection/quality_inspection.json
+++ b/erpnext/stock/doctype/quality_inspection/quality_inspection.json
@@ -1,857 +1,260 @@
 {
- "allow_copy": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "autoname": "naming_series:", 
- "beta": 0, 
- "creation": "2013-04-30 13:13:03", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Setup", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "autoname": "naming_series:",
+ "creation": "2013-04-30 13:13:03",
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "naming_series",
+  "report_date",
+  "column_break_4",
+  "inspection_type",
+  "reference_type",
+  "reference_name",
+  "section_break_7",
+  "item_code",
+  "item_serial_no",
+  "batch_no",
+  "sample_size",
+  "column_break1",
+  "item_name",
+  "description",
+  "status",
+  "section_break_14",
+  "inspected_by",
+  "verified_by",
+  "bom_no",
+  "column_break_17",
+  "remarks",
+  "amended_from",
+  "specification_details",
+  "quality_inspection_template",
+  "readings"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "", 
-   "fieldname": "naming_series", 
-   "fieldtype": "Select", 
-   "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": "Series", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "MAT-QA-.YYYY.-", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 1, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Series",
+   "no_copy": 1,
+   "options": "MAT-QA-.YYYY.-",
+   "reqd": 1,
+   "set_only_once": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "Today", 
-   "fieldname": "report_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Report Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "report_date", 
-   "oldfieldtype": "Date", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "Today",
+   "fieldname": "report_date",
+   "fieldtype": "Date",
+   "in_list_view": 1,
+   "label": "Report Date",
+   "oldfieldname": "report_date",
+   "oldfieldtype": "Date",
+   "reqd": 1,
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_4", 
-   "fieldtype": "Column Break", 
-   "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, 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_4",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "inspection_type", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Inspection Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "inspection_type", 
-   "oldfieldtype": "Select", 
-   "options": "\nIncoming\nOutgoing\nIn Process", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "inspection_type",
+   "fieldtype": "Select",
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Inspection Type",
+   "oldfieldname": "inspection_type",
+   "oldfieldtype": "Select",
+   "options": "\nIncoming\nOutgoing\nIn Process",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reference_type", 
-   "fieldtype": "Select", 
-   "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": "Reference Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nPurchase Receipt\nPurchase Invoice\nDelivery Note\nSales Invoice\nStock Entry", 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "reference_type",
+   "fieldtype": "Select",
+   "label": "Reference Type",
+   "options": "\nPurchase Receipt\nPurchase Invoice\nDelivery Note\nSales Invoice\nStock Entry"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "", 
-   "fieldname": "reference_name", 
-   "fieldtype": "Dynamic Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 1, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Reference Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "purchase_receipt_no", 
-   "oldfieldtype": "Link", 
-   "options": "reference_type", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "reference_name",
+   "fieldtype": "Dynamic Link",
+   "in_global_search": 1,
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Reference Name",
+   "oldfieldname": "purchase_receipt_no",
+   "oldfieldtype": "Link",
+   "options": "reference_type"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "section_break_7", 
-   "fieldtype": "Section Break", 
-   "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, 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "section_break_7",
+   "fieldtype": "Section Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "item_code", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 1, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Item Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "item_code", 
-   "oldfieldtype": "Link", 
-   "options": "Item", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "item_code",
+   "fieldtype": "Link",
+   "in_global_search": 1,
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Item Code",
+   "oldfieldname": "item_code",
+   "oldfieldtype": "Link",
+   "options": "Item",
+   "reqd": 1,
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "item_serial_no", 
-   "fieldtype": "Link", 
-   "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": "Item Serial No", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "item_serial_no", 
-   "oldfieldtype": "Link", 
-   "options": "Serial No", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "item_serial_no",
+   "fieldtype": "Link",
+   "label": "Item Serial No",
+   "oldfieldname": "item_serial_no",
+   "oldfieldtype": "Link",
+   "options": "Serial No"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "batch_no", 
-   "fieldtype": "Link", 
-   "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": "Batch No", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "batch_no", 
-   "oldfieldtype": "Link", 
-   "options": "Batch", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "batch_no",
+   "fieldtype": "Link",
+   "label": "Batch No",
+   "oldfieldname": "batch_no",
+   "oldfieldtype": "Link",
+   "options": "Batch"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "sample_size", 
-   "fieldtype": "Float", 
-   "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": "Sample Size", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "sample_size", 
-   "oldfieldtype": "Currency", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "sample_size",
+   "fieldtype": "Float",
+   "label": "Sample Size",
+   "oldfieldname": "sample_size",
+   "oldfieldtype": "Currency",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break1", 
-   "fieldtype": "Column Break", 
-   "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, 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldtype": "Column Break", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0, 
+   "fieldname": "column_break1",
+   "fieldtype": "Column Break",
+   "oldfieldtype": "Column Break",
    "width": "50%"
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "item_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 1, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Item Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "item_name",
+   "fieldtype": "Data",
+   "in_global_search": 1,
+   "label": "Item Name",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "description", 
-   "fieldtype": "Small Text", 
-   "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": "Description", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "description", 
-   "oldfieldtype": "Small Text", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0, 
+   "fieldname": "description",
+   "fieldtype": "Small Text",
+   "label": "Description",
+   "oldfieldname": "description",
+   "oldfieldtype": "Small Text",
    "width": "300px"
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "section_break_14", 
-   "fieldtype": "Section Break", 
-   "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, 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "section_break_14",
+   "fieldtype": "Section Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "user", 
-   "fieldname": "inspected_by", 
-   "fieldtype": "Link", 
-   "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": "Inspected By", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "inspected_by", 
-   "oldfieldtype": "Data", 
-   "options": "User", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "user",
+   "fieldname": "inspected_by",
+   "fieldtype": "Link",
+   "label": "Inspected By",
+   "oldfieldname": "inspected_by",
+   "oldfieldtype": "Data",
+   "options": "User",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "verified_by", 
-   "fieldtype": "Data", 
-   "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": "Verified By", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "verified_by", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "verified_by",
+   "fieldtype": "Data",
+   "label": "Verified By",
+   "oldfieldname": "verified_by",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "bom_no", 
-   "fieldtype": "Link", 
-   "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": "BOM No", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "BOM", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "bom_no",
+   "fieldtype": "Link",
+   "label": "BOM No",
+   "options": "BOM",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_17", 
-   "fieldtype": "Column Break", 
-   "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, 
-   "length": 0, 
-   "no_copy": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_17",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "remarks", 
-   "fieldtype": "Text", 
-   "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": "Remarks", 
-   "length": 0, 
-   "no_copy": 1, 
-   "oldfieldname": "remarks", 
-   "oldfieldtype": "Text", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "remarks",
+   "fieldtype": "Text",
+   "label": "Remarks",
+   "no_copy": 1,
+   "oldfieldname": "remarks",
+   "oldfieldtype": "Text"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "amended_from", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Amended From", 
-   "length": 0, 
-   "no_copy": 1, 
-   "oldfieldname": "amended_from", 
-   "oldfieldtype": "Data", 
-   "options": "Quality Inspection", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "amended_from",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "label": "Amended From",
+   "no_copy": 1,
+   "oldfieldname": "amended_from",
+   "oldfieldtype": "Data",
+   "options": "Quality Inspection",
+   "print_hide": 1,
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "specification_details", 
-   "fieldtype": "Section Break", 
-   "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": "", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldtype": "Section Break", 
-   "options": "Simple", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "specification_details",
+   "fieldtype": "Section Break",
+   "oldfieldtype": "Section Break",
+   "options": "Simple"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "quality_inspection_template", 
-   "fieldtype": "Link", 
-   "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": "Quality Inspection Template", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Quality Inspection Template", 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "quality_inspection_template",
+   "fieldtype": "Link",
+   "label": "Quality Inspection Template",
+   "options": "Quality Inspection Template"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "readings", 
-   "fieldtype": "Table", 
-   "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": "Readings", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "qa_specification_details", 
-   "oldfieldtype": "Table", 
-   "options": "Quality Inspection Reading", 
-   "permlevel": 0, 
-   "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, 
-   "translatable": 0, 
-   "unique": 0
+   "fieldname": "readings",
+   "fieldtype": "Table",
+   "label": "Readings",
+   "oldfieldname": "qa_specification_details",
+   "oldfieldtype": "Table",
+   "options": "Quality Inspection Reading"
+  },
+  {
+   "default": "Accepted",
+   "fieldname": "status",
+   "fieldtype": "Select",
+   "label": "Status",
+   "options": "\nAccepted\nRejected",
+   "reqd": 1
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "icon": "fa fa-search", 
- "idx": 1, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 1, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2018-08-21 14:44:45.996446", 
- "modified_by": "Administrator", 
- "module": "Stock", 
- "name": "Quality Inspection", 
- "owner": "Administrator", 
+ ],
+ "icon": "fa fa-search",
+ "idx": 1,
+ "is_submittable": 1,
+ "modified": "2019-07-12 12:07:23.153698",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Quality Inspection",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 1, 
-   "cancel": 1, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 0, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Quality Manager", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 1, 
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Quality Manager",
+   "share": 1,
+   "submit": 1,
    "write": 1
   }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "search_fields": "item_code, report_date, reference_name", 
- "show_name_in_global_search": 1, 
- "sort_order": "ASC", 
- "track_changes": 0, 
- "track_seen": 0, 
- "track_views": 0
+ ],
+ "quick_entry": 1,
+ "search_fields": "item_code, report_date, reference_name",
+ "show_name_in_global_search": 1,
+ "sort_field": "modified",
+ "sort_order": "ASC"
 }
\ No newline at end of file
diff --git a/erpnext/stock/doctype/quality_inspection_reading/quality_inspection_reading.json b/erpnext/stock/doctype/quality_inspection_reading/quality_inspection_reading.json
index 94aecfe..f9f8a71 100644
--- a/erpnext/stock/doctype/quality_inspection_reading/quality_inspection_reading.json
+++ b/erpnext/stock/doctype/quality_inspection_reading/quality_inspection_reading.json
@@ -1,413 +1,138 @@
 {
- "allow_copy": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "autoname": "hash", 
- "beta": 0, 
- "creation": "2013-02-22 01:27:43", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "editable_grid": 1, 
+ "autoname": "hash",
+ "creation": "2013-02-22 01:27:43",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "field_order": [
+  "specification",
+  "value",
+  "reading_1",
+  "reading_2",
+  "reading_3",
+  "reading_4",
+  "reading_5",
+  "reading_6",
+  "reading_7",
+  "reading_8",
+  "reading_9",
+  "reading_10",
+  "status"
+ ],
  "fields": [
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "specification", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Parameter", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "specification", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "columns": 3,
+   "fieldname": "specification",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Parameter",
+   "oldfieldname": "specification",
+   "oldfieldtype": "Data",
+   "reqd": 1
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "value", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Acceptance Criteria", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "value", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "columns": 2,
+   "fieldname": "value",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Acceptance Criteria",
+   "oldfieldname": "value",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_1", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Reading 1", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_1", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "columns": 1,
+   "fieldname": "reading_1",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Reading 1",
+   "oldfieldname": "reading_1",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_2", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Reading 2", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_2", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "columns": 1,
+   "fieldname": "reading_2",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Reading 2",
+   "oldfieldname": "reading_2",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_3", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Reading 3", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_3", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "columns": 1,
+   "fieldname": "reading_3",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Reading 3",
+   "oldfieldname": "reading_3",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_4", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Reading 4", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_4", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "fieldname": "reading_4",
+   "fieldtype": "Data",
+   "label": "Reading 4",
+   "oldfieldname": "reading_4",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_5", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reading 5", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_5", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "fieldname": "reading_5",
+   "fieldtype": "Data",
+   "label": "Reading 5",
+   "oldfieldname": "reading_5",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_6", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reading 6", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_6", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "fieldname": "reading_6",
+   "fieldtype": "Data",
+   "label": "Reading 6",
+   "oldfieldname": "reading_6",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_7", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reading 7", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_7", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "fieldname": "reading_7",
+   "fieldtype": "Data",
+   "label": "Reading 7",
+   "oldfieldname": "reading_7",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_8", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reading 8", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_8", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "fieldname": "reading_8",
+   "fieldtype": "Data",
+   "label": "Reading 8",
+   "oldfieldname": "reading_8",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_9", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reading 9", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_9", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "fieldname": "reading_9",
+   "fieldtype": "Data",
+   "label": "Reading 9",
+   "oldfieldname": "reading_9",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "reading_10", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Reading 10", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "reading_10", 
-   "oldfieldtype": "Data", 
-   "permlevel": 0, 
-   "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
-  }, 
+   "fieldname": "reading_10",
+   "fieldtype": "Data",
+   "label": "Reading 10",
+   "oldfieldname": "reading_10",
+   "oldfieldtype": "Data"
+  },
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "Accepted", 
-   "fieldname": "status", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Status", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "status", 
-   "oldfieldtype": "Select", 
-   "options": "Accepted\nRejected", 
-   "permlevel": 0, 
-   "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
+   "columns": 2,
+   "default": "Accepted",
+   "fieldname": "status",
+   "fieldtype": "Select",
+   "in_list_view": 1,
+   "label": "Status",
+   "oldfieldname": "status",
+   "oldfieldtype": "Select",
+   "options": "Accepted\nRejected"
   }
- ], 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 1, 
- "image_view": 0, 
- "in_create": 0, 
-
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2016-11-16 03:55:50.046712", 
- "modified_by": "Administrator", 
- "module": "Stock", 
- "name": "Quality Inspection Reading", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "track_seen": 0
+ ],
+ "idx": 1,
+ "istable": 1,
+ "modified": "2019-07-11 18:48:12.667404",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Quality Inspection Reading",
+ "owner": "Administrator",
+ "permissions": [],
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.json b/erpnext/stock/doctype/stock_entry/stock_entry.json
index bbc54ec..ee563cb 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.json
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.json
@@ -1,2376 +1,693 @@
 {
-  "allow_copy": 0,
-  "allow_events_in_timeline": 0,
-  "allow_guest_to_view": 0,
-  "allow_import": 1,
-  "allow_rename": 0,
-  "autoname": "naming_series:",
-  "beta": 0,
-  "creation": "2013-04-09 11:43:55",
-  "custom": 0,
-  "docstatus": 0,
-  "doctype": "DocType",
-  "document_type": "Document",
-  "editable_grid": 0,
-  "engine": "InnoDB",
-  "fields": [
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "items_section",
-    "fieldtype": "Section Break",
-    "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": "",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldtype": "Section Break",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 1,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "default": "{purpose}",
-    "fetch_if_empty": 0,
-    "fieldname": "title",
-    "fieldtype": "Data",
-    "hidden": 1,
-    "ignore_user_permissions": 0,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 0,
-    "in_standard_filter": 0,
-    "label": "Title",
-    "length": 0,
-    "no_copy": 1,
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "default": "",
-    "fetch_if_empty": 0,
-    "fieldname": "naming_series",
-    "fieldtype": "Select",
-    "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": "Series",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "naming_series",
-    "oldfieldtype": "Select",
-    "options": "MAT-STE-.YYYY.-",
-    "permlevel": 0,
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 1,
-    "search_index": 0,
-    "set_only_once": 1,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "stock_entry_type",
-    "fieldtype": "Link",
-    "hidden": 0,
-    "ignore_user_permissions": 0,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 1,
-    "in_standard_filter": 1,
-    "label": "Stock Entry Type",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Stock Entry Type",
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 1,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose == 'Receive at Warehouse'",
-    "fetch_if_empty": 0,
-    "fieldname": "outgoing_stock_entry",
-    "fieldtype": "Link",
-    "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": "Stock Entry (Outward GIT)",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Stock Entry",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 1,
-    "collapsible": 0,
-    "columns": 0,
-    "default": "",
-    "fetch_from": "stock_entry_type.purpose",
-    "fetch_if_empty": 0,
-    "fieldname": "purpose",
-    "fieldtype": "Select",
-    "hidden": 1,
-    "ignore_user_permissions": 0,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 1,
-    "in_standard_filter": 0,
-    "label": "Purpose",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldname": "purpose",
-    "oldfieldtype": "Select",
-    "options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nMaterial Transfer for Manufacture\nMaterial Consumption for Manufacture\nManufacture\nRepack\nSend to Subcontractor\nSend to Warehouse\nReceive at Warehouse",
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "company",
-    "fieldtype": "Link",
-    "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": "Company",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldname": "company",
-    "oldfieldtype": "Link",
-    "options": "Company",
-    "permlevel": 0,
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 1,
-    "report_hide": 0,
-    "reqd": 1,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:in_list([\"Material Transfer for Manufacture\", \"Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
-    "fetch_if_empty": 0,
-    "fieldname": "work_order",
-    "fieldtype": "Link",
-    "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": "Work Order",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldname": "production_order",
-    "oldfieldtype": "Link",
-    "options": "Work Order",
-    "permlevel": 0,
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 1,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Send to Subcontractor\"",
-    "fetch_if_empty": 0,
-    "fieldname": "purchase_order",
-    "fieldtype": "Link",
-    "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": "Purchase Order",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Purchase Order",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Sales Return\"",
-    "fetch_if_empty": 0,
-    "fieldname": "delivery_note_no",
-    "fieldtype": "Link",
-    "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": "Delivery Note No",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "delivery_note_no",
-    "oldfieldtype": "Link",
-    "options": "Delivery Note",
-    "permlevel": 0,
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 1,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Sales Return\"",
-    "fetch_if_empty": 0,
-    "fieldname": "sales_invoice_no",
-    "fieldtype": "Link",
-    "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": "Sales Invoice No",
-    "length": 0,
-    "no_copy": 1,
-    "options": "Sales Invoice",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Purchase Return\"",
-    "fetch_if_empty": 0,
-    "fieldname": "purchase_receipt_no",
-    "fieldtype": "Link",
-    "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": "Purchase Receipt No",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "purchase_receipt_no",
-    "oldfieldtype": "Link",
-    "options": "Purchase Receipt",
-    "permlevel": 0,
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 1,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "col2",
-    "fieldtype": "Column Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldtype": "Column Break",
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "print_width": "50%",
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0,
-    "width": "50%"
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "default": "Today",
-    "depends_on": "",
-    "fetch_if_empty": 0,
-    "fieldname": "posting_date",
-    "fieldtype": "Date",
-    "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": "Posting Date",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "posting_date",
-    "oldfieldtype": "Date",
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 1,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "",
-    "fetch_if_empty": 0,
-    "fieldname": "posting_time",
-    "fieldtype": "Time",
-    "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": "Posting Time",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "posting_time",
-    "oldfieldtype": "Time",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.docstatus==0",
-    "fetch_if_empty": 0,
-    "fieldname": "set_posting_time",
-    "fieldtype": "Check",
-    "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": "Edit Posting Date and Time",
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "inspection_required",
-    "fieldtype": "Check",
-    "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": "Inspection Required",
-    "length": 0,
-    "no_copy": 0,
-    "options": "",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:in_list([\"Material Issue\", \"Material Transfer\", \"Manufacture\", \"Repack\", \t\t\t\t\t\"Send to Subcontractor\", \"Material Transfer for Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
-    "fetch_if_empty": 0,
-    "fieldname": "from_bom",
-    "fieldtype": "Check",
-    "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": "From BOM",
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval: doc.from_bom && (doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")",
-    "fetch_if_empty": 0,
-    "fieldname": "sb1",
-    "fieldtype": "Section Break",
-    "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": "",
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "from_bom",
-    "fetch_if_empty": 0,
-    "fieldname": "bom_no",
-    "fieldtype": "Link",
-    "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": "BOM No",
-    "length": 0,
-    "no_copy": 0,
-    "options": "BOM",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "from_bom",
-    "description": "As per Stock UOM",
-    "fetch_if_empty": 0,
-    "fieldname": "fg_completed_qty",
-    "fieldtype": "Float",
-    "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": "For Quantity",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldname": "fg_completed_qty",
-    "oldfieldtype": "Currency",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "cb1",
-    "fieldtype": "Column Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "default": "1",
-    "depends_on": "from_bom",
-    "description": "Including items for sub assemblies",
-    "fetch_if_empty": 0,
-    "fieldname": "use_multi_level_bom",
-    "fieldtype": "Check",
-    "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": "Use Multi-Level BOM",
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "from_bom",
-    "fetch_if_empty": 0,
-    "fieldname": "get_items",
-    "fieldtype": "Button",
-    "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": "Get Items",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldtype": "Button",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "section_break_12",
-    "fieldtype": "Section Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "from_warehouse",
-    "fieldtype": "Link",
-    "hidden": 0,
-    "ignore_user_permissions": 0,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 1,
-    "in_standard_filter": 1,
-    "label": "Default Source Warehouse",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "from_warehouse",
-    "oldfieldtype": "Link",
-    "options": "Warehouse",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "from_warehouse",
-    "fetch_if_empty": 0,
-    "fieldname": "source_warehouse_address",
-    "fieldtype": "Link",
-    "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": "Source Warehouse Address",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Address",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "source_address_display",
-    "fieldtype": "Small Text",
-    "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": "Source Warehouse Address",
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "cb0",
-    "fieldtype": "Column Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "to_warehouse",
-    "fieldtype": "Link",
-    "hidden": 0,
-    "ignore_user_permissions": 0,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 1,
-    "in_standard_filter": 1,
-    "label": "Default Target Warehouse",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "to_warehouse",
-    "oldfieldtype": "Link",
-    "options": "Warehouse",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "to_warehouse",
-    "fetch_if_empty": 0,
-    "fieldname": "target_warehouse_address",
-    "fieldtype": "Link",
-    "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": "Target Warehouse Name",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Address",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "target_address_display",
-    "fieldtype": "Small Text",
-    "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": "Target Warehouse Address",
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "sb0",
-    "fieldtype": "Section Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "options": "Simple",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "scan_barcode",
-    "fieldtype": "Data",
-    "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": "Scan Barcode",
-    "length": 0,
-    "no_copy": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "items",
-    "fieldtype": "Table",
-    "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": "Items",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldname": "mtn_details",
-    "oldfieldtype": "Table",
-    "options": "Stock Entry Detail",
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 1,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "description": "",
-    "fetch_if_empty": 0,
-    "fieldname": "get_stock_and_rate",
-    "fieldtype": "Button",
-    "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": "Update Rate and Availability",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldtype": "Button",
-    "options": "get_stock_and_rate",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "section_break_19",
-    "fieldtype": "Section Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "total_incoming_value",
-    "fieldtype": "Currency",
-    "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": "Total Incoming Value",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Company:company:default_currency",
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "column_break_22",
-    "fieldtype": "Column Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "total_outgoing_value",
-    "fieldtype": "Currency",
-    "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": "Total Outgoing Value",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Company:company:default_currency",
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "value_difference",
-    "fieldtype": "Currency",
-    "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": "Total Value Difference (Out - In)",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Company:company:default_currency",
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 0,
-    "print_hide_if_no_value": 1,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 1,
-    "collapsible_depends_on": "total_additional_costs",
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "additional_costs_section",
-    "fieldtype": "Section Break",
-    "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": "Additional Costs",
-    "length": 0,
-    "no_copy": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "additional_costs",
-    "fieldtype": "Table",
-    "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": "Additional Costs",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Landed Cost Taxes and Charges",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "total_additional_costs",
-    "fieldtype": "Currency",
-    "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": "Total Additional Costs",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Company:company:default_currency",
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 0,
-    "print_hide_if_no_value": 1,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 1,
-    "columns": 0,
-    "depends_on": "eval: in_list([\"Sales Return\", \"Purchase Return\", \"Send to Subcontractor\"], doc.purpose)",
-    "fetch_if_empty": 0,
-    "fieldname": "contact_section",
-    "fieldtype": "Section Break",
-    "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": "Customer or Supplier Details",
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
-    "fetch_if_empty": 0,
-    "fieldname": "supplier",
-    "fieldtype": "Link",
-    "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": "Supplier",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "supplier",
-    "oldfieldtype": "Link",
-    "options": "Supplier",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 1,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
-    "fetch_if_empty": 0,
-    "fieldname": "supplier_name",
-    "fieldtype": "Data",
-    "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": "Supplier Name",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "supplier_name",
-    "oldfieldtype": "Data",
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
-    "fetch_if_empty": 0,
-    "fieldname": "supplier_address",
-    "fieldtype": "Link",
-    "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": "Supplier Address",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "supplier_address",
-    "oldfieldtype": "Small Text",
-    "options": "Address",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "address_display",
-    "fieldtype": "Small Text",
-    "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": "Address",
-    "length": 0,
-    "no_copy": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "column_break_39",
-    "fieldtype": "Column Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Sales Return\"",
-    "fetch_if_empty": 0,
-    "fieldname": "customer",
-    "fieldtype": "Link",
-    "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": "Customer",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "customer",
-    "oldfieldtype": "Link",
-    "options": "Customer",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 1,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Sales Return\"",
-    "fetch_if_empty": 0,
-    "fieldname": "customer_name",
-    "fieldtype": "Data",
-    "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": "Customer Name",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "customer_name",
-    "oldfieldtype": "Data",
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "eval:doc.purpose==\"Sales Return\"",
-    "fetch_if_empty": 0,
-    "fieldname": "customer_address",
-    "fieldtype": "Small Text",
-    "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": "Customer Address",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "customer_address",
-    "oldfieldtype": "Small Text",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 1,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "printing_settings",
-    "fieldtype": "Section Break",
-    "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": "Printing Settings",
-    "length": 0,
-    "no_copy": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 1,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "select_print_heading",
-    "fieldtype": "Link",
-    "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": "Print Heading",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldname": "select_print_heading",
-    "oldfieldtype": "Link",
-    "options": "Print Heading",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "letter_head",
-    "fieldtype": "Link",
-    "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": "Letter Head",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Letter Head",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 1,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "more_info",
-    "fieldtype": "Section Break",
-    "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": "More Information",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldtype": "Section Break",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-     "allow_bulk_edit": 0,
-     "allow_in_quick_entry": 0,
-     "allow_on_submit": 0,
-     "bold": 0,
-     "collapsible": 0,
-     "columns": 0,
-     "fetch_if_empty": 0,
-     "fieldname": "is_opening",
-     "fieldtype": "Select",
-     "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": "Is Opening",
-     "length": 0,
-     "no_copy": 0,
-     "options": "No\nYes",
-     "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,
-     "translatable": 0,
-     "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "project",
-    "fieldtype": "Link",
-    "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": "Project",
-    "length": 0,
-    "no_copy": 0,
-    "oldfieldtype": "Link",
-    "options": "Project",
-    "permlevel": 0,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "remarks",
-    "fieldtype": "Text",
-    "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": "Remarks",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "remarks",
-    "oldfieldtype": "Text",
-    "permlevel": 0,
-    "print_hide": 1,
-    "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,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "col5",
-    "fieldtype": "Column Break",
-    "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,
-    "length": 0,
-    "no_copy": 0,
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 0,
-    "print_width": "50%",
-    "read_only": 0,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0,
-    "width": "50%"
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "",
-    "fetch_if_empty": 0,
-    "fieldname": "per_transferred",
-    "fieldtype": "Percent",
-    "hidden": 0,
-    "ignore_user_permissions": 0,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 1,
-    "in_standard_filter": 0,
-    "label": "Per Transferred",
-    "length": 0,
-    "no_copy": 1,
-    "options": "",
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "depends_on": "total_amount",
-    "fetch_if_empty": 0,
-    "fieldname": "total_amount",
-    "fieldtype": "Currency",
-    "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": "Total Amount",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Company:company:default_currency",
-    "permlevel": 0,
-    "print_hide": 0,
-    "print_hide_if_no_value": 1,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "job_card",
-    "fieldtype": "Link",
-    "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": "Job Card",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Job Card",
-    "permlevel": 0,
-    "precision": "",
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "amended_from",
-    "fieldtype": "Link",
-    "hidden": 0,
-    "ignore_user_permissions": 1,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 0,
-    "in_standard_filter": 0,
-    "label": "Amended From",
-    "length": 0,
-    "no_copy": 1,
-    "oldfieldname": "amended_from",
-    "oldfieldtype": "Link",
-    "options": "Stock Entry",
-    "permlevel": 0,
-    "print_hide": 1,
-    "print_hide_if_no_value": 0,
-    "read_only": 1,
-    "remember_last_selected_value": 0,
-    "report_hide": 0,
-    "reqd": 0,
-    "search_index": 0,
-    "set_only_once": 0,
-    "translatable": 0,
-    "unique": 0
-   },
-   {
-    "allow_bulk_edit": 0,
-    "allow_in_quick_entry": 0,
-    "allow_on_submit": 0,
-    "bold": 0,
-    "collapsible": 0,
-    "columns": 0,
-    "fetch_if_empty": 0,
-    "fieldname": "credit_note",
-    "fieldtype": "Link",
-    "hidden": 1,
-    "ignore_user_permissions": 0,
-    "ignore_xss_filter": 0,
-    "in_filter": 0,
-    "in_global_search": 0,
-    "in_list_view": 0,
-    "in_standard_filter": 0,
-    "label": "Credit Note",
-    "length": 0,
-    "no_copy": 0,
-    "options": "Journal Entry",
-    "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,
-    "translatable": 0,
-    "unique": 0
-   }
-  ],
-  "has_web_view": 0,
-  "hide_toolbar": 0,
-  "icon": "fa fa-file-text",
-  "idx": 1,
-  "in_create": 0,
-  "is_submittable": 1,
-  "issingle": 0,
-  "istable": 0,
-  "max_attachments": 0,
-  "modified": "2019-05-23 12:24:46.439626",
-  "modified_by": "Administrator",
-  "module": "Stock",
-  "name": "Stock Entry",
-  "owner": "Administrator",
-  "permissions": [
-   {
-    "amend": 1,
-    "cancel": 1,
-    "create": 1,
-    "delete": 1,
-    "email": 1,
-    "export": 0,
-    "if_owner": 0,
-    "import": 0,
-    "permlevel": 0,
-    "print": 1,
-    "read": 1,
-    "report": 1,
-    "role": "Stock User",
-    "set_user_permissions": 0,
-    "share": 1,
-    "submit": 1,
-    "write": 1
-   },
-   {
-    "amend": 1,
-    "cancel": 1,
-    "create": 1,
-    "delete": 1,
-    "email": 1,
-    "export": 0,
-    "if_owner": 0,
-    "import": 0,
-    "permlevel": 0,
-    "print": 1,
-    "read": 1,
-    "report": 1,
-    "role": "Manufacturing User",
-    "set_user_permissions": 0,
-    "share": 1,
-    "submit": 1,
-    "write": 1
-   },
-   {
-    "amend": 1,
-    "cancel": 1,
-    "create": 1,
-    "delete": 1,
-    "email": 1,
-    "export": 0,
-    "if_owner": 0,
-    "import": 0,
-    "permlevel": 0,
-    "print": 1,
-    "read": 1,
-    "report": 1,
-    "role": "Manufacturing Manager",
-    "set_user_permissions": 0,
-    "share": 1,
-    "submit": 1,
-    "write": 1
-   },
-   {
-    "amend": 1,
-    "cancel": 1,
-    "create": 1,
-    "delete": 1,
-    "email": 1,
-    "export": 1,
-    "if_owner": 0,
-    "import": 1,
-    "permlevel": 0,
-    "print": 1,
-    "read": 1,
-    "report": 1,
-    "role": "Stock Manager",
-    "set_user_permissions": 1,
-    "share": 1,
-    "submit": 1,
-    "write": 1
-   }
-  ],
-  "quick_entry": 0,
-  "read_only": 0,
-  "search_fields": "posting_date, from_warehouse, to_warehouse, purpose, remarks",
-  "show_name_in_global_search": 1,
-  "sort_field": "modified",
-  "sort_order": "DESC",
-  "title_field": "title",
-  "track_changes": 1,
-  "track_seen": 0,
-  "track_views": 0
- }
\ No newline at end of file
+ "allow_import": 1,
+ "autoname": "naming_series:",
+ "creation": "2013-04-09 11:43:55",
+ "doctype": "DocType",
+ "document_type": "Document",
+ "engine": "InnoDB",
+ "field_order": [
+  "items_section",
+  "title",
+  "naming_series",
+  "stock_entry_type",
+  "outgoing_stock_entry",
+  "purpose",
+  "company",
+  "work_order",
+  "purchase_order",
+  "delivery_note_no",
+  "sales_invoice_no",
+  "purchase_receipt_no",
+  "col2",
+  "posting_date",
+  "posting_time",
+  "set_posting_time",
+  "inspection_required",
+  "from_bom",
+  "sb1",
+  "bom_no",
+  "fg_completed_qty",
+  "cb1",
+  "use_multi_level_bom",
+  "get_items",
+  "section_break_12",
+  "from_warehouse",
+  "source_warehouse_address",
+  "source_address_display",
+  "cb0",
+  "to_warehouse",
+  "target_warehouse_address",
+  "target_address_display",
+  "sb0",
+  "scan_barcode",
+  "items",
+  "get_stock_and_rate",
+  "section_break_19",
+  "total_incoming_value",
+  "column_break_22",
+  "total_outgoing_value",
+  "value_difference",
+  "additional_costs_section",
+  "additional_costs",
+  "total_additional_costs",
+  "contact_section",
+  "supplier",
+  "supplier_name",
+  "supplier_address",
+  "address_display",
+  "column_break_39",
+  "customer",
+  "customer_name",
+  "customer_address",
+  "accounting_dimensions_section",
+  "project",
+  "dimension_col_break",
+  "printing_settings",
+  "select_print_heading",
+  "letter_head",
+  "more_info",
+  "is_opening",
+  "remarks",
+  "col5",
+  "per_transferred",
+  "total_amount",
+  "job_card",
+  "amended_from",
+  "credit_note"
+ ],
+ "fields": [
+  {
+   "fieldname": "items_section",
+   "fieldtype": "Section Break",
+   "oldfieldtype": "Section Break"
+  },
+  {
+   "allow_on_submit": 1,
+   "default": "{purpose}",
+   "fieldname": "title",
+   "fieldtype": "Data",
+   "hidden": 1,
+   "label": "Title",
+   "no_copy": 1,
+   "print_hide": 1
+  },
+  {
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Series",
+   "no_copy": 1,
+   "oldfieldname": "naming_series",
+   "oldfieldtype": "Select",
+   "options": "MAT-STE-.YYYY.-",
+   "print_hide": 1,
+   "reqd": 1,
+   "set_only_once": 1
+  },
+  {
+   "fieldname": "stock_entry_type",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Stock Entry Type",
+   "options": "Stock Entry Type",
+   "reqd": 1
+  },
+  {
+   "depends_on": "eval:doc.purpose == 'Receive at Warehouse'",
+   "fieldname": "outgoing_stock_entry",
+   "fieldtype": "Link",
+   "label": "Stock Entry (Outward GIT)",
+   "options": "Stock Entry"
+  },
+  {
+   "bold": 1,
+   "fetch_from": "stock_entry_type.purpose",
+   "fieldname": "purpose",
+   "fieldtype": "Select",
+   "hidden": 1,
+   "in_list_view": 1,
+   "label": "Purpose",
+   "oldfieldname": "purpose",
+   "oldfieldtype": "Select",
+   "options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nMaterial Transfer for Manufacture\nMaterial Consumption for Manufacture\nManufacture\nRepack\nSend to Subcontractor\nSend to Warehouse\nReceive at Warehouse",
+   "read_only": 1
+  },
+  {
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "label": "Company",
+   "oldfieldname": "company",
+   "oldfieldtype": "Link",
+   "options": "Company",
+   "print_hide": 1,
+   "remember_last_selected_value": 1,
+   "reqd": 1
+  },
+  {
+   "depends_on": "eval:in_list([\"Material Transfer for Manufacture\", \"Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
+   "fieldname": "work_order",
+   "fieldtype": "Link",
+   "label": "Work Order",
+   "oldfieldname": "production_order",
+   "oldfieldtype": "Link",
+   "options": "Work Order",
+   "print_hide": 1,
+   "search_index": 1
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Send to Subcontractor\"",
+   "fieldname": "purchase_order",
+   "fieldtype": "Link",
+   "label": "Purchase Order",
+   "options": "Purchase Order"
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Sales Return\"",
+   "fieldname": "delivery_note_no",
+   "fieldtype": "Link",
+   "label": "Delivery Note No",
+   "no_copy": 1,
+   "oldfieldname": "delivery_note_no",
+   "oldfieldtype": "Link",
+   "options": "Delivery Note",
+   "print_hide": 1,
+   "search_index": 1
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Sales Return\"",
+   "fieldname": "sales_invoice_no",
+   "fieldtype": "Link",
+   "label": "Sales Invoice No",
+   "no_copy": 1,
+   "options": "Sales Invoice",
+   "print_hide": 1
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Purchase Return\"",
+   "fieldname": "purchase_receipt_no",
+   "fieldtype": "Link",
+   "label": "Purchase Receipt No",
+   "no_copy": 1,
+   "oldfieldname": "purchase_receipt_no",
+   "oldfieldtype": "Link",
+   "options": "Purchase Receipt",
+   "print_hide": 1,
+   "search_index": 1
+  },
+  {
+   "fieldname": "col2",
+   "fieldtype": "Column Break",
+   "oldfieldtype": "Column Break",
+   "print_width": "50%",
+   "width": "50%"
+  },
+  {
+   "default": "Today",
+   "fieldname": "posting_date",
+   "fieldtype": "Date",
+   "label": "Posting Date",
+   "no_copy": 1,
+   "oldfieldname": "posting_date",
+   "oldfieldtype": "Date",
+   "search_index": 1
+  },
+  {
+   "fieldname": "posting_time",
+   "fieldtype": "Time",
+   "label": "Posting Time",
+   "no_copy": 1,
+   "oldfieldname": "posting_time",
+   "oldfieldtype": "Time",
+   "print_hide": 1
+  },
+  {
+   "default": "0",
+   "depends_on": "eval:doc.docstatus==0",
+   "fieldname": "set_posting_time",
+   "fieldtype": "Check",
+   "label": "Edit Posting Date and Time",
+   "print_hide": 1
+  },
+  {
+   "default": "0",
+   "fieldname": "inspection_required",
+   "fieldtype": "Check",
+   "label": "Inspection Required"
+  },
+  {
+   "default": "0",
+   "depends_on": "eval:in_list([\"Material Issue\", \"Material Transfer\", \"Manufacture\", \"Repack\", \t\t\t\t\t\"Send to Subcontractor\", \"Material Transfer for Manufacture\", \"Material Consumption for Manufacture\"], doc.purpose)",
+   "fieldname": "from_bom",
+   "fieldtype": "Check",
+   "label": "From BOM",
+   "print_hide": 1
+  },
+  {
+   "depends_on": "eval: doc.from_bom && (doc.purpose!==\"Sales Return\" && doc.purpose!==\"Purchase Return\")",
+   "fieldname": "sb1",
+   "fieldtype": "Section Break"
+  },
+  {
+   "depends_on": "from_bom",
+   "fieldname": "bom_no",
+   "fieldtype": "Link",
+   "label": "BOM No",
+   "options": "BOM"
+  },
+  {
+   "depends_on": "from_bom",
+   "description": "As per Stock UOM",
+   "fieldname": "fg_completed_qty",
+   "fieldtype": "Float",
+   "label": "For Quantity",
+   "oldfieldname": "fg_completed_qty",
+   "oldfieldtype": "Currency",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "cb1",
+   "fieldtype": "Column Break"
+  },
+  {
+   "default": "1",
+   "depends_on": "from_bom",
+   "description": "Including items for sub assemblies",
+   "fieldname": "use_multi_level_bom",
+   "fieldtype": "Check",
+   "label": "Use Multi-Level BOM",
+   "print_hide": 1
+  },
+  {
+   "depends_on": "from_bom",
+   "fieldname": "get_items",
+   "fieldtype": "Button",
+   "label": "Get Items",
+   "oldfieldtype": "Button",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "section_break_12",
+   "fieldtype": "Section Break"
+  },
+  {
+   "fieldname": "from_warehouse",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Default Source Warehouse",
+   "no_copy": 1,
+   "oldfieldname": "from_warehouse",
+   "oldfieldtype": "Link",
+   "options": "Warehouse",
+   "print_hide": 1
+  },
+  {
+   "depends_on": "from_warehouse",
+   "fieldname": "source_warehouse_address",
+   "fieldtype": "Link",
+   "label": "Source Warehouse Address",
+   "options": "Address"
+  },
+  {
+   "fieldname": "source_address_display",
+   "fieldtype": "Small Text",
+   "label": "Source Warehouse Address",
+   "read_only": 1
+  },
+  {
+   "fieldname": "cb0",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "to_warehouse",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Default Target Warehouse",
+   "no_copy": 1,
+   "oldfieldname": "to_warehouse",
+   "oldfieldtype": "Link",
+   "options": "Warehouse",
+   "print_hide": 1
+  },
+  {
+   "depends_on": "to_warehouse",
+   "fieldname": "target_warehouse_address",
+   "fieldtype": "Link",
+   "label": "Target Warehouse Name",
+   "options": "Address"
+  },
+  {
+   "fieldname": "target_address_display",
+   "fieldtype": "Small Text",
+   "label": "Target Warehouse Address",
+   "read_only": 1
+  },
+  {
+   "fieldname": "sb0",
+   "fieldtype": "Section Break",
+   "options": "Simple"
+  },
+  {
+   "fieldname": "scan_barcode",
+   "fieldtype": "Data",
+   "label": "Scan Barcode"
+  },
+  {
+   "fieldname": "items",
+   "fieldtype": "Table",
+   "label": "Items",
+   "oldfieldname": "mtn_details",
+   "oldfieldtype": "Table",
+   "options": "Stock Entry Detail",
+   "reqd": 1
+  },
+  {
+   "fieldname": "get_stock_and_rate",
+   "fieldtype": "Button",
+   "label": "Update Rate and Availability",
+   "oldfieldtype": "Button",
+   "options": "get_stock_and_rate",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "section_break_19",
+   "fieldtype": "Section Break",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "total_incoming_value",
+   "fieldtype": "Currency",
+   "label": "Total Incoming Value",
+   "options": "Company:company:default_currency",
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_22",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "total_outgoing_value",
+   "fieldtype": "Currency",
+   "label": "Total Outgoing Value",
+   "options": "Company:company:default_currency",
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "fieldname": "value_difference",
+   "fieldtype": "Currency",
+   "label": "Total Value Difference (Out - In)",
+   "options": "Company:company:default_currency",
+   "print_hide_if_no_value": 1,
+   "read_only": 1
+  },
+  {
+   "collapsible": 1,
+   "collapsible_depends_on": "total_additional_costs",
+   "fieldname": "additional_costs_section",
+   "fieldtype": "Section Break",
+   "label": "Additional Costs"
+  },
+  {
+   "fieldname": "additional_costs",
+   "fieldtype": "Table",
+   "label": "Additional Costs",
+   "options": "Landed Cost Taxes and Charges"
+  },
+  {
+   "fieldname": "total_additional_costs",
+   "fieldtype": "Currency",
+   "label": "Total Additional Costs",
+   "options": "Company:company:default_currency",
+   "print_hide_if_no_value": 1,
+   "read_only": 1
+  },
+  {
+   "collapsible": 1,
+   "depends_on": "eval: in_list([\"Sales Return\", \"Purchase Return\", \"Send to Subcontractor\"], doc.purpose)",
+   "fieldname": "contact_section",
+   "fieldtype": "Section Break",
+   "label": "Customer or Supplier Details"
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
+   "fieldname": "supplier",
+   "fieldtype": "Link",
+   "label": "Supplier",
+   "no_copy": 1,
+   "oldfieldname": "supplier",
+   "oldfieldtype": "Link",
+   "options": "Supplier",
+   "print_hide": 1
+  },
+  {
+   "bold": 1,
+   "depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
+   "fieldname": "supplier_name",
+   "fieldtype": "Data",
+   "label": "Supplier Name",
+   "no_copy": 1,
+   "oldfieldname": "supplier_name",
+   "oldfieldtype": "Data",
+   "read_only": 1
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Purchase Return\" || doc.purpose==\"Send to Subcontractor\"",
+   "fieldname": "supplier_address",
+   "fieldtype": "Link",
+   "label": "Supplier Address",
+   "no_copy": 1,
+   "oldfieldname": "supplier_address",
+   "oldfieldtype": "Small Text",
+   "options": "Address"
+  },
+  {
+   "fieldname": "address_display",
+   "fieldtype": "Small Text",
+   "label": "Address"
+  },
+  {
+   "fieldname": "column_break_39",
+   "fieldtype": "Column Break"
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Sales Return\"",
+   "fieldname": "customer",
+   "fieldtype": "Link",
+   "label": "Customer",
+   "no_copy": 1,
+   "oldfieldname": "customer",
+   "oldfieldtype": "Link",
+   "options": "Customer",
+   "print_hide": 1
+  },
+  {
+   "bold": 1,
+   "depends_on": "eval:doc.purpose==\"Sales Return\"",
+   "fieldname": "customer_name",
+   "fieldtype": "Data",
+   "label": "Customer Name",
+   "no_copy": 1,
+   "oldfieldname": "customer_name",
+   "oldfieldtype": "Data",
+   "read_only": 1
+  },
+  {
+   "depends_on": "eval:doc.purpose==\"Sales Return\"",
+   "fieldname": "customer_address",
+   "fieldtype": "Small Text",
+   "label": "Customer Address",
+   "no_copy": 1,
+   "oldfieldname": "customer_address",
+   "oldfieldtype": "Small Text"
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "printing_settings",
+   "fieldtype": "Section Break",
+   "label": "Printing Settings"
+  },
+  {
+   "allow_on_submit": 1,
+   "fieldname": "select_print_heading",
+   "fieldtype": "Link",
+   "label": "Print Heading",
+   "oldfieldname": "select_print_heading",
+   "oldfieldtype": "Link",
+   "options": "Print Heading"
+  },
+  {
+   "fieldname": "letter_head",
+   "fieldtype": "Link",
+   "label": "Letter Head",
+   "options": "Letter Head"
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "more_info",
+   "fieldtype": "Section Break",
+   "label": "More Information",
+   "oldfieldtype": "Section Break"
+  },
+  {
+   "fieldname": "is_opening",
+   "fieldtype": "Select",
+   "label": "Is Opening",
+   "options": "No\nYes"
+  },
+  {
+   "fieldname": "project",
+   "fieldtype": "Link",
+   "label": "Project",
+   "oldfieldtype": "Link",
+   "options": "Project"
+  },
+  {
+   "fieldname": "remarks",
+   "fieldtype": "Text",
+   "label": "Remarks",
+   "no_copy": 1,
+   "oldfieldname": "remarks",
+   "oldfieldtype": "Text",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "col5",
+   "fieldtype": "Column Break",
+   "print_width": "50%",
+   "width": "50%"
+  },
+  {
+   "fieldname": "per_transferred",
+   "fieldtype": "Percent",
+   "in_list_view": 1,
+   "label": "Per Transferred",
+   "no_copy": 1,
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "depends_on": "total_amount",
+   "fieldname": "total_amount",
+   "fieldtype": "Currency",
+   "label": "Total Amount",
+   "options": "Company:company:default_currency",
+   "print_hide_if_no_value": 1,
+   "read_only": 1
+  },
+  {
+   "fieldname": "job_card",
+   "fieldtype": "Link",
+   "label": "Job Card",
+   "options": "Job Card",
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "fieldname": "amended_from",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "label": "Amended From",
+   "no_copy": 1,
+   "oldfieldname": "amended_from",
+   "oldfieldtype": "Link",
+   "options": "Stock Entry",
+   "print_hide": 1,
+   "read_only": 1
+  },
+  {
+   "fieldname": "credit_note",
+   "fieldtype": "Link",
+   "hidden": 1,
+   "label": "Credit Note",
+   "options": "Journal Entry"
+  },
+  {
+   "collapsible": 1,
+   "fieldname": "accounting_dimensions_section",
+   "fieldtype": "Section Break",
+   "label": "Accounting Dimensions"
+  },
+  {
+   "fieldname": "dimension_col_break",
+   "fieldtype": "Column Break"
+  }
+ ],
+ "icon": "fa fa-file-text",
+ "idx": 1,
+ "is_submittable": 1,
+ "modified": "2019-07-14 17:41:39.257508",
+ "modified_by": "Administrator",
+ "module": "Stock",
+ "name": "Stock Entry",
+ "owner": "Administrator",
+ "permissions": [
+  {
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Stock User",
+   "share": 1,
+   "submit": 1,
+   "write": 1
+  },
+  {
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Manufacturing User",
+   "share": 1,
+   "submit": 1,
+   "write": 1
+  },
+  {
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Manufacturing Manager",
+   "share": 1,
+   "submit": 1,
+   "write": 1
+  },
+  {
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "import": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Stock Manager",
+   "set_user_permissions": 1,
+   "share": 1,
+   "submit": 1,
+   "write": 1
+  }
+ ],
+ "search_fields": "posting_date, from_warehouse, to_warehouse, purpose, remarks",
+ "show_name_in_global_search": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "title",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.json b/erpnext/stock/doctype/stock_settings/stock_settings.json
index c989907..f43390f 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.json
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.json
@@ -255,7 +255,7 @@
    "columns": 0,
    "description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.",
    "fetch_if_empty": 0,
-   "fieldname": "tolerance",
+   "fieldname": "over_delivery_receipt_allowance",
    "fieldtype": "Float",
    "hidden": 0,
    "ignore_user_permissions": 0,
@@ -264,7 +264,7 @@
    "in_global_search": 0,
    "in_list_view": 0,
    "in_standard_filter": 0,
-   "label": "Limit Percent",
+   "label": "Over Delivery/Receipt Allowance (%)",
    "length": 0,
    "no_copy": 0,
    "permlevel": 0,
@@ -918,7 +918,7 @@
  "issingle": 1,
  "istable": 0,
  "max_attachments": 0,
- "modified": "2019-06-18 01:19:07.738045",
+ "modified": "2019-07-04 01:19:07.738045",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Stock Settings",
diff --git a/erpnext/stock/stock_balance.py b/erpnext/stock/stock_balance.py
index 4d07a0e..d68f979 100644
--- a/erpnext/stock/stock_balance.py
+++ b/erpnext/stock/stock_balance.py
@@ -110,7 +110,7 @@
 	return flt(reserved_qty[0][0]) if reserved_qty else 0
 
 def get_indented_qty(item_code, warehouse):
-	indented_qty = frappe.db.sql("""select sum(mr_item.qty - mr_item.ordered_qty)
+	indented_qty = frappe.db.sql("""select sum((mr_item.qty - mr_item.ordered_qty) * mr_item.conversion_factor)
 		from `tabMaterial Request Item` mr_item, `tabMaterial Request` mr
 		where mr_item.item_code=%s and mr_item.warehouse=%s
 		and mr_item.qty > mr_item.ordered_qty and mr_item.parent=mr.name
diff --git a/erpnext/support/doctype/issue/issue.js b/erpnext/support/doctype/issue/issue.js
index 2d9650c..aec9db9 100644
--- a/erpnext/support/doctype/issue/issue.js
+++ b/erpnext/support/doctype/issue/issue.js
@@ -2,6 +2,12 @@
 	onload: function(frm) {
 		frm.email_field = "raised_by";
 
+		frappe.db.get_value("Support Settings", {name: "Support Settings"}, "allow_resetting_service_level_agreement", (r) => {
+			if (!r.allow_resetting_service_level_agreement) {
+				frm.set_df_property("reset_service_level_agreement", "hidden", 1) ;
+			}
+		});
+
 		if (frm.doc.service_level_agreement) {
 			frappe.call({
 				method: "erpnext.support.doctype.service_level_agreement.service_level_agreement.get_service_level_agreement_filters",
@@ -73,6 +79,42 @@
 		}
 	},
 
+	reset_service_level_agreement: function(frm) {
+		let reset_sla = new frappe.ui.Dialog({
+			title: __("Reset Service Level Agreement"),
+			fields: [
+				{
+					fieldtype: "Data",
+					fieldname: "reason",
+					label: __("Reason"),
+					reqd: 1
+				}
+			],
+			primary_action_label: __("Reset"),
+			primary_action: (values) => {
+				reset_sla.disable_primary_action();
+				reset_sla.hide();
+				reset_sla.clear();
+
+				frappe.show_alert({
+					indicator: 'green',
+					message: __('Resetting Service Level Agreement.')
+				});
+
+				frm.call("reset_service_level_agreement", {
+					reason: values.reason,
+					user: frappe.session.user_email
+				}, () => {
+					reset_sla.enable_primary_action();
+					frm.refresh();
+					frappe.msgprint(__("Service Level Agreement Reset."));
+				});
+			}
+		});
+
+		reset_sla.show();
+	},
+
 	timeline_refresh: function(frm) {
 		// create button for "Help Article"
 		if(frappe.model.can_create('Help Article')) {
diff --git a/erpnext/support/doctype/issue/issue.json b/erpnext/support/doctype/issue/issue.json
index 72153dc..1e5d5f9 100644
--- a/erpnext/support/doctype/issue/issue.json
+++ b/erpnext/support/doctype/issue/issue.json
@@ -1,368 +1,384 @@
 {
- "allow_import": 1,
- "allow_rename": 1,
- "autoname": "naming_series:",
- "creation": "2013-02-01 10:36:25",
- "doctype": "DocType",
- "document_type": "Setup",
- "engine": "InnoDB",
- "field_order": [
-  "subject_section",
-  "naming_series",
-  "subject",
-  "customer",
-  "raised_by",
-  "cb00",
-  "status",
-  "priority",
-  "issue_type",
-  "sb_details",
-  "description",
-  "service_level_section",
-  "service_level_agreement",
-  "response_by",
-  "response_by_variance",
-  "cb",
-  "agreement_fulfilled",
-  "resolution_by",
-  "resolution_by_variance",
-  "response",
-  "mins_to_first_response",
-  "first_responded_on",
-  "additional_info",
-  "lead",
-  "contact",
-  "email_account",
-  "column_break_16",
-  "customer_name",
-  "project",
-  "company",
-  "section_break_19",
-  "resolution_details",
-  "column_break1",
-  "opening_date",
-  "opening_time",
-  "resolution_date",
-  "content_type",
-  "attachment",
-  "via_customer_portal"
- ],
- "fields": [
-  {
-   "fieldname": "subject_section",
-   "fieldtype": "Section Break",
-   "label": "Subject",
-   "options": "fa fa-flag"
-  },
-  {
-   "fieldname": "naming_series",
-   "fieldtype": "Select",
-   "label": "Series",
-   "no_copy": 1,
-   "options": "ISS-.YYYY.-",
-   "print_hide": 1,
-   "set_only_once": 1
-  },
-  {
-   "bold": 1,
-   "fieldname": "subject",
-   "fieldtype": "Data",
-   "in_global_search": 1,
-   "label": "Subject",
-   "reqd": 1,
-   "in_standard_filter": 1
-  },
-  {
-   "fieldname": "customer",
-   "fieldtype": "Link",
-   "in_global_search": 1,
-   "label": "Customer",
-   "oldfieldname": "customer",
-   "oldfieldtype": "Link",
-   "options": "Customer",
-   "print_hide": 1,
-   "search_index": 1
-  },
-  {
-   "bold": 1,
-   "depends_on": "eval:doc.__islocal",
-   "fieldname": "raised_by",
-   "fieldtype": "Data",
-   "in_global_search": 1,
-   "in_list_view": 1,
-   "label": "Raised By (Email)",
-   "oldfieldname": "raised_by",
-   "oldfieldtype": "Data",
-   "options": "Email"
-  },
-  {
-   "fieldname": "cb00",
-   "fieldtype": "Column Break"
-  },
-  {
-   "default": "Open",
-   "fieldname": "status",
-   "fieldtype": "Select",
-   "in_list_view": 1,
-   "in_standard_filter": 1,
-   "label": "Status",
-   "no_copy": 1,
-   "oldfieldname": "status",
-   "oldfieldtype": "Select",
-   "options": "Open\nReplied\nHold\nClosed",
-   "search_index": 1
-  },
-  {
-   "default": "Medium",
-   "fieldname": "priority",
-   "fieldtype": "Link",
-   "in_standard_filter": 1,
-   "label": "Priority",
-   "options": "Issue Priority"
-  },
-  {
-   "fieldname": "issue_type",
-   "fieldtype": "Link",
-   "label": "Issue Type",
-   "options": "Issue Type"
-  },
-  {
-   "collapsible": 1,
-   "collapsible_depends_on": "eval:doc.status!=\"Closed\"",
-   "fieldname": "sb_details",
-   "fieldtype": "Section Break",
-   "label": "Details"
-  },
-  {
-   "bold": 1,
-   "fieldname": "description",
-   "fieldtype": "Text Editor",
-   "in_global_search": 1,
-   "label": "Description",
-   "oldfieldname": "problem_description",
-   "oldfieldtype": "Text"
-  },
-  {
-   "collapsible": 1,
-   "fieldname": "service_level_section",
-   "fieldtype": "Section Break",
-   "label": "Service Level"
-  },
-  {
-   "fieldname": "service_level_agreement",
-   "fieldtype": "Link",
-   "label": "Service Level Agreement",
-   "options": "Service Level Agreement"
-  },
-  {
-   "fieldname": "response_by",
-   "fieldtype": "Datetime",
-   "label": "Response By",
-   "read_only": 1
-  },
-  {
-   "collapsible": 1,
-   "fieldname": "cb",
-   "fieldtype": "Column Break",
-   "options": "fa fa-pushpin",
-   "read_only": 1
-  },
-  {
-   "fieldname": "resolution_by",
-   "fieldtype": "Datetime",
-   "label": "Resolution By",
-   "read_only": 1
-  },
-  {
-   "collapsible": 1,
-   "fieldname": "response",
-   "fieldtype": "Section Break",
-   "label": "Response"
-  },
-  {
-   "bold": 1,
-   "fieldname": "mins_to_first_response",
-   "fieldtype": "Float",
-   "label": "Mins to First Response",
-   "read_only": 1
-  },
-  {
-   "fieldname": "first_responded_on",
-   "fieldtype": "Datetime",
-   "label": "First Responded On"
-  },
-  {
-   "collapsible": 1,
-   "fieldname": "additional_info",
-   "fieldtype": "Section Break",
-   "label": "Reference",
-   "options": "fa fa-pushpin",
-   "read_only": 1
-  },
-  {
-   "fieldname": "lead",
-   "fieldtype": "Link",
-   "label": "Lead",
-   "options": "Lead"
-  },
-  {
-   "fieldname": "contact",
-   "fieldtype": "Link",
-   "label": "Contact",
-   "options": "Contact"
-  },
-  {
-   "fieldname": "email_account",
-   "fieldtype": "Link",
-   "label": "Email Account",
-   "options": "Email Account"
-  },
-  {
-   "fieldname": "column_break_16",
-   "fieldtype": "Column Break"
-  },
-  {
-   "bold": 1,
-   "fieldname": "customer_name",
-   "fieldtype": "Data",
-   "label": "Customer Name",
-   "oldfieldname": "customer_name",
-   "oldfieldtype": "Data",
-   "read_only": 1
-  },
-  {
-   "fieldname": "project",
-   "fieldtype": "Link",
-   "label": "Project",
-   "options": "Project"
-  },
-  {
-   "fieldname": "company",
-   "fieldtype": "Link",
-   "label": "Company",
-   "options": "Company",
-   "print_hide": 1
-  },
-  {
-   "collapsible": 1,
-   "fieldname": "section_break_19",
-   "fieldtype": "Section Break",
-   "label": "Resolution"
-  },
-  {
-   "depends_on": "eval:!doc.__islocal",
-   "fieldname": "resolution_details",
-   "fieldtype": "Text Editor",
-   "label": "Resolution Details",
-   "no_copy": 1,
-   "oldfieldname": "resolution_details",
-   "oldfieldtype": "Text"
-  },
-  {
-   "depends_on": "eval:!doc.__islocal",
-   "fieldname": "column_break1",
-   "fieldtype": "Column Break",
-   "oldfieldtype": "Column Break",
-   "read_only": 1
-  },
-  {
-   "default": "Today",
-   "fieldname": "opening_date",
-   "fieldtype": "Date",
-   "label": "Opening Date",
-   "no_copy": 1,
-   "oldfieldname": "opening_date",
-   "oldfieldtype": "Date",
-   "read_only": 1
-  },
-  {
-   "fieldname": "opening_time",
-   "fieldtype": "Time",
-   "label": "Opening Time",
-   "no_copy": 1,
-   "oldfieldname": "opening_time",
-   "oldfieldtype": "Time",
-   "read_only": 1
-  },
-  {
-   "depends_on": "eval:!doc.__islocal",
-   "fieldname": "resolution_date",
-   "fieldtype": "Datetime",
-   "label": "Resolution Date",
-   "no_copy": 1,
-   "oldfieldname": "resolution_date",
-   "oldfieldtype": "Date",
-   "read_only": 1
-  },
-  {
-   "fieldname": "content_type",
-   "fieldtype": "Data",
-   "hidden": 1,
-   "label": "Content Type"
-  },
-  {
-   "fieldname": "attachment",
-   "fieldtype": "Attach",
-   "hidden": 1,
-   "label": "Attachment"
-  },
-  {
-   "default": "0",
-   "fieldname": "via_customer_portal",
-   "fieldtype": "Check",
-   "label": "Via Customer Portal"
-  },
-  {
-   "default": "Ongoing",
-   "depends_on": "eval: doc.service_level_agreement",
-   "fieldname": "agreement_fulfilled",
-   "fieldtype": "Select",
-   "label": "Service Level Agreement Fulfilled",
-   "options": "Ongoing\nFulfilled\nFailed",
-   "read_only": 1
-  },
-  {
-   "depends_on": "eval: doc.service_level_agreement",
-   "description": "in hours",
-   "fieldname": "response_by_variance",
-   "fieldtype": "Float",
-   "label": "Response By Variance",
-   "read_only": 1
-  },
-  {
-   "depends_on": "eval: doc.service_level_agreement",
-   "description": "in hours",
-   "fieldname": "resolution_by_variance",
-   "fieldtype": "Float",
-   "label": "Resolution By Variance",
-   "read_only": 1
-  }
- ],
- "icon": "fa fa-ticket",
- "idx": 7,
- "modified": "2019-06-30 13:19:38.215525",
- "modified_by": "Administrator",
- "module": "Support",
- "name": "Issue",
- "owner": "Administrator",
- "permissions": [
-  {
-   "create": 1,
-   "delete": 1,
-   "email": 1,
-   "print": 1,
-   "read": 1,
-   "report": 1,
-   "role": "Support Team",
-   "share": 1,
-   "write": 1
-  }
- ],
- "quick_entry": 1,
- "search_fields": "status,customer,subject,raised_by",
- "sort_field": "modified",
- "sort_order": "ASC",
- "timeline_field": "customer",
- "title_field": "subject",
- "track_seen": 1
-}
+  "allow_import": 1,
+  "allow_rename": 1,
+  "autoname": "naming_series:",
+  "creation": "2013-02-01 10:36:25",
+  "doctype": "DocType",
+  "document_type": "Setup",
+  "engine": "InnoDB",
+  "field_order": [
+   "subject_section",
+   "naming_series",
+   "subject",
+   "customer",
+   "raised_by",
+   "cb00",
+   "status",
+   "priority",
+   "issue_type",
+   "sb_details",
+   "description",
+   "service_level_section",
+   "service_level_agreement",
+   "response_by",
+   "response_by_variance",
+   "reset_service_level_agreement",
+   "cb",
+   "agreement_fulfilled",
+   "resolution_by",
+   "resolution_by_variance",
+   "service_level_agreement_creation",
+   "response",
+   "mins_to_first_response",
+   "first_responded_on",
+   "additional_info",
+   "lead",
+   "contact",
+   "email_account",
+   "column_break_16",
+   "customer_name",
+   "project",
+   "company",
+   "section_break_19",
+   "resolution_details",
+   "column_break1",
+   "opening_date",
+   "opening_time",
+   "resolution_date",
+   "content_type",
+   "attachment",
+   "via_customer_portal"
+  ],
+  "fields": [
+   {
+    "fieldname": "subject_section",
+    "fieldtype": "Section Break",
+    "label": "Subject",
+    "options": "fa fa-flag"
+   },
+   {
+    "fieldname": "naming_series",
+    "fieldtype": "Select",
+    "label": "Series",
+    "no_copy": 1,
+    "options": "ISS-.YYYY.-",
+    "print_hide": 1,
+    "set_only_once": 1
+   },
+   {
+    "bold": 1,
+    "fieldname": "subject",
+    "fieldtype": "Data",
+    "in_global_search": 1,
+    "in_standard_filter": 1,
+    "label": "Subject",
+    "reqd": 1
+   },
+   {
+    "fieldname": "customer",
+    "fieldtype": "Link",
+    "in_global_search": 1,
+    "label": "Customer",
+    "oldfieldname": "customer",
+    "oldfieldtype": "Link",
+    "options": "Customer",
+    "print_hide": 1,
+    "search_index": 1
+   },
+   {
+    "bold": 1,
+    "depends_on": "eval:doc.__islocal",
+    "fieldname": "raised_by",
+    "fieldtype": "Data",
+    "in_global_search": 1,
+    "in_list_view": 1,
+    "label": "Raised By (Email)",
+    "oldfieldname": "raised_by",
+    "oldfieldtype": "Data",
+    "options": "Email"
+   },
+   {
+    "fieldname": "cb00",
+    "fieldtype": "Column Break"
+   },
+   {
+    "default": "Open",
+    "fieldname": "status",
+    "fieldtype": "Select",
+    "in_list_view": 1,
+    "in_standard_filter": 1,
+    "label": "Status",
+    "no_copy": 1,
+    "oldfieldname": "status",
+    "oldfieldtype": "Select",
+    "options": "Open\nReplied\nHold\nClosed",
+    "search_index": 1
+   },
+   {
+    "default": "Medium",
+    "fieldname": "priority",
+    "fieldtype": "Link",
+    "in_standard_filter": 1,
+    "label": "Priority",
+    "options": "Issue Priority"
+   },
+   {
+    "fieldname": "issue_type",
+    "fieldtype": "Link",
+    "label": "Issue Type",
+    "options": "Issue Type"
+   },
+   {
+    "collapsible": 1,
+    "collapsible_depends_on": "eval:doc.status!=\"Closed\"",
+    "fieldname": "sb_details",
+    "fieldtype": "Section Break",
+    "label": "Details"
+   },
+   {
+    "bold": 1,
+    "fieldname": "description",
+    "fieldtype": "Text Editor",
+    "in_global_search": 1,
+    "label": "Description",
+    "oldfieldname": "problem_description",
+    "oldfieldtype": "Text"
+   },
+   {
+    "collapsible": 1,
+    "fieldname": "service_level_section",
+    "fieldtype": "Section Break",
+    "label": "Service Level"
+   },
+   {
+    "fieldname": "service_level_agreement",
+    "fieldtype": "Link",
+    "label": "Service Level Agreement",
+    "options": "Service Level Agreement"
+   },
+   {
+    "fieldname": "response_by",
+    "fieldtype": "Datetime",
+    "label": "Response By",
+    "read_only": 1
+   },
+   {
+    "collapsible": 1,
+    "fieldname": "cb",
+    "fieldtype": "Column Break",
+    "options": "fa fa-pushpin",
+    "read_only": 1
+   },
+   {
+    "fieldname": "resolution_by",
+    "fieldtype": "Datetime",
+    "label": "Resolution By",
+    "read_only": 1
+   },
+   {
+    "collapsible": 1,
+    "fieldname": "response",
+    "fieldtype": "Section Break",
+    "label": "Response"
+   },
+   {
+    "bold": 1,
+    "fieldname": "mins_to_first_response",
+    "fieldtype": "Float",
+    "label": "Mins to First Response",
+    "read_only": 1
+   },
+   {
+    "fieldname": "first_responded_on",
+    "fieldtype": "Datetime",
+    "label": "First Responded On"
+   },
+   {
+    "collapsible": 1,
+    "fieldname": "additional_info",
+    "fieldtype": "Section Break",
+    "label": "Reference",
+    "options": "fa fa-pushpin",
+    "read_only": 1
+   },
+   {
+    "fieldname": "lead",
+    "fieldtype": "Link",
+    "label": "Lead",
+    "options": "Lead"
+   },
+   {
+    "fieldname": "contact",
+    "fieldtype": "Link",
+    "label": "Contact",
+    "options": "Contact"
+   },
+   {
+    "fieldname": "email_account",
+    "fieldtype": "Link",
+    "label": "Email Account",
+    "options": "Email Account"
+   },
+   {
+    "fieldname": "column_break_16",
+    "fieldtype": "Column Break"
+   },
+   {
+    "bold": 1,
+    "fieldname": "customer_name",
+    "fieldtype": "Data",
+    "label": "Customer Name",
+    "oldfieldname": "customer_name",
+    "oldfieldtype": "Data",
+    "read_only": 1
+   },
+   {
+    "fieldname": "project",
+    "fieldtype": "Link",
+    "label": "Project",
+    "options": "Project"
+   },
+   {
+    "fieldname": "company",
+    "fieldtype": "Link",
+    "label": "Company",
+    "options": "Company",
+    "print_hide": 1
+   },
+   {
+    "collapsible": 1,
+    "fieldname": "section_break_19",
+    "fieldtype": "Section Break",
+    "label": "Resolution"
+   },
+   {
+    "depends_on": "eval:!doc.__islocal",
+    "fieldname": "resolution_details",
+    "fieldtype": "Text Editor",
+    "label": "Resolution Details",
+    "no_copy": 1,
+    "oldfieldname": "resolution_details",
+    "oldfieldtype": "Text"
+   },
+   {
+    "depends_on": "eval:!doc.__islocal",
+    "fieldname": "column_break1",
+    "fieldtype": "Column Break",
+    "oldfieldtype": "Column Break",
+    "read_only": 1
+   },
+   {
+    "default": "Today",
+    "fieldname": "opening_date",
+    "fieldtype": "Date",
+    "label": "Opening Date",
+    "no_copy": 1,
+    "oldfieldname": "opening_date",
+    "oldfieldtype": "Date",
+    "read_only": 1
+   },
+   {
+    "fieldname": "opening_time",
+    "fieldtype": "Time",
+    "label": "Opening Time",
+    "no_copy": 1,
+    "oldfieldname": "opening_time",
+    "oldfieldtype": "Time",
+    "read_only": 1
+   },
+   {
+    "depends_on": "eval:!doc.__islocal",
+    "fieldname": "resolution_date",
+    "fieldtype": "Datetime",
+    "label": "Resolution Date",
+    "no_copy": 1,
+    "oldfieldname": "resolution_date",
+    "oldfieldtype": "Date",
+    "read_only": 1
+   },
+   {
+    "fieldname": "content_type",
+    "fieldtype": "Data",
+    "hidden": 1,
+    "label": "Content Type"
+   },
+   {
+    "fieldname": "attachment",
+    "fieldtype": "Attach",
+    "hidden": 1,
+    "label": "Attachment"
+   },
+   {
+    "default": "0",
+    "fieldname": "via_customer_portal",
+    "fieldtype": "Check",
+    "label": "Via Customer Portal"
+   },
+   {
+    "default": "Ongoing",
+    "depends_on": "eval: doc.service_level_agreement",
+    "fieldname": "agreement_fulfilled",
+    "fieldtype": "Select",
+    "label": "Service Level Agreement Fulfilled",
+    "options": "Ongoing\nFulfilled\nFailed",
+    "read_only": 1
+   },
+   {
+    "depends_on": "eval: doc.service_level_agreement",
+    "description": "in hours",
+    "fieldname": "response_by_variance",
+    "fieldtype": "Float",
+    "label": "Response By Variance",
+    "read_only": 1
+   },
+   {
+    "depends_on": "eval: doc.service_level_agreement",
+    "description": "in hours",
+    "fieldname": "resolution_by_variance",
+    "fieldtype": "Float",
+    "label": "Resolution By Variance",
+    "read_only": 1
+   },
+   {
+    "fieldname": "service_level_agreement_creation",
+    "fieldtype": "Datetime",
+    "hidden": 1,
+    "label": "Service Level Agreement Creation",
+    "read_only": 1
+   },
+   {
+    "depends_on": "eval: doc.service_level_agreement",
+    "fieldname": "reset_service_level_agreement",
+    "fieldtype": "Button",
+    "label": "Reset Service Level Agreement"
+   }
+  ],
+  "icon": "fa fa-ticket",
+  "idx": 7,
+  "modified": "2019-07-11 23:57:22.015881",
+  "modified_by": "Administrator",
+  "module": "Support",
+  "name": "Issue",
+  "owner": "Administrator",
+  "permissions": [
+   {
+    "create": 1,
+    "delete": 1,
+    "email": 1,
+    "print": 1,
+    "read": 1,
+    "report": 1,
+    "role": "Support Team",
+    "share": 1,
+    "write": 1
+   }
+  ],
+  "quick_entry": 1,
+  "search_fields": "status,customer,subject,raised_by",
+  "sort_field": "modified",
+  "sort_order": "ASC",
+  "timeline_field": "customer",
+  "title_field": "subject",
+  "track_changes": 1,
+  "track_seen": 1
+ }
\ No newline at end of file
diff --git a/erpnext/support/doctype/issue/issue.py b/erpnext/support/doctype/issue/issue.py
index 226676f..98d8c99 100644
--- a/erpnext/support/doctype/issue/issue.py
+++ b/erpnext/support/doctype/issue/issue.py
@@ -121,6 +121,7 @@
 
 		# Reset SLA
 		if replicated_issue.service_level_agreement:
+			replicated_issue.service_level_agreement_creation = now_datetime()
 			replicated_issue.service_level_agreement = None
 			replicated_issue.agreement_fulfilled = "Ongoing"
 			replicated_issue.response_by = None
@@ -173,8 +174,9 @@
 
 		if not self.creation:
 			self.creation = now_datetime()
+			self.service_level_agreement_creation = now_datetime()
 
-		start_date_time = get_datetime(self.creation)
+		start_date_time = get_datetime(self.service_level_agreement_creation)
 		self.response_by = get_expected_time_for(parameter='response', service_level=priority, start_date_time=start_date_time)
 		self.resolution_by = get_expected_time_for(parameter='resolution', service_level=priority, start_date_time=start_date_time)
 
@@ -193,6 +195,23 @@
 				self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement)
 				frappe.msgprint(_("Service Level Agreement has been changed to {0}.").format(self.service_level_agreement))
 
+	def reset_service_level_agreement(self, reason, user):
+		if not frappe.db.get_single_value("Support Settings", "allow_resetting_service_level_agreement"):
+			frappe.throw(_("Allow Resetting Service Level Agreement from Support Settings."))
+
+		frappe.get_doc({
+			"doctype": "Comment",
+			"comment_type": "Info",
+			"reference_doctype": self.doctype,
+			"reference_name": self.name,
+			"comment_email": user,
+			"content": " resetted Service Level Agreement - {0}".format(_(reason)),
+		}).insert(ignore_permissions=True)
+
+		self.service_level_agreement_creation = now_datetime()
+		self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement)
+		self.save()
+
 def get_expected_time_for(parameter, service_level, start_date_time):
 	current_date_time = start_date_time
 	expected_time = current_date_time
@@ -251,7 +270,8 @@
 				allotted_days -= 1
 				expected_time_is_set = allotted_days <= 0
 
-		current_date_time = add_to_date(current_date_time, days=1)
+		if not expected_time_is_set:
+			current_date_time = add_to_date(current_date_time, days=1)
 
 	if end_time and time_period != 'Hour':
 		current_date_time = datetime.combine(getdate(current_date_time), get_time(end_time))
diff --git a/erpnext/support/doctype/issue/issue_list.js b/erpnext/support/doctype/issue/issue_list.js
index e87c464..6d702f6 100644
--- a/erpnext/support/doctype/issue/issue_list.js
+++ b/erpnext/support/doctype/issue/issue_list.js
@@ -23,8 +23,8 @@
 				'Low': 'yellow',
 				'Medium': 'orange',
 				'High': 'red'
-			}
-			return [__(doc.status), color[doc.priority] || 'Red', `status,=,Open`];
+			};
+			return [__(doc.status), color[doc.priority] || 'red', `status,=,Open`];
 		} else if (doc.status === 'Closed') {
 			return [__(doc.status), "green", "status,=," + doc.status];
 		} else {
diff --git a/erpnext/support/doctype/issue/test_issue.py b/erpnext/support/doctype/issue/test_issue.py
index eb1736e..7a5e3e3 100644
--- a/erpnext/support/doctype/issue/test_issue.py
+++ b/erpnext/support/doctype/issue/test_issue.py
@@ -80,7 +80,8 @@
 		"customer": customer,
 		"raised_by": "test@example.com",
 		"description": "Service Level Agreement Issue",
-		"creation": creation
+		"creation": creation,
+		"service_level_agreement_creation": creation
 	}).insert(ignore_permissions=True)
 
 	return issue
diff --git a/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py b/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
index 68b82d1..4a741ea 100644
--- a/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
+++ b/erpnext/support/doctype/service_level_agreement/test_service_level_agreement.py
@@ -76,6 +76,7 @@
 
 	service_level_agreement = frappe.get_doc({
 		"doctype": "Service Level Agreement",
+		"enable": 1,
 		"default_service_level_agreement": default_service_level_agreement,
 		"service_level": service_level,
 		"holiday_list": holiday_list,
diff --git a/erpnext/support/doctype/support_settings/support_settings.json b/erpnext/support/doctype/support_settings/support_settings.json
index 2dced15..be9e064 100644
--- a/erpnext/support/doctype/support_settings/support_settings.json
+++ b/erpnext/support/doctype/support_settings/support_settings.json
@@ -6,6 +6,7 @@
  "field_order": [
   "sb_00",
   "track_service_level_agreement",
+  "allow_resetting_service_level_agreement",
   "issues_sb",
   "close_issue_after_days",
   "portal_sb",
@@ -118,10 +119,16 @@
    "fieldname": "track_service_level_agreement",
    "fieldtype": "Check",
    "label": "Track Service Level Agreement"
+  },
+  {
+   "default": "0",
+   "fieldname": "allow_resetting_service_level_agreement",
+   "fieldtype": "Check",
+   "label": "Allow Resetting Service Level Agreement"
   }
  ],
  "issingle": 1,
- "modified": "2019-07-09 17:11:38.216732",
+ "modified": "2019-07-10 22:52:39.663873",
  "modified_by": "Administrator",
  "module": "Support",
  "name": "Support Settings",
diff --git a/erpnext/templates/includes/product_page.js b/erpnext/templates/includes/product_page.js
index af98fc7..65949bb 100644
--- a/erpnext/templates/includes/product_page.js
+++ b/erpnext/templates/includes/product_page.js
@@ -29,10 +29,10 @@
 						.html(r.message.product_info.price.formatted_price_sales_uom + "<div style='font-size: small'>\
 							(" + r.message.product_info.price.formatted_price + " / " + r.message.product_info.uom + ")</div>");
 
-					if(r.message.product_info.in_stock==0) {
+					if(r.message.product_info.in_stock===0) {
 						$(".item-stock").html("<div style='color: red'> <i class='fa fa-close'></i> {{ _("Not in stock") }}</div>");
 					}
-					else if(r.message.product_info.in_stock==1) {
+					else if(r.message.product_info.in_stock===1) {
 						var qty_display = "{{ _("In stock") }}";
 						if (r.message.product_info.show_stock_qty) {
 							qty_display += " ("+r.message.product_info.stock_qty+")";
@@ -75,13 +75,13 @@
 			newVal = 0;
 
 		if (btn.attr('data-dir') == 'up') {
-			newVal = parseInt(oldValue) + 1;
+			newVal = Number.parseInt(oldValue) + 1;
 		} else if (btn.attr('data-dir') == 'dwn')  {
-			if (parseInt(oldValue) > 1) {
-				newVal = parseInt(oldValue) - 1;
+			if (Number.parseInt(oldValue) > 1) {
+				newVal = Number.parseInt(oldValue) - 1;
 			}
 			else {
-				newVal = parseInt(oldValue);
+				newVal = Number.parseInt(oldValue);
 			}
 		}
 		input.val(newVal);
diff --git a/erpnext/templates/pages/projects.py b/erpnext/templates/pages/projects.py
index ddca274..d23fed9 100644
--- a/erpnext/templates/pages/projects.py
+++ b/erpnext/templates/pages/projects.py
@@ -7,22 +7,22 @@
 
 def get_context(context):
 	project_user = frappe.db.get_value("Project User", {"parent": frappe.form_dict.project, "user": frappe.session.user} , ["user", "view_attachments"], as_dict= True)
-	if not project_user or frappe.session.user == 'Guest': 
+	if frappe.session.user != 'Administrator' and (not project_user or frappe.session.user == 'Guest'):
 		raise frappe.PermissionError
-		
+
 	context.no_cache = 1
 	context.show_sidebar = True
 	project = frappe.get_doc('Project', frappe.form_dict.project)
 
 	project.has_permission('read')
-	
+
 	project.tasks = get_tasks(project.name, start=0, item_status='open',
 		search=frappe.form_dict.get("search"))
 
 	project.timesheets = get_timesheets(project.name, start=0,
 		search=frappe.form_dict.get("search"))
 
-	if project_user.view_attachments:
+	if project_user and project_user.view_attachments:
 		project.attachments = get_attachments(project.name)
 
 	context.doc = project
@@ -46,7 +46,7 @@
 			task.todo=task.todo[0]
 			task.todo.user_image = frappe.db.get_value('User', task.todo.owner, 'user_image')
 
-		
+
 		task.comment_count = len(json.loads(task._comments or "[]"))
 
 		task.css_seen = ''
@@ -86,7 +86,7 @@
 			timesheet.info.css_seen = ''
 			if timesheet.info._seen:
 				if frappe.session.user in json.loads(timesheet.info._seen):
-					timesheet.info.css_seen = 'seen'		
+					timesheet.info.css_seen = 'seen'
 	return timesheets
 
 @frappe.whitelist()
diff --git a/erpnext/www/lms/macros/__init__.py b/erpnext/www/lms/macros/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/www/lms/macros/__init__.py