Merge pull request #4175 from anandpdoshi/dynamic-linked-with

[fix] exclude gl entry and stock ledger entry in linked with. Depends on frappe/frappe#1339
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index 3927b8e..d74b9dc 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -11,6 +11,8 @@
 from erpnext.setup.doctype.company.company import get_company_currency
 from erpnext.exceptions import InvalidAccountCurrency, CustomerFrozen
 
+exclude_from_linked_with = True
+
 class GLEntry(Document):
 	def validate(self):
 		self.flags.ignore_submit_comment = True
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py
index 764dd78..742adc6 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe, json, copy
 
-from frappe.utils import cstr, flt, getdate
+from frappe.utils import cstr, flt, getdate, strip
 from frappe import _
 from frappe.utils.file_manager import save_file
 from frappe.translate import (set_default_language, get_dict,
@@ -23,12 +23,7 @@
 		if frappe.db.sql("select name from tabCompany"):
 			frappe.throw(_("Setup Already Complete!!"))
 
-		if not args:
-			args = frappe.local.form_dict
-		if isinstance(args, basestring):
-			args = json.loads(args)
-
-		args = frappe._dict(args)
+		args = process_args(args)
 
 		if args.language and args.language != "english":
 			set_default_language(args.language)
@@ -109,6 +104,21 @@
 			frappe.get_attr(hook)(args)
 
 
+def process_args(args):
+	if not args:
+		args = frappe.local.form_dict
+	if isinstance(args, basestring):
+		args = json.loads(args)
+
+	args = frappe._dict(args)
+
+	# strip the whitespace
+	for key, value in args.items():
+		if isinstance(value, basestring):
+			args[key] = strip(value)
+
+	return args
+
 def update_user_name(args):
 	if args.get("email"):
 		args['name'] = args.get("email")
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index 33fc658..37d1ab1 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -12,6 +12,8 @@
 
 class StockFreezeError(frappe.ValidationError): pass
 
+exclude_from_linked_with = True
+
 class StockLedgerEntry(Document):
 	def validate(self):
 		self.flags.ignore_submit_comment = True