Merge pull request #17388 from ashish-greycube/correct_party_type_values

fix: show only party_type doctypes in Party Type field of bank account
diff --git a/erpnext/accounts/doctype/c_form/c_form.js b/erpnext/accounts/doctype/c_form/c_form.js
index 92cdb63..3d0fc0a 100644
--- a/erpnext/accounts/doctype/c_form/c_form.js
+++ b/erpnext/accounts/doctype/c_form/c_form.js
@@ -4,24 +4,38 @@
 //c-form js file
 // -----------------------------
 
+frappe.ui.form.on('C-Form', {
+	setup(frm) {
+		frm.fields_dict.invoices.grid.get_field("invoice_no").get_query = function(doc) {
+			return {
+				filters: {
+					"docstatus": 1,
+					"customer": doc.customer,
+					"company": doc.company,
+					"c_form_applicable": 'Yes',
+					"c_form_no": ''
+				}
+			};
+		}
 
-cur_frm.fields_dict.invoices.grid.get_field("invoice_no").get_query = function(doc) {
-	return {
-		filters: {
-			"docstatus": 1,
-			"customer": doc.customer,
-			"company": doc.company,
-			"c_form_applicable": 'Yes',
-			"c_form_no": ''
+		frm.fields_dict.state.get_query = function() {
+			return {
+				filters: {
+					country: "India"
+				}
+			};
 		}
 	}
-}
+});
 
-cur_frm.fields_dict.state.get_query = function(doc) {
-	return {filters: { country: "India"}}
-}
+frappe.ui.form.on('C-Form Invoice Detail', {
+	invoice_no(frm, cdt, cdn) {
+		let d = frappe.get_doc(cdt, cdn);
 
-cur_frm.cscript.invoice_no = function(doc, cdt, cdn) {
-	var d = locals[cdt][cdn];
-	return get_server_fields('get_invoice_details', d.invoice_no, 'invoices', doc, cdt, cdn, 1);
-}
\ No newline at end of file
+		frm.call('get_invoice_details', {
+			invoice_no: d.invoice_no
+		}).then(r => {
+			frappe.model.set_value(cdt, cdn, r.message);
+		});
+	}
+});
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js
index 3df4da5..96ec57d 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.js
+++ b/erpnext/accounts/doctype/cost_center/cost_center.js
@@ -22,6 +22,28 @@
 				frm.trigger("update_cost_center_number");
 			});
 		}
+
+		let intro_txt = '';
+		let doc = frm.doc;
+		frm.toggle_display('cost_center_name', doc.__islocal);
+		frm.toggle_enable(['is_group', 'company'], doc.__islocal);
+
+		if(!doc.__islocal && doc.is_group==1) {
+			intro_txt += __('Note: This Cost Center is a Group. Cannot make accounting entries against groups.');
+		}
+
+		frm.events.hide_unhide_group_ledger(frm);
+
+		frm.toggle_display('sb1', doc.is_group==0);
+		frm.set_intro(intro_txt);
+
+		if(!frm.doc.__islocal) {
+			frm.add_custom_button(__('Chart of Cost Centers'),
+				function() { frappe.set_route("Tree", "Cost Center"); });
+
+			frm.add_custom_button(__('Budget'),
+				function() { frappe.set_route("List", "Budget", {'cost_center': frm.doc.name}); });
+		}
 	},
 	update_cost_center_number: function(frm) {
 		var d = new frappe.ui.Dialog({
@@ -64,62 +86,38 @@
 			primary_action_label: __('Update')
 		});
 		d.show();
+	},
+
+	parent_cost_center(frm) {
+		if(!frm.doc.company) {
+			frappe.msgprint(__('Please enter company name first'));
+		}
+	},
+
+	hide_unhide_group_ledger(frm) {
+		let doc = frm.doc;
+		if (doc.is_group == 1) {
+			frm.add_custom_button(__('Convert to Non-Group'),
+				() => frm.events.convert_to_ledger(frm));
+		} else if (doc.is_group == 0) {
+			frm.add_custom_button(__('Convert to Group'),
+				() => frm.events.convert_to_group(frm));
+		}
+	},
+
+	convert_to_group(frm) {
+		frm.call('convert_ledger_to_group').then(r => {
+			if(r.message === 1) {
+				frm.refresh();
+			}
+		});
+	},
+
+	convert_to_ledger(frm) {
+		frm.call('convert_group_to_ledger').then(r => {
+			if(r.message === 1) {
+				frm.refresh();
+			}
+		});
 	}
 });
-
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
-	var intro_txt = '';
-	cur_frm.toggle_display('cost_center_name', doc.__islocal);
-	cur_frm.toggle_enable(['is_group', 'company'], doc.__islocal);
-
-	if(!doc.__islocal && doc.is_group==1) {
-		intro_txt += __('Note: This Cost Center is a Group. Cannot make accounting entries against groups.');
-	}
-
-	cur_frm.cscript.hide_unhide_group_ledger(doc);
-
-	cur_frm.toggle_display('sb1', doc.is_group==0)
-	cur_frm.set_intro(intro_txt);
-
-	if(!cur_frm.doc.__islocal) {
-		cur_frm.add_custom_button(__('Chart of Cost Centers'),
-			function() { frappe.set_route("Tree", "Cost Center"); });
-
-		cur_frm.add_custom_button(__('Budget'),
-			function() { frappe.set_route("List", "Budget", {'cost_center': cur_frm.doc.name}); });
-	}
-}
-
-cur_frm.cscript.parent_cost_center = function(doc, cdt, cdn) {
-	if(!doc.company){
-		frappe.msgprint(__('Please enter company name first'));
-	}
-}
-
-cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
-	if (doc.is_group == 1) {
-		cur_frm.add_custom_button(__('Convert to Non-Group'),
-			function() { cur_frm.cscript.convert_to_ledger(); }, "fa fa-retweet",
-				"btn-default")
-	} else if (doc.is_group == 0) {
-		cur_frm.add_custom_button(__('Convert to Group'),
-			function() { cur_frm.cscript.convert_to_group(); }, "fa fa-retweet",
-				"btn-default")
-	}
-}
-
-cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
-	return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) {
-		if(r.message == 1) {
-			cur_frm.refresh();
-		}
-	});
-}
-
-cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
-	return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) {
-		if(r.message == 1) {
-			cur_frm.refresh();
-		}
-	});
-}
diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js
index 4dc6433..152e17d 100644
--- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.js
+++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.js
@@ -1,37 +1,31 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-$.extend(cur_frm.cscript, {
-	onload: function() {
-		if(cur_frm.doc.__islocal) {
-			cur_frm.set_value("year_start_date",
+frappe.ui.form.on('Fiscal Year', {
+	onload: function(frm) {
+		if(frm.doc.__islocal) {
+			frm.set_value("year_start_date",
 				frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1));
 		}
 	},
-	refresh: function (doc, dt, dn) {
-		var me = this;
-		this.frm.toggle_enable('year_start_date', doc.__islocal)
-		this.frm.toggle_enable('year_end_date', doc.__islocal)
+	refresh: function (frm) {
+		let doc = frm.doc;
+		frm.toggle_enable('year_start_date', doc.__islocal);
+		frm.toggle_enable('year_end_date', doc.__islocal);
 
 		if (!doc.__islocal && (doc.name != frappe.sys_defaults.fiscal_year)) {
-			this.frm.add_custom_button(__("Default"),
-				this.frm.cscript.set_as_default, "fa fa-star");
-			this.frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'"));
+			frm.add_custom_button(__("Set as Default"), () => frm.events.set_as_default(frm));
+			frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'"));
 		} else {
-			this.frm.set_intro("");
+			frm.set_intro("");
 		}
 	},
-	set_as_default: function() {
-		return frappe.call({
-			doc: cur_frm.doc,
-			method: "set_as_default"
-		});
+	set_as_default: function(frm) {
+		return frm.call('set_as_default');
 	},
-	year_start_date: function(doc, dt, dn) {
-		var me = this;
-
-		var year_end_date =
-			frappe.datetime.add_days(frappe.datetime.add_months(this.frm.doc.year_start_date, 12), -1);
-		this.frm.set_value("year_end_date", year_end_date);
+	year_start_date: function(frm) {
+		let year_end_date =
+			frappe.datetime.add_days(frappe.datetime.add_months(frm.doc.year_start_date, 12), -1);
+		frm.set_value("year_end_date", year_end_date);
 	},
 });
diff --git a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js
index 7b489de..569f008 100644
--- a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js
+++ b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.js
@@ -1,16 +1,16 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-cur_frm.cscript.onload = function(doc,cdt,cdn){
-	if(doc.__islocal){
-		var callback1 = function(r,rt){
-			refresh_field('percentages');
+frappe.ui.form.on('Monthly Distribution', {
+	onload(frm) {
+		if(frm.doc.__islocal) {
+			return frm.call('get_months').then(() => {
+				frm.refresh_field('percentages');
+			});
 		}
+	},
 
-		return $c('runserverobj', {'method':'get_months', 'docs':doc}, callback1);
+	refresh(frm) {
+		frm.toggle_display('distribution_id', frm.doc.__islocal);
 	}
-}
-
-cur_frm.cscript.refresh = function(doc,cdt,cdn){
-	cur_frm.toggle_display('distribution_id', doc.__islocal);
-}
+});
diff --git a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js
index e1fe5a1..8f09bc3 100644
--- a/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js
+++ b/erpnext/accounts/doctype/payment_gateway_account/payment_gateway_account.js
@@ -1,6 +1,10 @@
-cur_frm.cscript.refresh = function(doc, dt, dn){
-	if(!doc.__islocal){
-		var df = frappe.meta.get_docfield(doc.doctype, "payment_gateway", doc.name);
-		df.read_only = 1;
+// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
+// License: GNU General Public License v3. See license.txt
+
+frappe.ui.form.on('Payment Gateway Account', {
+	refresh(frm) {
+		if(!frm.doc.__islocal) {
+			frm.set_df_property('payment_gateway', 'read_only', 1);
+		}
 	}
-}
\ No newline at end of file
+});
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
index e5b6336..c92b58b 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.js
@@ -1,108 +1,6 @@
 // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
 // License: GNU General Public License v3. See license.txt
 
-frappe.ui.form.on("Pricing Rule", "refresh", function(frm) {
-	var help_content =
-		`<table class="table table-bordered" style="background-color: #f9f9f9;">
-			<tr><td>
-				<h4>
-					<i class="fa fa-hand-right"></i>
-					${__('Notes')}
-				</h4>
-				<ul>
-					<li>
-						${__("Pricing Rule is made to overwrite Price List / define discount percentage, based on some criteria.")}
-					</li>
-					<li>
-						${__("If selected Pricing Rule is made for 'Rate', it will overwrite Price List. Pricing Rule rate is the final rate, so no further discount should be applied. Hence, in transactions like Sales Order, Purchase Order etc, it will be fetched in 'Rate' field, rather than 'Price List Rate' field.")}
-					</li>
-					<li>
-						${__('Discount Percentage can be applied either against a Price List or for all Price List.')}
-					</li>
-					<li>
-						${__('To not apply Pricing Rule in a particular transaction, all applicable Pricing Rules should be disabled.')}
-					</li>
-				</ul>
-			</td></tr>
-			<tr><td>
-				<h4><i class="fa fa-question-sign"></i>
-					${__('How Pricing Rule is applied?')}
-				</h4>
-				<ol>
-					<li>
-						${__("Pricing Rule is first selected based on 'Apply On' field, which can be Item, Item Group or Brand.")}
-					</li>
-					<li>
-						${__("Then Pricing Rules are filtered out based on Customer, Customer Group, Territory, Supplier, Supplier Group, Campaign, Sales Partner etc.")}
-					</li>
-					<li>
-						${__('Pricing Rules are further filtered based on quantity.')}
-					</li>
-					<li>
-						${__('If two or more Pricing Rules are found based on the above conditions, Priority is applied. Priority is a number between 0 to 20 while default value is zero (blank). Higher number means it will take precedence if there are multiple Pricing Rules with same conditions.')}
-					</li>
-					<li>
-						${__('Even if there are multiple Pricing Rules with highest priority, then following internal priorities are applied:')}
-						<ul>
-							<li>
-								${__('Item Code > Item Group > Brand')}
-							</li>
-							<li>
-								${__('Customer > Customer Group > Territory')}
-							</li>
-							<li>
-								${__('Supplier > Supplier Group')}
-							</li>
-						</ul>
-					</li>
-					<li>
-						${__('If multiple Pricing Rules continue to prevail, users are asked to set Priority manually to resolve conflict.')}
-					</li>
-				</ol>
-			</td></tr>
-		</table>`;
-
-	set_field_options("pricing_rule_help", help_content);
-
-	cur_frm.cscript.set_options_for_applicable_for();
-});
-
-cur_frm.cscript.set_options_for_applicable_for = function() {
-	var options = [""];
-	var applicable_for = cur_frm.doc.applicable_for;
-
-	if(cur_frm.doc.selling) {
-		options = $.merge(options, ["Customer", "Customer Group", "Territory", "Sales Partner", "Campaign"]);
-	}
-	if(cur_frm.doc.buying) {
-		$.merge(options, ["Supplier", "Supplier Group"]);
-	}
-
-	set_field_options("applicable_for", options.join("\n"));
-
-	if(!in_list(options, applicable_for)) applicable_for = null;
-	cur_frm.set_value("applicable_for", applicable_for)
-}
-
-cur_frm.cscript.selling = function() {
-	cur_frm.cscript.set_options_for_applicable_for();
-}
-
-cur_frm.cscript.buying = function() {
-	cur_frm.cscript.set_options_for_applicable_for();
-}
-
-//Dynamically change the description based on type of margin
-cur_frm.cscript.margin_type = function(doc){
-	cur_frm.set_df_property('margin_rate_or_amount', 'description', doc.margin_type=='Percentage'?'In Percentage %':'In Amount')
-}
-
-frappe.ui.form.on('Pricing Rule', 'rate_or_discount', function(frm){
-	if(frm.doc.rate_or_discount == 'Rate') {
-		frm.set_value('for_price_list', "")
-	}
-})
-
 frappe.ui.form.on('Pricing Rule', {
 	setup: function(frm) {
 		frm.fields_dict["for_price_list"].get_query = function(doc){
@@ -199,7 +97,7 @@
 				</td></tr>
 			</table>`;
 
-		set_field_options("pricing_rule_help", help_content);
+		frm.set_df_property('pricing_rule_help', 'options', help_content);
 		frm.events.set_options_for_applicable_for(frm);
 		frm.trigger("toggle_reqd_apply_on");
 	},
@@ -256,5 +154,4 @@
 		if(!in_list(options, applicable_for)) applicable_for = null;
 		frm.set_value("applicable_for", applicable_for);
 	}
-
 });
diff --git a/erpnext/assets/doctype/asset/asset.js b/erpnext/assets/doctype/asset/asset.js
index e9a0f70..2d78d26 100644
--- a/erpnext/assets/doctype/asset/asset.js
+++ b/erpnext/assets/doctype/asset/asset.js
@@ -296,6 +296,12 @@
 		frm.toggle_reqd("finance_books", frm.doc.calculate_depreciation);
 	},
 
+	gross_purchase_amount: function(frm) {
+		frm.doc.finance_books.forEach(d => {
+			frm.events.set_depreciation_rate(frm, d);
+		})
+	},
+
 	set_depreciation_rate: function(frm, row) {
 		if (row.total_number_of_depreciations && row.frequency_of_depreciation) {
 			frappe.call({
diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py
index 8011038..72f5c62 100644
--- a/erpnext/assets/doctype/asset/asset.py
+++ b/erpnext/assets/doctype/asset/asset.py
@@ -101,7 +101,7 @@
 
 	def set_depreciation_rate(self):
 		for d in self.get("finance_books"):
-			d.rate_of_depreciation = self.get_depreciation_rate(d)
+			d.rate_of_depreciation = self.get_depreciation_rate(d, on_validate=True)
 
 	def make_depreciation_schedule(self):
 		depreciation_method = [d.depreciation_method for d in self.finance_books]
@@ -125,7 +125,7 @@
 					no_of_depreciations * cint(d.frequency_of_depreciation))
 
 				total_days = date_diff(end_date, self.available_for_use_date)
-				rate_per_day = value_after_depreciation / total_days
+				rate_per_day = (value_after_depreciation - d.get("expected_value_after_useful_life")) / total_days
 
 				number_of_pending_depreciations = cint(d.total_number_of_depreciations) - \
 					cint(self.number_of_depreciations_booked)
@@ -291,8 +291,8 @@
 
 	def validate_expected_value_after_useful_life(self):
 		for row in self.get('finance_books'):
-			accumulated_depreciation_after_full_schedule = \
-				max([d.accumulated_depreciation_amount for d in self.get("schedules") if d.finance_book_id == row.idx])
+			accumulated_depreciation_after_full_schedule = max([d.accumulated_depreciation_amount
+				for d in self.get("schedules") if cint(d.finance_book_id) == row.idx])
 
 			asset_value_after_full_schedule = flt(flt(self.gross_purchase_amount) -
 				flt(accumulated_depreciation_after_full_schedule),
@@ -403,7 +403,7 @@
 			make_gl_entries(gl_entries)
 			self.db_set('booked_fixed_asset', 1)
 
-	def get_depreciation_rate(self, args):
+	def get_depreciation_rate(self, args, on_validate=False):
 		if isinstance(args, string_types):
 			args = json.loads(args)
 
@@ -420,7 +420,10 @@
 		if args.get("depreciation_method") == 'Double Declining Balance':
 			return 200.0 / args.get("total_number_of_depreciations")
 
-		if args.get("depreciation_method") == "Written Down Value" and not args.get("rate_of_depreciation"):
+		if args.get("depreciation_method") == "Written Down Value":
+			if args.get("rate_of_depreciation") and on_validate:
+				return args.get("rate_of_depreciation")
+
 			no_of_years = flt(args.get("total_number_of_depreciations") * flt(args.get("frequency_of_depreciation"))) / 12
 			value = flt(args.get("expected_value_after_useful_life")) / flt(self.gross_purchase_amount)
 
diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py
index 985097b..ef85ffa 100644
--- a/erpnext/assets/doctype/asset/test_asset.py
+++ b/erpnext/assets/doctype/asset/test_asset.py
@@ -102,9 +102,9 @@
 		asset.save()
 		self.assertEqual(asset.status, "Draft")
 		expected_schedules = [
-			["2020-06-06", 163.93, 163.93],
-			["2021-04-06", 49836.07, 50000.0],
-			["2022-02-06", 40000.0, 90000.00]
+			["2020-06-06", 147.54, 147.54],
+			["2021-04-06", 44852.46, 45000.0],
+			["2022-02-06", 45000.0, 90000.00]
 		]
 
 		schedules = [[cstr(d.schedule_date), d.depreciation_amount, d.accumulated_depreciation_amount]
@@ -130,8 +130,8 @@
 		self.assertEqual(asset.status, "Draft")
 		asset.save()
 		expected_schedules = [
-			["2020-06-06", 197.37, 40197.37],
-			["2021-04-06", 49802.63, 90000.00]
+			["2020-06-06", 164.47, 40164.47],
+			["2021-04-06", 49835.53, 90000.00]
 		]
 		schedules = [[cstr(d.schedule_date), flt(d.depreciation_amount, 2), d.accumulated_depreciation_amount]
 			for d in asset.get("schedules")]
@@ -266,8 +266,8 @@
 		self.assertEqual(asset.get("schedules")[0].journal_entry[:4], "DEPR")
 
 		expected_gle = (
-			("_Test Accumulated Depreciations - _TC", 0.0, 35699.15),
-			("_Test Depreciations - _TC", 35699.15, 0.0)
+			("_Test Accumulated Depreciations - _TC", 0.0, 32129.24),
+			("_Test Depreciations - _TC", 32129.24, 0.0)
 		)
 
 		gle = frappe.db.sql("""select account, debit, credit from `tabGL Entry`
diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py
index 1885504..6206dfd 100644
--- a/erpnext/demo/user/accounts.py
+++ b/erpnext/demo/user/accounts.py
@@ -4,6 +4,7 @@
 
 from __future__ import unicode_literals
 
+import erpnext
 import frappe
 import random
 from frappe.utils import random_string
@@ -72,8 +73,10 @@
 	make_pos_invoice()
 
 def make_payment_entries(ref_doctype, report):
-	outstanding_invoices = list(set([r[3] for r in query_report.run(report,
-	{"report_date": frappe.flags.current_date })["result"] if r[2]==ref_doctype]))
+	outstanding_invoices = list(set([r[3] for r in query_report.run(report, {
+						"report_date": frappe.flags.current_date,
+						"company": erpnext.get_default_company()
+					})["result"] if r[2]==ref_doctype]))
 
 	# make Payment Entry
 	for inv in outstanding_invoices[:random.randint(1, 2)]:
diff --git a/erpnext/demo/user/manufacturing.py b/erpnext/demo/user/manufacturing.py
index a28d061..bece079 100644
--- a/erpnext/demo/user/manufacturing.py
+++ b/erpnext/demo/user/manufacturing.py
@@ -102,10 +102,18 @@
 
 	for operation in work_order.operations:
 		job = job_map[operation.operation]
-		job.actual_start_date = start_date
+		job_time_log = frappe.new_doc("Job Card Time Log")
+		job_time_log.from_time = start_date
 		minutes = operation.get("time_in_mins")
-		random_minutes = random.randint(int(minutes/2), minutes)
-		job.actual_end_date = job.actual_start_date + timedelta(minutes=random_minutes)
-		start_date = job.actual_end_date
-		job.save()
+		job_time_log.time_in_mins = random.randint(int(minutes/2), minutes)
+		job_time_log.to_time = job_time_log.from_time + \
+					timedelta(minutes=job_time_log.time_in_mins)
+		job_time_log.parent = job.name
+		job_time_log.parenttype = 'Job Card'
+		job_time_log.parentfield = 'time_logs'
+		job_time_log.completed_qty = work_order.qty
+		job_time_log.save(ignore_permissions=True)
+		job.time_logs.append(job_time_log)
+		job.save(ignore_permissions=True)
 		job.submit()
+		start_date = job_time_log.to_time
diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py
index 69ba900..d4b55e8 100644
--- a/erpnext/demo/user/sales.py
+++ b/erpnext/demo/user/sales.py
@@ -21,17 +21,26 @@
 		if random.random() < 0.5:
 			make_quotation(domain)
 
+	try:
+		lost_reason = frappe.get_doc({
+			"doctype": "Opportunity Lost Reason",
+			"lost_reason": "Did not ask"
+		})
+		lost_reason.save(ignore_permissions=True)
+	except frappe.exceptions.DuplicateEntryError:
+		pass
+
 	# lost quotations / inquiries
 	if random.random() < 0.3:
 		for i in range(random.randint(1,3)):
 			quotation = get_random('Quotation', doc=True)
 			if quotation and quotation.status == 'Submitted':
-				quotation.declare_order_lost('Did not ask')
+				quotation.declare_order_lost([{'lost_reason': 'Did not ask'}])
 
 		for i in range(random.randint(1,3)):
 			opportunity = get_random('Opportunity', doc=True)
 			if opportunity and opportunity.status in ('Open', 'Replied'):
-				opportunity.declare_enquiry_lost('Did not ask')
+				opportunity.declare_enquiry_lost([{'lost_reason': 'Did not ask'}])
 
 	for i in range(random.randint(1,3)):
 		if random.random() < 0.6:
diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py
index 60b1edc..f95a6b8 100644
--- a/erpnext/demo/user/stock.py
+++ b/erpnext/demo/user/stock.py
@@ -73,13 +73,13 @@
 		stock_reco = frappe.new_doc("Stock Reconciliation")
 		stock_reco.posting_date = frappe.flags.current_date
 		stock_reco.company = erpnext.get_default_company()
-		stock_reco.get_items_for("Stores - WP")
+		stock_reco.get_items_for("Stores - WPL")
 		if stock_reco.items:
 			for item in stock_reco.items:
 				if item.qty:
 					item.qty = item.qty - round(random.randint(1, item.qty))
 			try:
-				stock_reco.insert()
+				stock_reco.insert(ignore_permissions=True)
 				stock_reco.submit()
 				frappe.db.commit()
 			except OpeningEntryAccountError:
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/__init__.py b/erpnext/erpnext_integrations/doctype/tally_migration/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/__init__.py
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
new file mode 100644
index 0000000..104ac57
--- /dev/null
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.js
@@ -0,0 +1,50 @@
+// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Tally Migration', {
+	onload: function(frm) {
+		frappe.realtime.on("tally_migration_progress_update", function (data) {
+			frm.dashboard.show_progress(data.title, (data.count / data.total) * 100, data.message);
+			if (data.count == data.total) {
+				window.setTimeout(title => frm.dashboard.hide_progress(title), 1500, data.title);
+			}
+		});
+	},
+	refresh: function(frm) {
+		if (frm.doc.master_data && !frm.doc.is_master_data_imported) {
+			if (frm.doc.is_master_data_processed) {
+				if (frm.doc.status != "Importing Master Data") {
+					frm.events.add_button(frm, __("Import Master Data"), "import_master_data");
+				}
+			} else {
+				if (frm.doc.status != "Processing Master Data") {
+					frm.events.add_button(frm, __("Process Master Data"), "process_master_data");
+				}
+			}
+		}
+		if (frm.doc.day_book_data && !frm.doc.is_day_book_data_imported) {
+			if (frm.doc.is_day_book_data_processed) {
+				if (frm.doc.status != "Importing Day Book Data") {
+					frm.events.add_button(frm, __("Import Day Book Data"), "import_day_book_data");
+				}
+			} else {
+				if (frm.doc.status != "Processing Day Book Data") {
+					frm.events.add_button(frm, __("Process Day Book Data"), "process_day_book_data");
+				}
+			}
+		}
+	},
+	add_button: function(frm, label, method) {
+		frm.add_custom_button(
+			label,
+			() => frm.call({
+				doc: frm.doc,
+				method: method,
+				freeze: true,
+				callback: () => {
+					frm.remove_custom_button(label);
+				}
+			})
+		);
+	}
+});
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
new file mode 100644
index 0000000..26415ca
--- /dev/null
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.json
@@ -0,0 +1,219 @@
+{
+ "beta": 1,
+ "creation": "2019-02-01 14:27:09.485238",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "status",
+  "master_data",
+  "is_master_data_processed",
+  "is_master_data_imported",
+  "column_break_2",
+  "tally_creditors_account",
+  "tally_debtors_account",
+  "company_section",
+  "tally_company",
+  "column_break_8",
+  "erpnext_company",
+  "processed_files_section",
+  "chart_of_accounts",
+  "parties",
+  "addresses",
+  "column_break_17",
+  "uoms",
+  "items",
+  "vouchers",
+  "accounts_section",
+  "default_warehouse",
+  "round_off_account",
+  "column_break_21",
+  "default_cost_center",
+  "day_book_section",
+  "day_book_data",
+  "column_break_27",
+  "is_day_book_data_processed",
+  "is_day_book_data_imported"
+ ],
+ "fields": [
+  {
+   "fieldname": "status",
+   "fieldtype": "Data",
+   "hidden": 1,
+   "label": "Status"
+  },
+  {
+   "fieldname": "master_data",
+   "fieldtype": "Attach",
+   "in_list_view": 1,
+   "label": "Master Data"
+  },
+  {
+   "default": "Sundry Creditors",
+   "fieldname": "tally_creditors_account",
+   "fieldtype": "Data",
+   "label": "Tally Creditors Account",
+   "reqd": 1
+  },
+  {
+   "fieldname": "column_break_2",
+   "fieldtype": "Column Break"
+  },
+  {
+   "default": "Sundry Debtors",
+   "fieldname": "tally_debtors_account",
+   "fieldtype": "Data",
+   "label": "Tally Debtors Account",
+   "reqd": 1
+  },
+  {
+   "depends_on": "is_master_data_processed",
+   "fieldname": "company_section",
+   "fieldtype": "Section Break"
+  },
+  {
+   "fieldname": "tally_company",
+   "fieldtype": "Data",
+   "label": "Tally Company",
+   "read_only": 1
+  },
+  {
+   "fieldname": "column_break_8",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "erpnext_company",
+   "fieldtype": "Data",
+   "label": "ERPNext Company"
+  },
+  {
+   "fieldname": "processed_files_section",
+   "fieldtype": "Section Break",
+   "hidden": 1,
+   "label": "Processed Files"
+  },
+  {
+   "fieldname": "chart_of_accounts",
+   "fieldtype": "Attach",
+   "label": "Chart of Accounts"
+  },
+  {
+   "fieldname": "parties",
+   "fieldtype": "Attach",
+   "label": "Parties"
+  },
+  {
+   "fieldname": "addresses",
+   "fieldtype": "Attach",
+   "label": "Addresses"
+  },
+  {
+   "fieldname": "column_break_17",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "uoms",
+   "fieldtype": "Attach",
+   "label": "UOMs"
+  },
+  {
+   "fieldname": "items",
+   "fieldtype": "Attach",
+   "label": "Items"
+  },
+  {
+   "fieldname": "vouchers",
+   "fieldtype": "Attach",
+   "label": "Vouchers"
+  },
+  {
+   "depends_on": "is_master_data_imported",
+   "fieldname": "accounts_section",
+   "fieldtype": "Section Break",
+   "label": "Accounts"
+  },
+  {
+   "fieldname": "default_warehouse",
+   "fieldtype": "Link",
+   "label": "Default Warehouse",
+   "options": "Warehouse"
+  },
+  {
+   "fieldname": "round_off_account",
+   "fieldtype": "Link",
+   "label": "Round Off Account",
+   "options": "Account"
+  },
+  {
+   "fieldname": "column_break_21",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "default_cost_center",
+   "fieldtype": "Link",
+   "label": "Default Cost Center",
+   "options": "Cost Center"
+  },
+  {
+   "fieldname": "is_master_data_processed",
+   "fieldtype": "Check",
+   "label": "Is Master Data Processed",
+   "read_only": 1
+  },
+  {
+   "fieldname": "is_day_book_data_processed",
+   "fieldtype": "Check",
+   "label": "Is Day Book Data Processed",
+   "read_only": 1
+  },
+  {
+   "fieldname": "is_day_book_data_imported",
+   "fieldtype": "Check",
+   "label": "Is Day Book Data Imported",
+   "read_only": 1
+  },
+  {
+   "fieldname": "is_master_data_imported",
+   "fieldtype": "Check",
+   "label": "Is Master Data Imported",
+   "read_only": 1
+  },
+  {
+   "depends_on": "is_master_data_imported",
+   "fieldname": "day_book_section",
+   "fieldtype": "Section Break"
+  },
+  {
+   "fieldname": "column_break_27",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "day_book_data",
+   "fieldtype": "Attach",
+   "in_list_view": 1,
+   "label": "Day Book Data"
+  }
+ ],
+ "modified": "2019-04-29 05:46:54.394967",
+ "modified_by": "Administrator",
+ "module": "ERPNext Integrations",
+ "name": "Tally Migration",
+ "owner": "Administrator",
+ "permissions": [
+  {
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "System Manager",
+   "share": 1,
+   "write": 1
+  }
+ ],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
new file mode 100644
index 0000000..12b646d
--- /dev/null
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/tally_migration.py
@@ -0,0 +1,512 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+
+from decimal import Decimal
+import json
+import re
+import traceback
+import zipfile
+import frappe
+from frappe import _
+from frappe.custom.doctype.custom_field.custom_field import create_custom_field
+from frappe.model.document import Document
+from frappe.model.naming import getseries, revert_series_if_last
+from frappe.utils.data import format_datetime
+from bs4 import BeautifulSoup as bs
+from erpnext import encode_company_abbr
+from erpnext.accounts.doctype.account.chart_of_accounts.chart_of_accounts import create_charts
+
+PRIMARY_ACCOUNT = "Primary"
+VOUCHER_CHUNK_SIZE = 500
+
+
+class TallyMigration(Document):
+	def autoname(self):
+		if not self.name:
+			self.name = "Tally Migration on " + format_datetime(self.creation)
+
+	def get_collection(self, data_file):
+		def sanitize(string):
+			return re.sub("&#4;", "", string)
+
+		def emptify(string):
+			string = re.sub(r"<\w+/>", "", string)
+			string = re.sub(r"<([\w.]+)>\s*<\/\1>", "", string)
+			string = re.sub(r"\r\n", "", string)
+			return string
+
+		master_file = frappe.get_doc("File", {"file_url": data_file})
+
+		with zipfile.ZipFile(master_file.get_full_path()) as zf:
+			encoded_content = zf.read(zf.namelist()[0])
+			try:
+				content = encoded_content.decode("utf-8-sig")
+			except UnicodeDecodeError:
+				content = encoded_content.decode("utf-16")
+
+		master = bs(sanitize(emptify(content)), "xml")
+		collection = master.BODY.IMPORTDATA.REQUESTDATA
+		return collection
+
+	def dump_processed_data(self, data):
+		for key, value in data.items():
+			f = frappe.get_doc({
+				"doctype": "File",
+				"file_name":  key + ".json",
+				"attached_to_doctype": self.doctype,
+				"attached_to_name": self.name,
+				"content": json.dumps(value)
+			}).insert()
+			setattr(self, key, f.file_url)
+
+	def _process_master_data(self):
+		def get_company_name(collection):
+			return collection.find_all("REMOTECMPINFO.LIST")[0].REMOTECMPNAME.string
+
+		def get_coa_customers_suppliers(collection):
+			root_type_map = {
+				"Application of Funds (Assets)": "Asset",
+				"Expenses": "Expense",
+				"Income": "Income",
+				"Source of Funds (Liabilities)": "Liability"
+			}
+			roots = set(root_type_map.keys())
+			accounts = list(get_groups(collection.find_all("GROUP"))) + list(get_ledgers(collection.find_all("LEDGER")))
+			children, parents = get_children_and_parent_dict(accounts)
+			group_set =  [acc[1] for acc in accounts if acc[2]]
+			children, customers, suppliers = remove_parties(parents, children, group_set)
+			coa = traverse({}, children, roots, roots, group_set)
+
+			for account in coa:
+				coa[account]["root_type"] = root_type_map[account]
+
+			return coa, customers, suppliers
+
+		def get_groups(accounts):
+			for account in accounts:
+				if account["NAME"] in (self.tally_creditors_account, self.tally_debtors_account):
+					yield get_parent(account), account["NAME"], 0
+				else:
+					yield get_parent(account), account["NAME"], 1
+
+		def get_ledgers(accounts):
+			for account in accounts:
+				# If Ledger doesn't have PARENT field then don't create Account
+				# For example "Profit & Loss A/c"
+				if account.PARENT:
+					yield account.PARENT.string, account["NAME"], 0
+
+		def get_parent(account):
+			if account.PARENT:
+				return account.PARENT.string
+			return {
+				("Yes", "No"): "Application of Funds (Assets)",
+				("Yes", "Yes"): "Expenses",
+				("No", "Yes"): "Income",
+				("No", "No"): "Source of Funds (Liabilities)",
+			}[(account.ISDEEMEDPOSITIVE.string, account.ISREVENUE.string)]
+
+		def get_children_and_parent_dict(accounts):
+			children, parents = {}, {}
+			for parent, account, is_group in accounts:
+				children.setdefault(parent, set()).add(account)
+				parents.setdefault(account, set()).add(parent)
+				parents[account].update(parents.get(parent, []))
+			return children, parents
+
+		def remove_parties(parents, children, group_set):
+			customers, suppliers = set(), set()
+			for account in parents:
+				if self.tally_creditors_account in parents[account]:
+					children.pop(account, None)
+					if account not in group_set:
+						suppliers.add(account)
+				elif self.tally_debtors_account in parents[account]:
+					children.pop(account, None)
+					if account not in group_set:
+						customers.add(account)
+			return children, customers, suppliers
+
+		def traverse(tree, children, accounts, roots, group_set):
+			for account in accounts:
+				if account in group_set or account in roots:
+					if account in children:
+						tree[account] = traverse({}, children, children[account], roots, group_set)
+					else:
+						tree[account] = {"is_group": 1}
+				else:
+					tree[account] = {}
+			return tree
+
+		def get_parties_addresses(collection, customers, suppliers):
+			parties, addresses = [], []
+			for account in collection.find_all("LEDGER"):
+				party_type = None
+				if account.NAME.string in customers:
+					party_type = "Customer"
+					parties.append({
+						"doctype": party_type,
+						"customer_name": account.NAME.string,
+						"tax_id": account.INCOMETAXNUMBER.string if account.INCOMETAXNUMBER else None,
+						"customer_group": "All Customer Groups",
+						"territory": "All Territories",
+						"customer_type": "Individual",
+					})
+				elif account.NAME.string in suppliers:
+					party_type = "Supplier"
+					parties.append({
+						"doctype": party_type,
+						"supplier_name": account.NAME.string,
+						"pan": account.INCOMETAXNUMBER.string if account.INCOMETAXNUMBER else None,
+						"supplier_group": "All Supplier Groups",
+						"supplier_type": "Individual",
+					})
+				if party_type:
+					address = "\n".join([a.string for a in account.find_all("ADDRESS")])
+					addresses.append({
+						"doctype": "Address",
+						"address_line1": address[:140].strip(),
+						"address_line2": address[140:].strip(),
+						"country": account.COUNTRYNAME.string if account.COUNTRYNAME else None,
+						"state": account.LEDSTATENAME.string if account.LEDSTATENAME else None,
+						"gst_state": account.LEDSTATENAME.string if account.LEDSTATENAME else None,
+						"pin_code": account.PINCODE.string if account.PINCODE else None,
+						"mobile": account.LEDGERPHONE.string if account.LEDGERPHONE else None,
+						"phone": account.LEDGERPHONE.string if account.LEDGERPHONE else None,
+						"gstin": account.PARTYGSTIN.string if account.PARTYGSTIN else None,
+						"links": [{"link_doctype": party_type, "link_name": account["NAME"]}],
+					})
+			return parties, addresses
+
+		def get_stock_items_uoms(collection):
+			uoms = []
+			for uom in collection.find_all("UNIT"):
+				uoms.append({"doctype": "UOM", "uom_name": uom.NAME.string})
+
+			items = []
+			for item in collection.find_all("STOCKITEM"):
+				items.append({
+					"doctype": "Item",
+					"item_code" : item.NAME.string,
+					"stock_uom": item.BASEUNITS.string,
+					"is_stock_item": 0,
+					"item_group": "All Item Groups",
+					"item_defaults": [{"company": self.erpnext_company}]
+				})
+			return items, uoms
+
+
+		self.publish("Process Master Data", _("Reading Uploaded File"), 1, 5)
+		collection = self.get_collection(self.master_data)
+
+		company = get_company_name(collection)
+		self.tally_company = company
+		self.erpnext_company = company
+
+		self.publish("Process Master Data", _("Processing Chart of Accounts and Parties"), 2, 5)
+		chart_of_accounts, customers, suppliers = get_coa_customers_suppliers(collection)
+		self.publish("Process Master Data", _("Processing Party Addresses"), 3, 5)
+		parties, addresses = get_parties_addresses(collection, customers, suppliers)
+		self.publish("Process Master Data", _("Processing Items and UOMs"), 4, 5)
+		items, uoms = get_stock_items_uoms(collection)
+		data = {"chart_of_accounts": chart_of_accounts, "parties": parties, "addresses": addresses, "items": items, "uoms": uoms}
+		self.publish("Process Master Data", _("Done"), 5, 5)
+
+		self.dump_processed_data(data)
+		self.is_master_data_processed = 1
+		self.status = ""
+		self.save()
+
+	def publish(self, title, message, count, total):
+		frappe.publish_realtime("tally_migration_progress_update", {"title": title, "message": message, "count": count, "total": total})
+
+	def _import_master_data(self):
+		def create_company_and_coa(coa_file_url):
+			coa_file = frappe.get_doc("File", {"file_url": coa_file_url})
+			frappe.local.flags.ignore_chart_of_accounts = True
+			company = frappe.get_doc({
+				"doctype": "Company",
+				"company_name": self.erpnext_company,
+				"default_currency": "INR",
+				"enable_perpetual_inventory": 0,
+			}).insert()
+			frappe.local.flags.ignore_chart_of_accounts = False
+			create_charts(company.name, custom_chart=json.loads(coa_file.get_content()))
+			company.create_default_warehouses()
+
+		def create_parties_and_addresses(parties_file_url, addresses_file_url):
+			parties_file = frappe.get_doc("File", {"file_url": parties_file_url})
+			for party in json.loads(parties_file.get_content()):
+				try:
+					frappe.get_doc(party).insert()
+				except:
+					self.log(party)
+			addresses_file = frappe.get_doc("File", {"file_url": addresses_file_url})
+			for address in json.loads(addresses_file.get_content()):
+				try:
+					frappe.get_doc(address).insert(ignore_mandatory=True)
+				except:
+					try:
+						gstin = address.pop("gstin", None)
+						frappe.get_doc(address).insert(ignore_mandatory=True)
+						self.log({"address": address, "message": "Invalid GSTIN: {}. Address was created without GSTIN".format(gstin)})
+					except:
+						self.log(address)
+
+
+		def create_items_uoms(items_file_url, uoms_file_url):
+			uoms_file = frappe.get_doc("File", {"file_url": uoms_file_url})
+			for uom in json.loads(uoms_file.get_content()):
+				if not frappe.db.exists(uom):
+					try:
+						frappe.get_doc(uom).insert()
+					except:
+						self.log(uom)
+
+			items_file = frappe.get_doc("File", {"file_url": items_file_url})
+			for item in json.loads(items_file.get_content()):
+				try:
+					frappe.get_doc(item).insert()
+				except:
+					self.log(item)
+
+		self.publish("Import Master Data", _("Creating Company and Importing Chart of Accounts"), 1, 4)
+		create_company_and_coa(self.chart_of_accounts)
+		self.publish("Import Master Data", _("Importing Parties and Addresses"), 2, 4)
+		create_parties_and_addresses(self.parties, self.addresses)
+		self.publish("Import Master Data", _("Importing Items and UOMs"), 3, 4)
+		create_items_uoms(self.items, self.uoms)
+		self.publish("Import Master Data", _("Done"), 4, 4)
+		self.status = ""
+		self.is_master_data_imported = 1
+		self.save()
+
+	def _process_day_book_data(self):
+		def get_vouchers(collection):
+			vouchers = []
+			for voucher in collection.find_all("VOUCHER"):
+				if voucher.ISCANCELLED.string == "Yes":
+					continue
+				inventory_entries = voucher.find_all("INVENTORYENTRIES.LIST") + voucher.find_all("ALLINVENTORYENTRIES.LIST") + voucher.find_all("INVENTORYENTRIESIN.LIST") + voucher.find_all("INVENTORYENTRIESOUT.LIST")
+				if voucher.VOUCHERTYPENAME.string not in ["Journal", "Receipt", "Payment", "Contra"] and inventory_entries:
+					function = voucher_to_invoice
+				else:
+					function = voucher_to_journal_entry
+				try:
+					vouchers.append(function(voucher))
+				except:
+					self.log(voucher)
+			return vouchers
+
+		def voucher_to_journal_entry(voucher):
+			accounts = []
+			ledger_entries = voucher.find_all("ALLLEDGERENTRIES.LIST") + voucher.find_all("LEDGERENTRIES.LIST")
+			for entry in ledger_entries:
+				account = {"account": encode_company_abbr(entry.LEDGERNAME.string, self.erpnext_company), "cost_center": self.default_cost_center}
+				if entry.ISPARTYLEDGER.string == "Yes":
+					party_details = get_party(entry.LEDGERNAME.string)
+					if party_details:
+						party_type, party_account = party_details
+						account["party_type"] = party_type
+						account["account"] = party_account
+						account["party"] = entry.LEDGERNAME.string
+				amount = Decimal(entry.AMOUNT.string)
+				if amount > 0:
+					account["credit_in_account_currency"] = str(abs(amount))
+				else:
+					account["debit_in_account_currency"] = str(abs(amount))
+				accounts.append(account)
+
+			journal_entry = {
+				"doctype": "Journal Entry",
+				"tally_guid": voucher.GUID.string,
+				"posting_date": voucher.DATE.string,
+				"company": self.erpnext_company,
+				"accounts": accounts,
+			}
+			return journal_entry
+
+		def voucher_to_invoice(voucher):
+			if voucher.VOUCHERTYPENAME.string in ["Sales", "Credit Note"]:
+				doctype = "Sales Invoice"
+				party_field = "customer"
+				account_field = "debit_to"
+				account_name = encode_company_abbr(self.tally_debtors_account, self.erpnext_company)
+				price_list_field = "selling_price_list"
+			elif voucher.VOUCHERTYPENAME.string in ["Purchase", "Debit Note"]:
+				doctype = "Purchase Invoice"
+				party_field = "supplier"
+				account_field = "credit_to"
+				account_name = encode_company_abbr(self.tally_creditors_account, self.erpnext_company)
+				price_list_field = "buying_price_list"
+
+			invoice = {
+				"doctype": doctype,
+				party_field: voucher.PARTYNAME.string,
+				"tally_guid": voucher.GUID.string,
+				"posting_date": voucher.DATE.string,
+				"due_date": voucher.DATE.string,
+				"items": get_voucher_items(voucher, doctype),
+				"taxes": get_voucher_taxes(voucher),
+				account_field: account_name,
+				price_list_field: "Tally Price List",
+				"set_posting_time": 1,
+				"disable_rounded_total": 1,
+				"company": self.erpnext_company,
+			}
+			return invoice
+
+		def get_voucher_items(voucher, doctype):
+			inventory_entries = voucher.find_all("INVENTORYENTRIES.LIST") + voucher.find_all("ALLINVENTORYENTRIES.LIST") + voucher.find_all("INVENTORYENTRIESIN.LIST") + voucher.find_all("INVENTORYENTRIESOUT.LIST")
+			if doctype == "Sales Invoice":
+				account_field = "income_account"
+			elif doctype == "Purchase Invoice":
+				account_field = "expense_account"
+			items = []
+			for entry in inventory_entries:
+				qty, uom = entry.ACTUALQTY.string.strip().split()
+				items.append({
+					"item_code": entry.STOCKITEMNAME.string,
+					"description": entry.STOCKITEMNAME.string,
+					"qty": qty.strip(),
+					"uom": uom.strip(),
+					"conversion_factor": 1,
+					"price_list_rate": entry.RATE.string.split("/")[0],
+					"cost_center": self.default_cost_center,
+					"warehouse": self.default_warehouse,
+					account_field: encode_company_abbr(entry.find_all("ACCOUNTINGALLOCATIONS.LIST")[0].LEDGERNAME.string, self.erpnext_company),
+				})
+			return items
+
+		def get_voucher_taxes(voucher):
+			ledger_entries = voucher.find_all("ALLLEDGERENTRIES.LIST") + voucher.find_all("LEDGERENTRIES.LIST")
+			taxes = []
+			for entry in ledger_entries:
+				if entry.ISPARTYLEDGER.string == "No":
+					tax_account = encode_company_abbr(entry.LEDGERNAME.string, self.erpnext_company)
+					taxes.append({
+						"charge_type": "Actual",
+						"account_head": tax_account,
+						"description": tax_account,
+						"tax_amount": entry.AMOUNT.string,
+						"cost_center": self.default_cost_center,
+					})
+			return taxes
+
+		def get_party(party):
+			if frappe.db.exists({"doctype": "Supplier", "supplier_name": party}):
+				return "Supplier", encode_company_abbr(self.tally_creditors_account, self.erpnext_company)
+			elif frappe.db.exists({"doctype": "Customer", "customer_name": party}):
+				return "Customer", encode_company_abbr(self.tally_debtors_account, self.erpnext_company)
+
+		self.publish("Process Day Book Data", _("Reading Uploaded File"), 1, 3)
+		collection = self.get_collection(self.day_book_data)
+		self.publish("Process Day Book Data", _("Processing Vouchers"), 2, 3)
+		vouchers = get_vouchers(collection)
+		self.publish("Process Day Book Data", _("Done"), 3, 3)
+		self.dump_processed_data({"vouchers": vouchers})
+		self.status = ""
+		self.is_day_book_data_processed = 1
+		self.save()
+
+	def _import_day_book_data(self):
+		def create_fiscal_years(vouchers):
+			from frappe.utils.data import add_years, getdate
+			earliest_date = getdate(min(voucher["posting_date"] for voucher in vouchers))
+			oldest_year = frappe.get_all("Fiscal Year", fields=["year_start_date", "year_end_date"], order_by="year_start_date")[0]
+			while earliest_date < oldest_year.year_start_date:
+				new_year = frappe.get_doc({"doctype": "Fiscal Year"})
+				new_year.year_start_date = add_years(oldest_year.year_start_date, -1)
+				new_year.year_end_date = add_years(oldest_year.year_end_date, -1)
+				if new_year.year_start_date.year == new_year.year_end_date.year:
+					new_year.year = new_year.year_start_date.year
+				else:
+					new_year.year = "{}-{}".format(new_year.year_start_date.year, new_year.year_end_date.year)
+				new_year.save()
+				oldest_year = new_year
+
+		def create_custom_fields(doctypes):
+			for doctype in doctypes:
+				df = {
+					"fieldtype": "Data",
+					"fieldname": "tally_guid",
+					"read_only": 1,
+					"label": "Tally GUID"
+				}
+				create_custom_field(doctype, df)
+
+		def create_price_list():
+			frappe.get_doc({
+				"doctype": "Price List",
+				"price_list_name": "Tally Price List",
+				"selling": 1,
+				"buying": 1,
+				"enabled": 1,
+				"currency": "INR"
+			}).insert()
+
+		frappe.db.set_value("Account", encode_company_abbr(self.tally_creditors_account, self.erpnext_company), "account_type", "Payable")
+		frappe.db.set_value("Account", encode_company_abbr(self.tally_debtors_account, self.erpnext_company), "account_type", "Receivable")
+		frappe.db.set_value("Company", self.erpnext_company, "round_off_account", self.round_off_account)
+
+		vouchers_file = frappe.get_doc("File", {"file_url": self.vouchers})
+		vouchers = json.loads(vouchers_file.get_content())
+
+		create_fiscal_years(vouchers)
+		create_price_list()
+		create_custom_fields(["Journal Entry", "Purchase Invoice", "Sales Invoice"])
+
+		total = len(vouchers)
+		is_last = False
+		for index in range(0, total, VOUCHER_CHUNK_SIZE):
+			if index + VOUCHER_CHUNK_SIZE >= total:
+				is_last = True
+			frappe.enqueue_doc(self.doctype, self.name, "_import_vouchers", queue="long", timeout=3600, start=index+1, total=total, is_last=is_last)
+
+	def _import_vouchers(self, start, total, is_last=False):
+		frappe.flags.in_migrate = True
+		vouchers_file = frappe.get_doc("File", {"file_url": self.vouchers})
+		vouchers = json.loads(vouchers_file.get_content())
+		chunk = vouchers[start: start + VOUCHER_CHUNK_SIZE]
+
+		for index, voucher in enumerate(chunk, start=start):
+			try:
+				doc = frappe.get_doc(voucher).insert()
+				doc.submit()
+				self.publish("Importing Vouchers", _("{} of {}").format(index, total), index, total)
+			except:
+				self.log(voucher)
+
+		if is_last:
+			self.status = ""
+			self.is_day_book_data_imported = 1
+			self.save()
+			frappe.db.set_value("Price List", "Tally Price List", "enabled", 0)
+		frappe.flags.in_migrate = False
+
+	def process_master_data(self):
+		self.status = "Processing Master Data"
+		self.save()
+		frappe.enqueue_doc(self.doctype, self.name, "_process_master_data", queue="long", timeout=3600)
+
+	def import_master_data(self):
+		self.status = "Importing Master Data"
+		self.save()
+		frappe.enqueue_doc(self.doctype, self.name, "_import_master_data", queue="long", timeout=3600)
+
+	def process_day_book_data(self):
+		self.status = "Processing Day Book Data"
+		self.save()
+		frappe.enqueue_doc(self.doctype, self.name, "_process_day_book_data", queue="long", timeout=3600)
+
+	def import_day_book_data(self):
+		self.status = "Importing Day Book Data"
+		self.save()
+		frappe.enqueue_doc(self.doctype, self.name, "_import_day_book_data", queue="long", timeout=3600)
+
+	def log(self, data=None):
+		message = "\n".join(["Data", json.dumps(data, default=str, indent=4), "Exception", traceback.format_exc()])
+		return frappe.log_error(title="Tally Migration Error", message=message)
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.js b/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.js
new file mode 100644
index 0000000..433c5e2
--- /dev/null
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.js
@@ -0,0 +1,23 @@
+/* eslint-disable */
+// rename this file from _test_[name] to test_[name] to activate
+// and remove above this line
+
+QUnit.test("test: Tally Migration", function (assert) {
+	let done = assert.async();
+
+	// number of asserts
+	assert.expect(1);
+
+	frappe.run_serially([
+		// insert a new Tally Migration
+		() => frappe.tests.make('Tally Migration', [
+			// values to be set
+			{key: 'value'}
+		]),
+		() => {
+			assert.equal(cur_frm.doc.key, 'value');
+		},
+		() => done()
+	]);
+
+});
diff --git a/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.py b/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.py
new file mode 100644
index 0000000..9f67e55
--- /dev/null
+++ b/erpnext/erpnext_integrations/doctype/tally_migration/test_tally_migration.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
+# See license.txt
+from __future__ import unicode_literals
+
+import frappe
+import unittest
+
+class TestTallyMigration(unittest.TestCase):
+	pass
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index ecc9611..85f2804 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -24,7 +24,8 @@
 doctype_js = {
 	"Communication": "public/js/communication.js",
 	"Event": "public/js/event.js",
-	"Website Theme": "public/js/website_theme.js"
+	"Website Theme": "public/js/website_theme.js",
+	"Newsletter": "public/js/newsletter.js"
 }
 
 welcome_email = "erpnext.setup.utils.welcome_email"
@@ -169,10 +170,6 @@
 	{'role': 'Student', 'doctype':'Student', 'email_field': 'student_email_id'},
 ]
 
-role_home_page = {
-	"LMS User": "/lms"
-}
-
 has_website_permission = {
 	"Sales Order": "erpnext.controllers.website_list_for_contact.has_website_permission",
 	"Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission",
diff --git a/erpnext/hr/report/loan_repayment/__init__.py b/erpnext/hr/report/loan_repayment/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/hr/report/loan_repayment/__init__.py
diff --git a/erpnext/hr/report/loan_repayment/loan_repayment.js b/erpnext/hr/report/loan_repayment/loan_repayment.js
new file mode 100644
index 0000000..21aa206
--- /dev/null
+++ b/erpnext/hr/report/loan_repayment/loan_repayment.js
@@ -0,0 +1,9 @@
+// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+/* eslint-disable */
+
+frappe.query_reports["Loan Repayment"] = {
+	"filters": [
+
+	]
+}
diff --git a/erpnext/hr/report/loan_repayment/loan_repayment.json b/erpnext/hr/report/loan_repayment/loan_repayment.json
new file mode 100644
index 0000000..b967dfd
--- /dev/null
+++ b/erpnext/hr/report/loan_repayment/loan_repayment.json
@@ -0,0 +1,28 @@
+{
+ "add_total_row": 0, 
+ "creation": "2019-03-29 18:58:00.166032", 
+ "disable_prepared_report": 0, 
+ "disabled": 0, 
+ "docstatus": 0, 
+ "doctype": "Report", 
+ "idx": 0, 
+ "is_standard": "Yes", 
+ "letter_head": "", 
+ "modified": "2019-03-29 18:58:00.166032", 
+ "modified_by": "Administrator", 
+ "module": "HR", 
+ "name": "Loan Repayment", 
+ "owner": "Administrator", 
+ "prepared_report": 0, 
+ "ref_doctype": "Loan", 
+ "report_name": "Loan Repayment", 
+ "report_type": "Script Report", 
+ "roles": [
+  {
+   "role": "HR Manager"
+  }, 
+  {
+   "role": "Employee"
+  }
+ ]
+}
diff --git a/erpnext/hr/report/loan_repayment/loan_repayment.py b/erpnext/hr/report/loan_repayment/loan_repayment.py
new file mode 100644
index 0000000..9e310de
--- /dev/null
+++ b/erpnext/hr/report/loan_repayment/loan_repayment.py
@@ -0,0 +1,95 @@
+# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+import frappe
+from frappe import _
+
+def execute(filters=None):
+
+	columns = create_columns()
+	data = get_record()
+	return columns, data
+
+def create_columns():
+	return [
+			{
+				"label": _("Employee"),
+				"fieldtype": "Data",
+				"fieldname": "employee",
+				"options": "Employee",
+				"width": 200
+			},
+			{
+				"label": _("Loan"),
+				"fieldtype": "Link",
+				"fieldname": "loan_name",
+				"options": "Loan",
+				"width": 200
+			},
+			{
+				"label": _("Loan Amount"),
+				"fieldtype": "Currency",
+				"fieldname": "loan_amount",
+				"options": "currency",
+				"width": 100
+			},
+			{
+				"label": _("Interest"),
+				"fieldtype": "Data",
+				"fieldname": "interest",
+				"width": 100
+			},
+			{
+				"label": _("Payable Amount"),
+				"fieldtype": "Currency",
+				"fieldname": "payable_amount",
+				"options": "currency",
+				"width": 100
+			},
+			{
+				"label": _("EMI"),
+				"fieldtype": "Currency",
+				"fieldname": "emi",
+				"options": "currency",
+				"width": 100
+			},
+			{
+				"label": _("Paid Amount"),
+				"fieldtype": "Currency",
+				"fieldname": "paid_amount",
+				"options": "currency",
+				"width": 100
+			},
+			{
+				"label": _("Outstanding Amount"),
+				"fieldtype": "Currency",
+				"fieldname": "out_amt",
+				"options": "currency",
+				"width": 100
+			},
+		]
+
+def get_record():
+	data = []
+	loans = frappe.get_all("Loan",
+		filters=[("status", "=", "Fully Disbursed")],
+		fields=["applicant", "applicant_name", "name", "loan_amount", "rate_of_interest",
+			"total_payment", "monthly_repayment_amount", "total_amount_paid"]
+	)
+
+	for loan in loans:
+		row = {
+			"employee": loan.applicant + ": " + loan.applicant_name,
+			"loan_name": loan.name,
+			"loan_amount": loan.loan_amount,
+			"interest": str(loan.rate_of_interest) + "%",
+			"payable_amount": loan.total_payment,
+			"emi": loan.monthly_repayment_amount,
+			"paid_amount": loan.total_amount_paid,
+			"out_amt": loan.total_payment - loan.total_amount_paid
+		}
+
+		data.append(row)
+
+	return data
diff --git a/erpnext/hr/report/salary_register/salary_register.py b/erpnext/hr/report/salary_register/salary_register.py
index 586ca67..869ca23 100644
--- a/erpnext/hr/report/salary_register/salary_register.py
+++ b/erpnext/hr/report/salary_register/salary_register.py
@@ -99,8 +99,6 @@
 					employee,
 					date_of_joining
 				FROM `tabEmployee`
-				WHERE
-					`status`='Active'
 				"""))
 
 def get_ss_earning_map(salary_slips):
diff --git a/erpnext/patches/v11_1/woocommerce_set_creation_user.py b/erpnext/patches/v11_1/woocommerce_set_creation_user.py
index e50d5ae..5ccdec6 100644
--- a/erpnext/patches/v11_1/woocommerce_set_creation_user.py
+++ b/erpnext/patches/v11_1/woocommerce_set_creation_user.py
@@ -1,10 +1,11 @@
 from __future__ import unicode_literals
 import frappe
+from frappe.utils import cint
 
 def execute():
-	woocommerce_setting_enable_sync = frappe.db.sql("SELECT t.value FROM tabSingles t WHERE doctype = 'Woocommerce Settings' AND field = 'enable_sync'",  as_dict=True)
-	if len(woocommerce_setting_enable_sync) and woocommerce_setting_enable_sync[0].value == '1':
-		frappe.db.sql("""UPDATE tabSingles
-					SET value = (SELECT t.value FROM tabSingles t WHERE doctype = 'Woocommerce Settings' AND field = 'modified_by')
-					WHERE doctype = 'Woocommerce Settings'
-					AND field = 'creation_user';""")
\ No newline at end of file
+	frappe.reload_doc("erpnext_integrations", "doctype","woocommerce_settings")
+	doc = frappe.get_doc("Woocommerce Settings")
+
+	if cint(doc.enable_sync):
+		doc.creation_user = doc.modified_by
+		doc.save(ignore_permissions=True)
\ No newline at end of file
diff --git a/erpnext/portal/product_configurator/item_variants_cache.py b/erpnext/portal/product_configurator/item_variants_cache.py
index 458c229..f17639c 100644
--- a/erpnext/portal/product_configurator/item_variants_cache.py
+++ b/erpnext/portal/product_configurator/item_variants_cache.py
@@ -62,7 +62,7 @@
 
 		item_variants_data = frappe.db.get_all('Item Variant Attribute',
 			{'variant_of': parent_item_code}, ['parent', 'attribute', 'attribute_value'],
-			order_by='parent',
+			order_by='name',
 			as_list=1
 		)
 
diff --git a/erpnext/projects/doctype/task/task.json b/erpnext/projects/doctype/task/task.json
index 4012346..bba258a 100644
--- a/erpnext/projects/doctype/task/task.json
+++ b/erpnext/projects/doctype/task/task.json
@@ -1,1505 +1,378 @@
 {
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
  "allow_import": 1,
- "allow_rename": 0,
  "autoname": "TASK-.YYYY.-.#####",
- "beta": 0,
  "creation": "2013-01-29 19:25:50",
- "custom": 0,
- "docstatus": 0,
  "doctype": "DocType",
  "document_type": "Setup",
- "editable_grid": 0,
+ "field_order": [
+  "subject",
+  "project",
+  "issue",
+  "type",
+  "is_group",
+  "column_break0",
+  "status",
+  "priority",
+  "task_weight",
+  "color",
+  "parent_task",
+  "sb_timeline",
+  "exp_start_date",
+  "expected_time",
+  "column_break_11",
+  "exp_end_date",
+  "progress",
+  "is_milestone",
+  "sb_details",
+  "description",
+  "sb_depends_on",
+  "depends_on",
+  "depends_on_tasks",
+  "sb_actual",
+  "act_start_date",
+  "actual_time",
+  "column_break_15",
+  "act_end_date",
+  "sb_costing",
+  "total_costing_amount",
+  "total_expense_claim",
+  "column_break_20",
+  "total_billing_amount",
+  "sb_more_info",
+  "review_date",
+  "closing_date",
+  "column_break_22",
+  "department",
+  "company",
+  "lft",
+  "rgt",
+  "old_parent"
+ ],
  "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": "subject",
    "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": "Subject",
-   "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": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "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": 1,
    "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Project",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "project",
    "oldfieldtype": "Link",
    "options": "Project",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
    "remember_last_selected_value": 1,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fetch_if_empty": 0,
    "fieldname": "issue",
    "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": "Issue",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Issue",
-   "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": "Issue"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fetch_if_empty": 0,
    "fieldname": "type",
    "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": "Type",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Task 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": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Task Type"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
    "default": "0",
-   "fetch_if_empty": 0,
    "fieldname": "is_group",
    "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": "Is Group",
-   "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": "Is Group"
   },
   {
-   "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_break0",
    "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": 1,
-   "collapsible": 0,
-   "columns": 0,
-   "fetch_if_empty": 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": 1,
    "in_standard_filter": 1,
    "label": "Status",
-   "length": 0,
    "no_copy": 1,
    "oldfieldname": "status",
    "oldfieldtype": "Select",
-   "options": "Open\nWorking\nPending Review\nOverdue\nCompleted\nCancelled",
-   "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
+   "options": "Open\nWorking\nPending Review\nOverdue\nCompleted\nCancelled"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fetch_if_empty": 0,
    "fieldname": "priority",
    "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": "Priority",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "priority",
    "oldfieldtype": "Select",
    "options": "Low\nMedium\nHigh\nUrgent",
-   "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
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fetch_if_empty": 0,
    "fieldname": "color",
    "fieldtype": "Color",
-   "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": "Color",
-   "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": "Color"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
-   "fetch_if_empty": 0,
    "fieldname": "parent_task",
    "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": "Parent Task",
-   "length": 0,
-   "no_copy": 0,
    "options": "Task",
-   "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": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
    "collapsible": 1,
    "collapsible_depends_on": "eval:doc.__islocal",
-   "columns": 0,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "sb_timeline",
    "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": "Timeline",
-   "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": "Timeline"
   },
   {
-   "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": "exp_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": "Expected Start Date",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "exp_start_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": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "oldfieldtype": "Date"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "default": "0",
-   "depends_on": "",
-   "description": "",
-   "fetch_if_empty": 0,
    "fieldname": "expected_time",
    "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": "Expected Time (in hours)",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "exp_total_hrs",
-   "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
+   "oldfieldtype": "Data"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "depends_on": "",
    "fetch_from": "type.weight",
-   "fetch_if_empty": 0,
    "fieldname": "task_weight",
    "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": "Weight",
-   "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
+   "label": "Weight"
   },
   {
-   "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_11",
-   "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": 1,
-   "collapsible": 0,
-   "columns": 0,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "exp_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": "Expected End Date",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "exp_end_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
+   "search_index": 1
   },
   {
-   "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": "progress",
    "fieldtype": "Percent",
-   "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": "% Progress",
-   "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": "% Progress"
   },
   {
-   "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": "is_milestone",
    "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": "Is Milestone",
-   "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": "Is Milestone"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "collapsible_depends_on": "",
-   "columns": 0,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "sb_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": "Details",
-   "length": 0,
-   "no_copy": 0,
-   "oldfieldtype": "Section Break",
-   "options": "",
-   "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
+   "oldfieldtype": "Section Break"
   },
   {
-   "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": "description",
    "fieldtype": "Text Editor",
-   "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": "Task Description",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "description",
    "oldfieldtype": "Text Editor",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
    "print_width": "300px",
-   "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": "300px"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "collapsible_depends_on": "",
-   "columns": 0,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "sb_depends_on",
    "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": "Depends On",
-   "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
+   "label": "Dependencies",
+   "oldfieldtype": "Section Break"
   },
   {
-   "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": "depends_on",
    "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": "depends_on",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Task Depends On",
-   "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": "Dependent Tasks",
+   "options": "Task Depends On"
   },
   {
-   "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": "depends_on_tasks",
    "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": "Depends on Tasks",
-   "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,
-   "collapsible_depends_on": "",
-   "columns": 0,
-   "depends_on": "",
-   "description": "",
-   "fetch_if_empty": 0,
    "fieldname": "sb_actual",
    "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": "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,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "act_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": "Actual Start Date (via Time Sheet)",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "act_start_date",
    "oldfieldtype": "Date",
-   "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
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "",
-   "depends_on": "",
-   "description": "",
-   "fetch_if_empty": 0,
    "fieldname": "actual_time",
    "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": "Actual Time (in hours)",
-   "length": 0,
-   "no_copy": 0,
-   "options": "",
-   "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_if_empty": 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,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "act_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": "Actual End Date (via Time Sheet)",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "act_end_date",
    "oldfieldtype": "Date",
-   "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
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
    "collapsible": 1,
-   "columns": 0,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "sb_costing",
    "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": "Costing",
-   "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": "Costing"
   },
   {
-   "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": "total_costing_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 Costing Amount (via Time Sheet)",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "actual_budget",
    "oldfieldtype": "Currency",
    "options": "Company:company:default_currency",
-   "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
+   "read_only": 1
   },
   {
-   "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": "total_expense_claim",
    "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 Expense Claim (via Expense Claim)",
-   "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,
-   "fetch_if_empty": 0,
    "fieldname": "column_break_20",
-   "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,
-   "depends_on": "",
-   "fetch_if_empty": 0,
    "fieldname": "total_billing_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 Billing Amount (via Time Sheet)",
-   "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": 1,
-   "columns": 0,
-   "fetch_if_empty": 0,
    "fieldname": "sb_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 Info",
-   "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
+   "label": "More Info"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "depends_on": "eval:doc.status == \"Closed\" || doc.status == \"Pending Review\"",
-   "fetch_if_empty": 0,
    "fieldname": "review_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": "Review Date",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "review_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": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "oldfieldtype": "Date"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "depends_on": "eval:doc.status == \"Closed\"",
-   "fetch_if_empty": 0,
    "fieldname": "closing_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": "Closing Date",
-   "length": 0,
-   "no_copy": 0,
    "oldfieldname": "closing_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": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "oldfieldtype": "Date"
   },
   {
-   "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,
-   "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,
-   "fetch_if_empty": 0,
    "fieldname": "department",
    "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": "Department",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Department",
-   "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": "Department"
   },
   {
-   "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,
    "options": "Company",
-   "permlevel": 0,
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 1,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "remember_last_selected_value": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fetch_if_empty": 0,
    "fieldname": "lft",
    "fieldtype": "Int",
    "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": "lft",
-   "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_if_empty": 0,
    "fieldname": "rgt",
    "fieldtype": "Int",
    "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": "rgt",
-   "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_if_empty": 0,
    "fieldname": "old_parent",
    "fieldtype": "Data",
    "hidden": 1,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Old Parent",
-   "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
   }
  ],
- "has_web_view": 0,
- "hide_toolbar": 0,
  "icon": "fa fa-check",
  "idx": 1,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
  "max_attachments": 5,
- "menu_index": 0,
- "modified": "2019-04-20 22:45:20.777600",
+ "modified": "2019-04-29 14:48:10.204819",
  "modified_by": "Administrator",
  "module": "Projects",
  "name": "Task",
  "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
    "delete": 1,
    "email": 1,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Projects User",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   }
  ],
- "quick_entry": 0,
- "read_only": 0,
  "search_fields": "subject",
  "show_name_in_global_search": 1,
  "sort_order": "DESC",
  "timeline_field": "project",
  "title_field": "subject",
- "track_changes": 0,
- "track_seen": 1,
- "track_views": 0
+ "track_seen": 1
 }
\ No newline at end of file
diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js
index 5291d4f..343e65e 100644
--- a/erpnext/public/js/controllers/transaction.js
+++ b/erpnext/public/js/controllers/transaction.js
@@ -1199,6 +1199,7 @@
 					"qty": d.qty,
 					"stock_qty": d.stock_qty,
 					"uom": d.uom,
+					"stock_uom": d.stock_uom,
 					"parenttype": d.parenttype,
 					"parent": d.parent,
 					"pricing_rules": d.pricing_rules,
diff --git a/erpnext/public/js/education/lms/components/Breadcrumb.vue b/erpnext/public/js/education/lms/components/Breadcrumb.vue
index e7c0fc3..1b617a3 100644
--- a/erpnext/public/js/education/lms/components/Breadcrumb.vue
+++ b/erpnext/public/js/education/lms/components/Breadcrumb.vue
@@ -1,8 +1,15 @@
 <template>
 	<div>
-		<span v-for="(route, index) in routeData">
-			<router-link :to="route.route">{{ route.label }}</router-link><span> / </span>
-		</span>
+		<nav aria-label="breadcrumb">
+			<ol class="breadcrumb">
+				<li v-for="(route, index) in routeData" class="breadcrumb-item active" aria-current="page">
+					<router-link v-if="index != routeData.length - 1" :to="route.route">
+						{{ route.label }}
+					</router-link>
+					<span v-else>{{ route.label }}</span>
+				</li>
+			</ol>
+		</nav>
 	</div>
 </template>
 <script type="text/javascript">
diff --git a/erpnext/public/js/education/lms/components/CourseCard.vue b/erpnext/public/js/education/lms/components/CourseCard.vue
index 223654f..16f8873 100644
--- a/erpnext/public/js/education/lms/components/CourseCard.vue
+++ b/erpnext/public/js/education/lms/components/CourseCard.vue
@@ -1,5 +1,5 @@
 <template>
-    <div class="mt-3 col-md-4 col-sm-12">
+    <div class="py-3 col-md-4 col-sm-12">
         <div class="card h-100">
             <div class="card-hero-img" v-if="course.hero_image" v-bind:style="{ 'background-image': 'url(' + image + ')' }"></div>
             <div v-else class="card-image-wrapper">
diff --git a/erpnext/public/js/education/lms/components/ProgramCard.vue b/erpnext/public/js/education/lms/components/ProgramCard.vue
index 26d3882..20de085 100644
--- a/erpnext/public/js/education/lms/components/ProgramCard.vue
+++ b/erpnext/public/js/education/lms/components/ProgramCard.vue
@@ -1,5 +1,5 @@
 <template>
-<div class='mt-3 col-md-4 col-sm-12'>
+<div class='py-3 col-md-4 col-sm-12'>
     <div class="card h-100">
         <router-link :to="'/Program/' + program.name">
             <div class="card-hero-img" v-if="program.hero_image" v-bind:style="{ 'background-image': 'url(' + image + ')' }"></div>
diff --git a/erpnext/public/js/education/lms/components/ProgressCard.vue b/erpnext/public/js/education/lms/components/ProgressCard.vue
index 77fb6ef..66b61f6 100644
--- a/erpnext/public/js/education/lms/components/ProgressCard.vue
+++ b/erpnext/public/js/education/lms/components/ProgressCard.vue
@@ -1,5 +1,5 @@
 <template>
-    <div class='mt-3 col-md-4 col-sm-12'>
+    <div class='py-3 col-md-4 col-sm-12'>
         <div class="card h-100">
             <div class='card-body'>
                 <router-link :to="'/Program/' + programData.name">
diff --git a/erpnext/public/js/education/lms/components/ScoreCard.vue b/erpnext/public/js/education/lms/components/ScoreCard.vue
index 1cf53ef..80b12cb 100644
--- a/erpnext/public/js/education/lms/components/ScoreCard.vue
+++ b/erpnext/public/js/education/lms/components/ScoreCard.vue
@@ -1,5 +1,5 @@
 <template>
-    <div v-if="quizData" class='mt-3 col-md-4 col-sm-12'>
+    <div v-if="quizData" class='py-3 col-md-4 col-sm-12'>
         <div class="card h-100">
             <div class='card-body'>
                 <h5 class='card-title'>{{ quizData.program }}</h5>
diff --git a/erpnext/public/js/education/lms/components/TopicCard.vue b/erpnext/public/js/education/lms/components/TopicCard.vue
index 3e930df..4cb8e85 100644
--- a/erpnext/public/js/education/lms/components/TopicCard.vue
+++ b/erpnext/public/js/education/lms/components/TopicCard.vue
@@ -1,6 +1,6 @@
 
 <template>
-    <div class="mt-3 col-md-4 col-sm-12">
+    <div class="py-3 col-md-4 col-sm-12">
         <div class="card h-100">
             <div class="card-hero-img" v-if="topic.hero_image" v-bind:style="{ 'background-image': 'url(' + image + ')' }"></div>
             <div v-else class="card-image-wrapper">
diff --git a/erpnext/public/js/newsletter.js b/erpnext/public/js/newsletter.js
new file mode 100644
index 0000000..3a4dbf8
--- /dev/null
+++ b/erpnext/public/js/newsletter.js
@@ -0,0 +1,8 @@
+// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
+// License: GNU General Public License v3. See license.txt
+
+frappe.ui.form.on('Newsletter', {
+	refresh() {
+		erpnext.toggle_naming_series();
+	}
+});
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index fc11e11..fb7a335 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -551,7 +551,7 @@
 		"Sales Order Item": {
 			"doctype": "Project Task",
 			"field_map": {
-				"description": "title",
+				"item_code": "title",
 			},
 		}
 	}, target_doc, postprocess)
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 4d8022c..30a45dd 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -492,7 +492,7 @@
 def get_item_price(args, item_code, ignore_party=False):
 	"""
 		Get name, price_list_rate from Item Price based on conditions
-			Check if the Derised qty is within the increment of the packing list.
+			Check if the desired qty is within the increment of the packing list.
 		:param args: dict (or frappe._dict) with mandatory fields price_list, uom
 			optional fields min_qty, transaction_date, customer, supplier
 		:param item_code: str, Item Doctype field item_code
@@ -530,11 +530,11 @@
 		for min_qty 9 and min_qty 20. It returns Item Price Rate for qty 9 as
 		the best fit in the range of avaliable min_qtyies
 
-        :param customer: link to Customer DocType
-        :param supplier: link to Supplier DocType
+		:param customer: link to Customer DocType
+		:param supplier: link to Supplier DocType
 		:param price_list: str (Standard Buying or Standard Selling)
 		:param item_code: str, Item Doctype field item_code
-		:param qty: Derised Qty
+		:param qty: Desired Qty
 		:param transaction_date: Date of the price
 	"""
 	item_price_args = {
@@ -559,7 +559,7 @@
 
 		general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party"))
 		if not general_price_list_rate and args.get("uom") != args.get("stock_uom"):
-			item_price_args["args"] = args.get("stock_uom")
+			item_price_args["uom"] = args.get("stock_uom")
 			general_price_list_rate = get_item_price(item_price_args, item_code, ignore_party=args.get("ignore_party"))
 
 		if general_price_list_rate:
@@ -575,11 +575,11 @@
 
 def check_packing_list(price_list_rate_name, desired_qty, item_code):
 	"""
-		Check if the Derised qty is within the increment of the packing list.
+		Check if the desired qty is within the increment of the packing list.
 		:param price_list_rate_name: Name of Item Price
-        :param desired_qty: Derised Qt
+		:param desired_qty: Desired Qt
 		:param item_code: str, Item Doctype field item_code
-		:param qty: Derised Qt
+		:param qty: Desired Qt
 	"""
 
 	flag = True