Merge pull request #9673 from rohitwaghchaure/serial_no_sales_return_issue

Remove sales invoice from serial number while making sales return entery using delivery note
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 58a8311..a8a8055 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,8 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '8.3.0'
-
+__version__ = '8.3.5'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/budget/budget.py b/erpnext/accounts/doctype/budget/budget.py
index a6348f1..f99d0bb 100644
--- a/erpnext/accounts/doctype/budget/budget.py
+++ b/erpnext/accounts/doctype/budget/budget.py
@@ -83,7 +83,7 @@
 
 			budget_records = frappe.db.sql("""
 				select
-					b.{budget_against_field}, ba.budget_amount, b.monthly_distribution,
+					b.{budget_against_field} as budget_against, ba.budget_amount, b.monthly_distribution,
 					b.action_if_annual_budget_exceeded, 
 					b.action_if_accumulated_monthly_budget_exceeded
 				from 
@@ -111,15 +111,15 @@
 				args["month_end_date"] = get_last_day(args.posting_date)
 
 				compare_expense_with_budget(args, budget_amount, 
-					_("Accumulated Monthly"), monthly_action)
+					_("Accumulated Monthly"), monthly_action, budget.budget_against)
 
 			if yearly_action in ("Stop", "Warn") and monthly_action != "Stop" \
 				and yearly_action != monthly_action:
 				compare_expense_with_budget(args, flt(budget.budget_amount), 
-						_("Annual"), yearly_action)
+						_("Annual"), yearly_action, budget.budget_against)
 
 
-def compare_expense_with_budget(args, budget_amount, action_for, action):
+def compare_expense_with_budget(args, budget_amount, action_for, action, budget_against):
 	actual_expense = get_actual_expense(args)
 	if actual_expense > budget_amount:
 		diff = actual_expense - budget_amount
@@ -127,7 +127,7 @@
 
 		msg = _("{0} Budget for Account {1} against {2} {3} is {4}. It will exceed by {5}").format(
 				_(action_for), frappe.bold(args.account), args.budget_against_field, 
-				frappe.bold(args.budget_against), 
+				frappe.bold(budget_against),
 				frappe.bold(fmt_money(budget_amount, currency=currency)), 
 				frappe.bold(fmt_money(diff, currency=currency)))
 
diff --git a/erpnext/accounts/doctype/budget/test_budget.py b/erpnext/accounts/doctype/budget/test_budget.py
index 15895dc..f6849ba 100644
--- a/erpnext/accounts/doctype/budget/test_budget.py
+++ b/erpnext/accounts/doctype/budget/test_budget.py
@@ -140,6 +140,33 @@
 		budget.load_from_db()
 		budget.cancel()
 
+	def test_monthly_budget_against_parent_group_cost_center(self):
+		cost_center = "_Test Cost Center 3 - _TC"
+
+		if not frappe.db.exists("Cost Center", cost_center):
+			frappe.get_doc({
+				'doctype': 'Cost Center',
+				'cost_center_name': '_Test Cost Center 3',
+				'parent_cost_center': "_Test Company - _TC",
+				'company': '_Test Company',
+				'is_group': 0
+			}).insert(ignore_permissions=True)
+
+		budget = make_budget("Cost Center", cost_center)
+		frappe.db.set_value("Budget", budget.name, "action_if_accumulated_monthly_budget_exceeded", "Stop")
+
+		jv = make_journal_entry("_Test Account Cost for Goods Sold - _TC",
+			"_Test Bank - _TC", 40000, cost_center)
+
+		self.assertRaises(BudgetError, jv.submit)
+
+		budget.load_from_db()
+		budget.cancel()
+		jv.cancel()
+
+		frappe.delete_doc('Journal Entry', jv.name)
+		frappe.delete_doc('Cost Center', cost_center)
+
 def set_total_expense_zero(posting_date, budget_against_field=None, budget_against_CC=None):
 	if budget_against_field == "Project":
 		budget_against = "_Test Project"
@@ -167,7 +194,8 @@
 	if budget_against == "Project":
 		budget_list = frappe.get_all("Budget", fields=["name"], filters = {"name": ("like", "_Test Project/_Test Fiscal Year 2013%")})
 	else:
-		budget_list = frappe.get_all("Budget", fields=["name"], filters = {"name": ("like", "_Test Cost Center - _TC/_Test Fiscal Year 2013%")})
+		cost_center_name = "{0}%".format(cost_center or "_Test Cost Center - _TC/_Test Fiscal Year 2013")
+		budget_list = frappe.get_all("Budget", fields=["name"], filters = {"name": ("like", cost_center_name)})
 	for d in budget_list:
 		frappe.db.sql("delete from `tabBudget` where name = %(name)s", d)
 		frappe.db.sql("delete from `tabBudget Account` where parent = %(name)s", d)
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index 5bfd4d9..63832fa 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -291,37 +291,39 @@
 
 	set_account_currency_and_balance: function(frm, account, currency_field,
 			balance_field, callback_function) {
-		frappe.call({
-			method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_account_details",
-			args: {
-				"account": account,
-				"date": frm.doc.posting_date
-			},
-			callback: function(r, rt) {
-				if(r.message) {
-					frm.set_value(currency_field, r.message['account_currency']);
-					frm.set_value(balance_field, r.message['account_balance']);
+		if (frm.doc.posting_date) {
+			frappe.call({
+				method: "erpnext.accounts.doctype.payment_entry.payment_entry.get_account_details",
+				args: {
+					"account": account,
+					"date": frm.doc.posting_date
+				},
+				callback: function(r, rt) {
+					if(r.message) {
+						frm.set_value(currency_field, r.message['account_currency']);
+						frm.set_value(balance_field, r.message['account_balance']);
 
-					if(frm.doc.payment_type=="Receive" && currency_field=="paid_to_account_currency") {
-						frm.toggle_reqd(["reference_no", "reference_date"],
-							(r.message['account_type'] == "Bank" ? 1 : 0));
-						if(!frm.doc.received_amount && frm.doc.paid_amount)
-							frm.events.paid_amount(frm);
-					} else if(frm.doc.payment_type=="Pay" && currency_field=="paid_from_account_currency") {
-						frm.toggle_reqd(["reference_no", "reference_date"],
-							(r.message['account_type'] == "Bank" ? 1 : 0));
+						if(frm.doc.payment_type=="Receive" && currency_field=="paid_to_account_currency") {
+							frm.toggle_reqd(["reference_no", "reference_date"],
+								(r.message['account_type'] == "Bank" ? 1 : 0));
+							if(!frm.doc.received_amount && frm.doc.paid_amount)
+								frm.events.paid_amount(frm);
+						} else if(frm.doc.payment_type=="Pay" && currency_field=="paid_from_account_currency") {
+							frm.toggle_reqd(["reference_no", "reference_date"],
+								(r.message['account_type'] == "Bank" ? 1 : 0));
 
-						if(!frm.doc.paid_amount && frm.doc.received_amount)
-							frm.events.received_amount(frm);
+							if(!frm.doc.paid_amount && frm.doc.received_amount)
+								frm.events.received_amount(frm);
+						}
+
+						if(callback_function) callback_function(frm);
+
+						frm.events.hide_unhide_fields(frm);
+						frm.events.set_dynamic_labels(frm);
 					}
-
-					if(callback_function) callback_function(frm);
-
-					frm.events.hide_unhide_fields(frm);
-					frm.events.set_dynamic_labels(frm);
 				}
-			}
-		});
+			});			
+		}
 	},
 
 	paid_from_account_currency: function(frm) {
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
index 4c05b94..260c05e 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json
@@ -12,6 +12,7 @@
  "doctype": "DocType", 
  "document_type": "", 
  "editable_grid": 0, 
+ "engine": "InnoDB", 
  "fields": [
   {
    "allow_bulk_edit": 0, 
@@ -1927,7 +1928,7 @@
    "in_global_search": 0, 
    "in_list_view": 0, 
    "in_standard_filter": 0, 
-   "label": "Item-wise Tax Breakup", 
+   "label": "Tax Breakup", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -4687,7 +4688,7 @@
  "istable": 0, 
  "max_attachments": 0, 
  "menu_index": 0, 
- "modified": "2017-07-04 17:11:09.477003", 
+ "modified": "2017-07-07 13:05:37.469682", 
  "modified_by": "Administrator", 
  "module": "Accounts", 
  "name": "Sales Invoice", 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 282425d..2dd4e7a 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -803,9 +803,10 @@
 				continue
 
 			for serial_no in item.serial_no.split("\n"):
-				sno = frappe.get_doc('Serial No', serial_no)
-				sno.sales_invoice = invoice
-				sno.db_update()
+				if serial_no and frappe.db.exists('Serial No', serial_no):
+					sno = frappe.get_doc('Serial No', serial_no)
+					sno.sales_invoice = invoice
+					sno.db_update()
 
 	def validate_serial_numbers(self):
 		"""
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 22485e9..6f1c2c9 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1116,7 +1116,7 @@
 		})
 		si.insert()
 		
-		tax_breakup_html = '''\n<div class="tax-break-up" style="overflow-x: auto;">\n\t<table class="table table-bordered table-hover">\n\t\t<thead><tr><th class="text-left" style="min-width: 120px;">Item Name</th>\n<th class="text-right" style="min-width: 80px;">Taxable Amount</th>\n<th class="text-right" style="min-width: 80px;">_Test Account Service Tax - _TC</th></tr></thead>\n\t\t<tbody><tr><td>_Test Item</td><td class="text-right">\u20b9 5,000.00</td><td class="text-right">(10.0%) \u20b9 500.00</td></tr></tbody>\n\t</table>\n</div>'''
+		tax_breakup_html = '''\n<div class="tax-break-up" style="overflow-x: auto;">\n\t<table class="table table-bordered table-hover">\n\t\t<thead><tr><th class="text-left" style="min-width: 120px;">Item Name</th><th class="text-right" style="min-width: 80px;">Taxable Amount</th><th class="text-right" style="min-width: 80px;">_Test Account Service Tax - _TC</th></tr></thead>\n\t\t<tbody><tr><td>_Test Item</td><td class="text-right">\u20b9 5,000.00</td><td class="text-right">(10.0%) \u20b9 500.00</td></tr></tbody>\n\t</table>\n</div>'''
 		
 		self.assertEqual(si.other_charges_calculation, tax_breakup_html)
 		
diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
index b798d2b..853b805 100644
--- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
+++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.html
@@ -1,9 +1,3 @@
-{% var letterhead= filters.letter_head || (frappe.get_doc(":Company", filters.company) && frappe.get_doc(":Company", filters.company).default_letter_head) || frappe.defaults.get_default("letter_head"); %}
-{% if(letterhead) { %} 
-<div style="margin-bottom: 7px;" class="text-center">
-	{%= frappe.boot.letter_heads[letterhead].header %}
-</div>
-{% } %}
 <h2 class="text-center">{%= __(report.report_name) %}</h2>
 <h4 class="text-center">{%= filters.customer || filters.supplier %} </h4>
 <h5 class="text-center">
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.html b/erpnext/accounts/report/general_ledger/general_ledger.html
index 0a25225..91cc3c9 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.html
+++ b/erpnext/accounts/report/general_ledger/general_ledger.html
@@ -1,9 +1,3 @@
-{% var letterhead= filters.letter_head || (frappe.get_doc(":Company", filters.company) && frappe.get_doc(":Company", filters.company).default_letter_head) || frappe.defaults.get_default("letter_head"); %}
-{% if(letterhead) { %} 
-<div style="margin-bottom: 7px;" class="text-center">
-	{%= frappe.boot.letter_heads[letterhead].header %}
-</div>
-{% } %}
 <h2 class="text-center">{%= __("Statement of Account") %}</h2>
 <h4 class="text-center">
 	{% if (filters.party_name) { %}
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 8c07120..8eb83af 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -531,8 +531,8 @@
 		<tbody>{rows}</tbody>
 	</table>
 </div>'''.format(**{
-	"headings": "\n".join(headings),
-	"rows": "\n".join(rows)
+	"headings": "".join(headings),
+	"rows": "".join(rows)
 })
 
 	def get_item_tax(self, item_tax, tax_accounts, company_currency):
@@ -605,7 +605,7 @@
 		rows.append("<tr><td>{item_name}</td><td class='text-right'>{taxable_amount}</td>{taxes}</tr>".format(**{
 			"item_name": item.item_name,
 			"taxable_amount": fmt_money(item.net_amount, item.precision("net_amount"), company_currency),
-			"taxes": "\n".join(taxes)
+			"taxes": "".join(taxes)
 		}))
 		
 	return rows
\ No newline at end of file
diff --git a/erpnext/docs/assets/img/setup/email/email-alert-set-property.png b/erpnext/docs/assets/img/setup/email/email-alert-set-property.png
new file mode 100644
index 0000000..658b149
--- /dev/null
+++ b/erpnext/docs/assets/img/setup/email/email-alert-set-property.png
Binary files differ
diff --git a/erpnext/docs/assets/img/setup/sms-setting2.jpg b/erpnext/docs/assets/img/setup/sms-settings2.jpg
similarity index 100%
rename from erpnext/docs/assets/img/setup/sms-setting2.jpg
rename to erpnext/docs/assets/img/setup/sms-settings2.jpg
Binary files differ
diff --git a/erpnext/docs/user/manual/en/setting-up/email/email-alerts.md b/erpnext/docs/user/manual/en/setting-up/email/email-alerts.md
index 9ec3073..8d239ea 100644
--- a/erpnext/docs/user/manual/en/setting-up/email/email-alerts.md
+++ b/erpnext/docs/user/manual/en/setting-up/email/email-alerts.md
@@ -42,6 +42,7 @@
 
 The above example will send an Email Alert when a Task is saved with the status "Open" and the Expected End Date for the Task is the date on or before the date on which it was saved on.
 
+
 ### Setting a Message
 
 You can use both Jinja Tags (`{% raw %}{{ doc.[field_name] }}{% endraw %}`) and HTML tags in the message textbox.
@@ -64,6 +65,17 @@
 
 ---
 
+### Setting a Value after the Alert is Set
+
+Sometimes to make sure that the email alert is not sent multiple times, you can
+define a custom property (via Customize Form) like "Email Alert Sent" and then
+set this property after the alert is sent by setting the **Set Property After Alert**
+field.
+
+Then you can use that as a condition in the **Condition** rules to ensure emails are not sent multiple times
+
+<img class="screenshot" alt="Setting Property in Email Alert" src="{{docs_base_url}}/assets/img/setup/email/email-alert-subject.png">
+
 ### Example
 
 1. Defining the Criteria
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index ec93f62..0966485 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -80,6 +80,13 @@
 			"parents": [{"title": _("Supplier Quotation"), "name": "quotations"}]
 		}
 	},
+	{"from_route": "/quotes", "to_route": "Quotation"},
+	{"from_route": "/quotes/<path:name>", "to_route": "order",
+		"defaults": {
+			"doctype": "Quotation",
+			"parents": [{"title": _("Quotes"), "name": "quotes"}]
+		}
+	},
 	{"from_route": "/shipments", "to_route": "Delivery Note"},
 	{"from_route": "/shipments/<path:name>", "to_route": "order",
 		"defaults": {
@@ -110,6 +117,7 @@
 	{"title": _("Projects"), "route": "/project", "reference_doctype": "Project"},
 	{"title": _("Request for Quotations"), "route": "/rfq", "reference_doctype": "Request for Quotation", "role": "Supplier"},
 	{"title": _("Supplier Quotation"), "route": "/quotations", "reference_doctype": "Supplier Quotation", "role": "Supplier"},
+	{"title": _("Quotes"), "route": "/quotes", "reference_doctype": "Quotation", "role":"Customer"},
 	{"title": _("Orders"), "route": "/orders", "reference_doctype": "Sales Order", "role":"Customer"},
 	{"title": _("Invoices"), "route": "/invoices", "reference_doctype": "Sales Invoice", "role":"Customer"},
 	{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"},
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index 880b52e..f6d9eaf 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -90,9 +90,7 @@
 
 		// formatter for production order operation
 		frm.set_indicator_formatter('operation',
-			function(doc) { return (frm.doc.qty==doc.completed_qty) ? "green" : "orange" })
-
-		erpnext.production_order.set_custom_buttons(frm);
+			function(doc) { return (frm.doc.qty==doc.completed_qty) ? "green" : "orange" });
 	},
 	
 	refresh: function(frm) {
@@ -153,26 +151,28 @@
 	},
 	
 	production_item: function(frm) {
-		frappe.call({
-			method: "erpnext.manufacturing.doctype.production_order.production_order.get_item_details",
-			args: {
-				item: frm.doc.production_item,
-				project: frm.doc.project
-			},
-			callback: function(r) {
-				if(r.message) {
-					erpnext.in_production_item_onchange = true;
-					$.each(["description", "stock_uom", "project", "bom_no"], function(i, field) {
-						frm.set_value(field, r.message[field]);
-					});
+		if (frm.doc.production_item) {
+			frappe.call({
+				method: "erpnext.manufacturing.doctype.production_order.production_order.get_item_details",
+				args: {
+					item: frm.doc.production_item,
+					project: frm.doc.project
+				},
+				callback: function(r) {
+					if(r.message) {
+						erpnext.in_production_item_onchange = true;
+						$.each(["description", "stock_uom", "project", "bom_no"], function(i, field) {
+							frm.set_value(field, r.message[field]);
+						});
 
-					if(r.message["set_scrap_wh_mandatory"]){
-						frm.toggle_reqd("scrap_warehouse", true);
+						if(r.message["set_scrap_wh_mandatory"]){
+							frm.toggle_reqd("scrap_warehouse", true);
+						}
+						erpnext.in_production_item_onchange = false;
 					}
-					erpnext.in_production_item_onchange = false;
 				}
-			}
-		});
+			});
+		}
 	},
 	
 	project: function(frm) {
@@ -265,7 +265,7 @@
 					erpnext.production_order.stop_production_order(frm, "Resumed");
 				}, __("Status"));
 			}
-			
+
 			if(!frm.doc.skip_transfer){
 				if ((flt(doc.material_transferred_for_manufacturing) < flt(doc.qty))
 					&& frm.doc.status != 'Stopped') {
@@ -274,7 +274,7 @@
 						erpnext.production_order.make_se(frm, 'Material Transfer for Manufacture');
 					});
 					start_btn.addClass('btn-primary');
-					}
+				}
 			}
 
 			if(!frm.doc.skip_transfer){
@@ -293,8 +293,9 @@
 			} else {
 				if ((flt(doc.produced_qty) < flt(doc.qty)) && frm.doc.status != 'Stopped') {
 					frm.has_finish_btn = true;
-					var finish_btn = frm.add_custom_button(__('Finish'),
-						cur_frm.cscript['Update Finished Goods']);
+					var finish_btn = frm.add_custom_button(__('Finish'), function() {
+						erpnext.production_order.make_se(frm, 'Manufacture');
+					});
 					finish_btn.addClass('btn-primary');
 				}
 			}
@@ -381,4 +382,4 @@
 			}
 		})
 	}
-}
\ No newline at end of file
+}
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.json b/erpnext/manufacturing/doctype/production_order/production_order.json
index ee033c4..e56e5a1 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.json
+++ b/erpnext/manufacturing/doctype/production_order/production_order.json
@@ -1358,7 +1358,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-06-13 14:29:00.457874", 
+ "modified": "2017-07-10 14:29:00.457874", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "Production Order", 
diff --git a/erpnext/manufacturing/doctype/production_order_item/production_order_item.json b/erpnext/manufacturing/doctype/production_order_item/production_order_item.json
index 06a7876..00e3adf 100644
--- a/erpnext/manufacturing/doctype/production_order_item/production_order_item.json
+++ b/erpnext/manufacturing/doctype/production_order_item/production_order_item.json
@@ -353,7 +353,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2017-05-15 17:37:20.212361", 
+ "modified": "2017-07-10 17:37:20.212361", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "Production Order Item", 
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 0cf0f7b..80d64e8 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -413,4 +413,5 @@
 erpnext.patches.v8_1.removed_roles_from_gst_report_non_indian_account
 erpnext.patches.v8_1.gst_fixes #2017-07-06
 erpnext.patches.v8_0.update_production_orders
-erpnext.patches.v8_1.remove_sales_invoice_from_returned_serial_no
\ No newline at end of file
+erpnext.patches.v8_1.remove_sales_invoice_from_returned_serial_no
+erpnext.patches.v8_1.allow_invoice_copy_to_edit_after_submit
\ No newline at end of file
diff --git a/erpnext/patches/v8_0/merge_student_batch_and_student_group.py b/erpnext/patches/v8_0/merge_student_batch_and_student_group.py
index 7cfdf60..c5654eb 100644
--- a/erpnext/patches/v8_0/merge_student_batch_and_student_group.py
+++ b/erpnext/patches/v8_0/merge_student_batch_and_student_group.py
@@ -9,8 +9,8 @@
 
 def execute():
 	# for converting student batch into student group
-	for doctype in ["Student Group", "Student Group Student", "Student Group Instructor", "Student Attendance"]:
-		frappe.reload_doc("schools", "doctype", doctype)
+	for doctype in ["Student Group", "Student Group Student", "Student Group Instructor", "Student Attendance", "Student"]:
+		frappe.reload_doc("schools", "doctype", frappe.scrub(doctype))
 
 	if frappe.db.table_exists("Student Batch"):
 		student_batches = frappe.db.sql('''select name as student_group_name, student_batch_name as batch,
diff --git a/erpnext/patches/v8_0/update_production_orders.py b/erpnext/patches/v8_0/update_production_orders.py
index 317aed5..06b8ce7 100644
--- a/erpnext/patches/v8_0/update_production_orders.py
+++ b/erpnext/patches/v8_0/update_production_orders.py
@@ -17,9 +17,11 @@
 		
 	pro_orders = frappe.get_all("Production Order", filters={"docstatus": ["!=", 2]}, fields=fields)
 	
+	count = 0
 	for p in pro_orders:
 		pro_order = frappe.get_doc("Production Order", p.name)
-		
+		count += 1
+
 		# set required items table
 		pro_order.set_required_items()
 		
@@ -39,6 +41,6 @@
 				pro_order.db_set("status", status)
 			elif pro_order.status == "Stopped":
 				pro_order.update_reserved_qty_for_production()
-			
-			
-			
\ No newline at end of file
+		
+		if count % 200 == 0:
+			frappe.db.commit()
\ No newline at end of file
diff --git a/erpnext/patches/v8_1/allow_invoice_copy_to_edit_after_submit.py b/erpnext/patches/v8_1/allow_invoice_copy_to_edit_after_submit.py
new file mode 100644
index 0000000..1fb297f
--- /dev/null
+++ b/erpnext/patches/v8_1/allow_invoice_copy_to_edit_after_submit.py
@@ -0,0 +1,12 @@
+import frappe
+
+def execute():
+	inv_copy_options = "ORIGINAL FOR RECIPIENT\nDUPLICATE FOR TRANSPORTER\nDUPLICATE FOR SUPPLIER\nTRIPLICATE FOR SUPPLIER"
+	
+	frappe.db.sql("""update `tabCustom Field` set allow_on_submit=1, options=%s
+		where fieldname='invoice_copy' and dt = 'Sales Invoice'
+	""", inv_copy_options)
+	
+	frappe.db.sql("""update `tabCustom Field` set read_only=1
+		where fieldname='gst_state_number' and dt = 'Address'
+	""")
diff --git a/erpnext/patches/v8_1/gst_fixes.py b/erpnext/patches/v8_1/gst_fixes.py
index 1d3a380..b47879c 100644
--- a/erpnext/patches/v8_1/gst_fixes.py
+++ b/erpnext/patches/v8_1/gst_fixes.py
@@ -44,7 +44,7 @@
 		],
 		'Sales Invoice': [
 			dict(fieldname='invoice_copy', label='Invoice Copy',
-				fieldtype='Select', insert_after='project', print_hide=1,
+				fieldtype='Select', insert_after='project', print_hide=1, allow_on_submit=1,
 				options='ORIGINAL FOR RECIPIENT\nDUPLICATE FOR TRANSPORTER\nTRIPLICATE FOR SUPPLIER'),
 		],
 		'Sales Order Item': [hsn_sac_field],
diff --git a/erpnext/patches/v8_1/setup_gst_india.py b/erpnext/patches/v8_1/setup_gst_india.py
index ce27d37..5660693 100644
--- a/erpnext/patches/v8_1/setup_gst_india.py
+++ b/erpnext/patches/v8_1/setup_gst_india.py
@@ -5,6 +5,7 @@
 	frappe.reload_doc('regional', 'doctype', 'gst_settings')
 	frappe.reload_doc('regional', 'doctype', 'gst_hsn_code')
 	frappe.reload_doc('stock', 'doctype', 'item')
+	frappe.reload_doc("stock", "doctype", "customs_tariff_number")
 
 	for report_name in ('GST Sales Register', 'GST Purchase Register',
 		'GST Itemised Sales Register', 'GST Itemised Purchase Register'):
diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js
index 075b2d0..e917a75 100644
--- a/erpnext/public/js/controllers/taxes_and_totals.js
+++ b/erpnext/public/js/controllers/taxes_and_totals.js
@@ -689,7 +689,7 @@
 					return '<th style="min-width: 80px;" class="text-right">' + (head || "") + "</th>";
 				}	
 			}
-		).join("\n");
+		).join("");
 
 		var distinct_item_names = [];
 		var distinct_items = [];
@@ -711,9 +711,9 @@
 					return item_tax_record[head[0]] ?
 						"<td class='text-right'>(" + item_tax_record[head[0]][0] + ") " + item_tax_record[head[0]][1] + "</td>" :
 						"<td></td>";
-				}).join("\n")
+				}).join("")
 			});
-		}).join("\n");
+		}).join("");
 
 		if(!rows) return "";
 		return '<div class="tax-break-up" style="overflow-x: auto;">\
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index c4f9e8a..fd91227 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -63,37 +63,32 @@
 		});
 
 		frappe.ui.form.on(this.frm.doctype, "additional_discount_percentage", function(frm) {
-			if (frm.via_discount_amount) {
-				return;
-			}
-
 			if(!frm.doc.apply_discount_on) {
 				frappe.msgprint(__("Please set 'Apply Additional Discount On'"));
-				return
+				return;
 			}
 
 			frm.via_discount_percentage = true;
 
 			if(frm.doc.additional_discount_percentage && frm.doc.discount_amount) {
 				// Reset discount amount and net / grand total
-				frm.set_value("discount_amount", 0);
+				frm.doc.discount_amount = 0;
+				frm.cscript.calculate_taxes_and_totals();
 			}
 
 			var total = flt(frm.doc[frappe.model.scrub(frm.doc.apply_discount_on)]);
 			var discount_amount = flt(total*flt(frm.doc.additional_discount_percentage) / 100,
 				precision("discount_amount"));
 
-			frm.set_value("discount_amount", discount_amount);
-			delete frm.via_discount_percentage;
+			frm.set_value("discount_amount", discount_amount)
+				.then(() => delete frm.via_discount_percentage);
 		});
 
 		frappe.ui.form.on(this.frm.doctype, "discount_amount", function(frm) {
 			frm.cscript.set_dynamic_labels();
 
 			if (!frm.via_discount_percentage) {
-				frm.via_discount_amount = true;
-				frm.set_value("additional_discount_percentage", 0);
-				delete frm.via_discount_amount;
+				frm.doc.additional_discount_percentage = 0;
 			}
 
 			frm.cscript.calculate_taxes_and_totals();
diff --git a/erpnext/regional/india/__init__.py b/erpnext/regional/india/__init__.py
index 0b1b163..9a6c376 100644
--- a/erpnext/regional/india/__init__.py
+++ b/erpnext/regional/india/__init__.py
@@ -72,5 +72,5 @@
  "Tripura": "16",
  "Uttar Pradesh": "35",
  "Uttarakhand": "36",
- "West Bengal": "37"
+ "West Bengal": "19"
 }
\ No newline at end of file
diff --git a/erpnext/regional/india/gst_state_code_data.json b/erpnext/regional/india/gst_state_code_data.json
index 89dc193..196f8d0 100644
--- a/erpnext/regional/india/gst_state_code_data.json
+++ b/erpnext/regional/india/gst_state_code_data.json
@@ -15,7 +15,7 @@
   "state_name": "Uttarakhand"
  },
  {
-  "state_number": "37",
+  "state_number": "19",
   "state_code": "WB",
   "state_name": "West Bengal"
  },
diff --git a/erpnext/regional/india/setup.py b/erpnext/regional/india/setup.py
index f547b82..93aea0d 100644
--- a/erpnext/regional/india/setup.py
+++ b/erpnext/regional/india/setup.py
@@ -84,7 +84,7 @@
 			dict(fieldname='gst_state', label='GST State', fieldtype='Select',
 				options='\n'.join(states), insert_after='gstin'),
 			dict(fieldname='gst_state_number', label='GST State Number',
-				fieldtype='Int', insert_after='gst_state'),
+				fieldtype='Int', insert_after='gst_state', read_only=1),
 		],
 		'Purchase Invoice': [
 			dict(fieldname='supplier_gstin', label='Supplier GSTIN',
@@ -102,8 +102,8 @@
 				fieldtype='Data', insert_after='company_address',
 				options='company_address.gstin', print_hide=1),
 			dict(fieldname='invoice_copy', label='Invoice Copy',
-				fieldtype='Select', insert_after='project', print_hide=1,
-				options='ORIGINAL FOR RECIPIENT\nDUPLICATE FOR TRANSPORTER\nTRIPLICATE FOR SUPPLIER')
+				fieldtype='Select', insert_after='project', print_hide=1, allow_on_submit=1,
+				options='ORIGINAL FOR RECIPIENT\nDUPLICATE FOR TRANSPORTER\nDUPLICATE FOR SUPPLIER\nTRIPLICATE FOR SUPPLIER')
 		],
 		'Item': [
 			dict(fieldname='gst_hsn_code', label='HSN/SAC',
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 62de7a9..84e5f3e 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -19,6 +19,6 @@
 
 		if doc.gst_state:
 			doc.gst_state_number = state_numbers[doc.gst_state]
-			if doc.gst_state_number != doc.gstin[:2]:
+			if doc.gstin != "NA" and doc.gst_state_number != doc.gstin[:2]:
 				frappe.throw(_("First 2 digits of GSTIN should match with State number {0}")
-					.format(doc.gst_state_number))
\ No newline at end of file
+					.format(doc.gst_state_number))
diff --git a/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json b/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json
index 8d12336..3850847 100644
--- a/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json
+++ b/erpnext/regional/print_format/gst_tax_invoice/gst_tax_invoice.json
@@ -7,10 +7,10 @@
  "docstatus": 0, 
  "doctype": "Print Format", 
  "font": "Default", 
- "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"<div class=\\\"print-heading\\\">\\n\\t<h2>\\n\\t\\tSALES INVOICE<br>\\n\\t\\t<small>{{ doc.name }}</small>\\n\\t</h2>\\n</div>\\n<h2 class=\\\"text-right\\\">\\n\\t{% if doc.invoice_copy -%}\\n\\t\\t<small><i>({{ doc.invoice_copy }})</i></small>\\n\\t{% endif -%}\\n</h2>\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"print_hide\": 0, \"fieldname\": \"due_date\", \"label\": \"Payment Due Date\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"options\": \"<hr>\", \"fieldname\": \"_custom_html\", \"fieldtype\": \"HTML\", \"label\": \"Custom HTML\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"address_display\", \"label\": \"Address\"}, {\"print_hide\": 0, \"fieldname\": \"contact_display\", \"label\": \"Contact\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"shipping_address\", \"label\": \"Shipping Address\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"gst_hsn_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"qty\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"label\": \"In Words\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"other_charges_calculation\", \"align\": \"left\", \"label\": \"Item-wise Tax Breakup\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Terms\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"terms\", \"label\": \"Terms and Conditions Details\"}]", 
+ "format_data": "[{\"fieldname\": \"print_heading_template\", \"fieldtype\": \"Custom HTML\", \"options\": \"<div class=\\\"print-heading\\\">\\n\\t<h2>\\n\\t\\tTAX INVOICE<br>\\n\\t\\t<small>{{ doc.name }}</small>\\n\\t</h2>\\n</div>\\n<h2 class=\\\"text-center\\\">\\n\\t{% if doc.invoice_copy -%}\\n\\t\\t<small>{{ doc.invoice_copy }}</small>\\n\\t{% endif -%}\\n</h2>\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"company\", \"label\": \"Company\"}, {\"print_hide\": 0, \"fieldname\": \"company_address_display\", \"label\": \"Company Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"posting_date\", \"label\": \"Date\"}, {\"print_hide\": 0, \"fieldname\": \"due_date\", \"label\": \"Payment Due Date\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"options\": \"<hr>\", \"fieldname\": \"_custom_html\", \"fieldtype\": \"HTML\", \"label\": \"Custom HTML\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Address\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"customer_name\", \"label\": \"Customer Name\"}, {\"print_hide\": 0, \"fieldname\": \"address_display\", \"label\": \"Address\"}, {\"print_hide\": 0, \"fieldname\": \"contact_display\", \"label\": \"Contact\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"shipping_address\", \"label\": \"Shipping Address\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"item_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"200px\"}, {\"print_hide\": 0, \"fieldname\": \"gst_hsn_code\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"qty\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"uom\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"rate\", \"print_width\": \"\"}, {\"print_hide\": 0, \"fieldname\": \"amount\", \"print_width\": \"\"}], \"print_hide\": 0, \"fieldname\": \"items\", \"label\": \"Items\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"total\", \"label\": \"Total\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"visible_columns\": [{\"print_hide\": 0, \"fieldname\": \"description\", \"print_width\": \"300px\"}], \"print_hide\": 0, \"fieldname\": \"taxes\", \"label\": \"Sales Taxes and Charges\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"grand_total\", \"label\": \"Grand Total\"}, {\"print_hide\": 0, \"fieldname\": \"rounded_total\", \"label\": \"Rounded Total\"}, {\"print_hide\": 0, \"fieldname\": \"in_words\", \"label\": \"In Words\"}, {\"fieldtype\": \"Section Break\", \"label\": \"\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"other_charges_calculation\", \"align\": \"left\", \"label\": \"Tax Breakup\"}, {\"fieldtype\": \"Section Break\", \"label\": \"Terms\"}, {\"fieldtype\": \"Column Break\"}, {\"print_hide\": 0, \"fieldname\": \"terms\", \"label\": \"Terms and Conditions Details\"}]", 
  "idx": 0, 
  "line_breaks": 0, 
- "modified": "2017-07-06 13:45:55.033384", 
+ "modified": "2017-07-07 13:06:20.042807", 
  "modified_by": "Administrator", 
  "module": "Regional", 
  "name": "GST Tax Invoice", 
diff --git a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js
index 93c83f3..c5ff917 100644
--- a/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js
+++ b/erpnext/schools/doctype/student_attendance_tool/student_attendance_tool.js
@@ -135,22 +135,24 @@
 				frappe.confirm(__("Do you want to update attendance?<br>Present: {0}\
 					<br>Absent: {1}", [students_present.length, students_absent.length]),
 					function() {	//ifyes
-						frappe.call({
-							method: "erpnext.schools.api.mark_attendance",
-							freeze: true,
-							freeze_message: "Marking attendance",
-							args: {
-								"students_present": students_present,
-								"students_absent": students_absent,
-								"student_group": frm.doc.student_group,
-								"course_schedule": frm.doc.course_schedule,
-								"date": frm.doc.date
-							},
-							callback: function(r) {
-								$(me.wrapper.find(".btn-mark-att")).attr("disabled", false);
-								frm.trigger("student_group");
-							}
-						});
+						if(!frappe.request.ajax_count) {
+							frappe.call({
+								method: "erpnext.schools.api.mark_attendance",
+								freeze: true,
+								freeze_message: "Marking attendance",
+								args: {
+									"students_present": students_present,
+									"students_absent": students_absent,
+									"student_group": frm.doc.student_group,
+									"course_schedule": frm.doc.course_schedule,
+									"date": frm.doc.date
+								},
+								callback: function(r) {
+									$(me.wrapper.find(".btn-mark-att")).attr("disabled", false);
+									frm.trigger("student_group");
+								}
+							});
+						}
 					},
 					function() {	//ifno
 						$(me.wrapper.find(".btn-mark-att")).attr("disabled", false);
diff --git a/erpnext/schools/doctype/student_log/student_log.json b/erpnext/schools/doctype/student_log/student_log.json
index 43ac134..6c9d4b0 100644
--- a/erpnext/schools/doctype/student_log/student_log.json
+++ b/erpnext/schools/doctype/student_log/student_log.json
@@ -1,5 +1,6 @@
 {
  "allow_copy": 0, 
+ "allow_guest_to_view": 0, 
  "allow_import": 0, 
  "allow_rename": 0, 
  "autoname": "SLog.####", 
@@ -13,6 +14,7 @@
  "engine": "InnoDB", 
  "fields": [
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -43,64 +45,7 @@
    "unique": 0
   }, 
   {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "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": "Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "General\nAcademic\nMedical\nAchievement", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_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, 
-   "unique": 0
-  }, 
-  {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -131,6 +76,38 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "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": "Type", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "General\nAcademic\nMedical\nAchievement", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -160,6 +137,160 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 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, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "academic_year", 
+   "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": "Academic Year", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Academic Year", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "academic_term", 
+   "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": "Academic Term", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Academic Term", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "program", 
+   "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": "Program", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Program", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "student_batch", 
+   "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": "Student Batch", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Student Batch Name", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -188,6 +319,7 @@
    "unique": 0
   }, 
   {
+   "allow_bulk_edit": 0, 
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
@@ -217,17 +349,17 @@
    "unique": 0
   }
  ], 
+ "has_web_view": 0, 
  "hide_heading": 0, 
  "hide_toolbar": 0, 
  "idx": 0, 
  "image_view": 0, 
  "in_create": 0, 
- "in_dialog": 0, 
  "is_submittable": 0, 
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2017-02-17 17:18:19.596892", 
+ "modified": "2017-07-06 12:42:05.777673", 
  "modified_by": "Administrator", 
  "module": "Schools", 
  "name": "Student Log", 
diff --git a/erpnext/selling/doctype/installation_note/installation_note.js b/erpnext/selling/doctype/installation_note/installation_note.js
index ab35574..9f0c050 100644
--- a/erpnext/selling/doctype/installation_note/installation_note.js
+++ b/erpnext/selling/doctype/installation_note/installation_note.js
@@ -30,12 +30,8 @@
 	setup_queries: function() {
 		var me = this;
 
-		this.frm.set_query("customer_address", function() {
-			return {
-				filters: {'customer': me.frm.doc.customer }
-			}
-		});
-
+		frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'customer', doctype: 'Customer'}
+		frm.set_query('customer_address', erpnext.queries.address_query);
 		this.frm.set_query('contact_person', erpnext.queries.contact_query);
 
 		this.frm.set_query("customer", function() {
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index b102e1d..a4d4bf9 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -86,6 +86,17 @@
 			print_lst.append(lst1)
 		return print_lst
 
+def get_list_context(context=None):
+	from erpnext.controllers.website_list_for_contact import get_list_context
+	list_context = get_list_context(context)
+	list_context.update({
+		'show_sidebar': True,
+		'show_search': True,
+		'no_breadcrumbs': True,
+		'title': _('Quotes'),
+	})
+
+	return list_context
 
 @frappe.whitelist()
 def make_sales_order(source_name, target_doc=None):
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index adff615..8d027b3 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -69,7 +69,7 @@
 		context.update({
 			"items": get_product_list_for_group(product_group = self.name, start=start,
 				limit=context.page_length + 1, search=frappe.form_dict.get("search")),
-			"parent_groups": get_parent_item_groups(self.name),
+			"parents": get_parent_item_groups(self.parent_item_group),
 			"title": self.name,
 			"products_as_list": cint(frappe.db.get_single_value('Website Settings', 'products_as_list'))
 		})
@@ -136,7 +136,8 @@
 
 def get_parent_item_groups(item_group_name):
 	item_group = frappe.get_doc("Item Group", item_group_name)
-	return frappe.db.sql("""select name, route from `tabItem Group`
+	return 	[{"name": frappe._("Home"),"route":"/"}]+\
+		frappe.db.sql("""select name, route from `tabItem Group`
 		where lft <= %s and rgt >= %s
 		and show_in_website=1
 		order by lft asc""", (item_group.lft, item_group.rgt), as_dict=True)
@@ -146,6 +147,7 @@
 		item_group = doc.name
 
 	for d in get_parent_item_groups(item_group):
-		d = frappe.get_doc("Item Group", d.name)
-		if d.route:
-			clear_cache(d.route)
+		if frappe.db.exists("Item Group", d.get("name")):
+			d = frappe.get_doc("Item Group", d.get("name"))
+			if d.route:
+				clear_cache(d.route)
diff --git a/erpnext/setup/setup_wizard/setup_wizard.py b/erpnext/setup/setup_wizard/setup_wizard.py
index 3005ed6..5134ee1 100644
--- a/erpnext/setup/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/setup_wizard/setup_wizard.py
@@ -351,7 +351,7 @@
 	for i in xrange(1,6):
 		item = args.get("item_" + str(i))
 		if item:
-			item_group = args.get("item_group_" + str(i))
+			item_group = _(args.get("item_group_" + str(i)))
 			is_sales_item = args.get("is_sales_item_" + str(i))
 			is_purchase_item = args.get("is_purchase_item_" + str(i))
 			is_stock_item = item_group!=_("Services")
@@ -373,7 +373,7 @@
 					"is_purchase_item": is_purchase_item,
 					"is_stock_item": is_stock_item and 1 or 0,
 					"item_group": item_group,
-					"stock_uom": args.get("item_uom_" + str(i)),
+					"stock_uom": _(args.get("item_uom_" + str(i))),
 					"default_warehouse": default_warehouse
 				}).insert()
 
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 9328194..2c6aab5 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -146,10 +146,6 @@
 			return cstr(frappe.db.get_value('Item Group', self.item_group,
 				'route')) + '/' + self.scrub(self.item_name + '-' + random_string(5))
 
-	def get_parents(self, context):
-		item_group, route = frappe.db.get_value('Item Group', self.item_group, ['name', 'route'])
-		context.parents = [{'name': route, 'label': item_group}]
-
 	def validate_website_image(self):
 		"""Validate if the website image is a public file"""
 		auto_set_website_image = False
@@ -242,15 +238,12 @@
 		context.show_search=True
 		context.search_link = '/product_search'
 
-		context.parent_groups = get_parent_item_groups(self.item_group) + \
-			[{"name": self.name}]
+		context.parents = get_parent_item_groups(self.item_group)
 
 		self.set_variant_context(context)
 		self.set_attribute_context(context)
 		self.set_disabled_attributes(context)
 
-		self.get_parents(context)
-
 		return context
 
 	def set_variant_context(self, context):
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
index 5f1e944..aca77a5 100755
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.json
@@ -1597,7 +1597,7 @@
    "collapsible": 0,
    "columns": 0,
    "default": ":Company",
-   "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)",
+   "depends_on": "eval:cint(erpnext.is_perpetual_inventory_enabled(parent.company))",
    "fieldname": "cost_center",
    "fieldtype": "Link",
    "hidden": 0,
@@ -2044,7 +2044,7 @@
  "issingle": 0,
  "istable": 1,
  "max_attachments": 0,
- "modified": "2017-06-16 17:23:01.404744",
+ "modified": "2017-07-10 06:31:31.457497",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Purchase Receipt Item",
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
index ec14aab..6afb54e 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.json
@@ -960,7 +960,7 @@
    "bold": 0,
    "collapsible": 0,
    "columns": 0,
-   "depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
+   "depends_on": "eval:cint(erpnext.is_perpetual_inventory_enabled(parent.company))",
    "fieldname": "expense_account",
    "fieldtype": "Link",
    "hidden": 0,
@@ -1020,7 +1020,7 @@
    "collapsible": 0,
    "columns": 0,
    "default": ":Company",
-   "depends_on": "eval:cint(frappe.sys_defaults.auto_accounting_for_stock)",
+   "depends_on": "eval:cint(erpnext.is_perpetual_inventory_enabled(parent.company))",
    "fieldname": "cost_center",
    "fieldtype": "Link",
    "hidden": 0,
@@ -1266,7 +1266,7 @@
  "issingle": 0,
  "istable": 1,
  "max_attachments": 0,
- "modified": "2017-06-16 17:32:56.989049",
+ "modified": "2017-07-10 06:29:22.805345",
  "modified_by": "Administrator",
  "module": "Stock",
  "name": "Stock Entry Detail",