Merge branch 'unicode' of github.com:webnotes/erpnext into unicode
diff --git a/erpnext/accounts/doctype/c_form/c_form.js b/erpnext/accounts/doctype/c_form/c_form.js
index 4fb3227..d9e5c68 100644
--- a/erpnext/accounts/doctype/c_form/c_form.js
+++ b/erpnext/accounts/doctype/c_form/c_form.js
@@ -17,10 +17,13 @@
 //c-form js file
 // -----------------------------
 cur_frm.fields_dict.invoice_details.grid.get_field("invoice_no").get_query = function(doc) {
-	return 'SELECT `tabSales Invoice`.`name` FROM `tabSales Invoice` WHERE `tabSales Invoice`.`company` = "' +doc.company+'" AND `tabSales Invoice`.%(key)s LIKE "%s" AND `tabSales Invoice`.`customer` = "' + doc.customer + '" AND `tabSales Invoice`.`docstatus` = 1 and `tabSales Invoice`.`c_form_applicable` = "Yes" and ifnull(`tabSales Invoice`.c_form_no, "") = "" ORDER BY `tabSales Invoice`.`name` ASC LIMIT 50';
+	cond = ""
+	if (doc.customer) cond += ' AND `tabSales Invoice`.`customer` = "' + cstr(doc.customer) + '"';
+	if (doc.company) cond += ' AND `tabSales Invoice`.`company` = "' + cstr(doc.company) + '"';
+	return 'SELECT `tabSales Invoice`.`name` FROM `tabSales Invoice` WHERE `tabSales Invoice`.`docstatus` = 1 and `tabSales Invoice`.`c_form_applicable` = "Yes" and ifnull(`tabSales Invoice`.c_form_no, "") = ""'+cond+' AND `tabSales Invoice`.%(key)s LIKE "%s" ORDER BY `tabSales Invoice`.`name` ASC LIMIT 50';
 }
 
 cur_frm.cscript.invoice_no = function(doc, cdt, cdn) {
 	var d = locals[cdt][cdn];
 	get_server_fields('get_invoice_details', d.invoice_no, 'invoice_details', doc, cdt, cdn, 1);
-}
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py
index 7429821..57d9a29 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.py
+++ b/erpnext/accounts/doctype/cost_center/cost_center.py
@@ -73,7 +73,7 @@
 	def validate_budget_details(self):
 		check_acc_list = []
 		for d in getlist(self.doclist, 'budget_details'):
-			if doc.group_or_ledger=="Group":
+			if self.doc.group_or_ledger=="Group":
 				msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1)
 				
 			if [d.account, d.fiscal_year] in check_acc_list:
diff --git a/erpnext/accounts/doctype/gl_control/gl_control.py b/erpnext/accounts/doctype/gl_control/gl_control.py
index 2acb5ef..bd10d6c 100644
--- a/erpnext/accounts/doctype/gl_control/gl_control.py
+++ b/erpnext/accounts/doctype/gl_control/gl_control.py
@@ -622,7 +622,7 @@
 					<td width = "50%%">Invoice Date	   : %s<br>Invoice Period : %s to %s <br>Due Date	   : %s</td>
 				</tr>
 			</table>
-		''' % (com, new_rv.doc.name, new_rv.doc.customer, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
+		''' % (com, new_rv.doc.name, new_rv.doc.customer_name, new_rv.doc.address_display, getdate(new_rv.doc.posting_date).strftime("%d-%m-%Y"), \
 		getdate(new_rv.doc.invoice_period_from_date).strftime("%d-%m-%Y"), getdate(new_rv.doc.invoice_period_to_date).strftime("%d-%m-%Y"),\
 		getdate(new_rv.doc.due_date).strftime("%d-%m-%Y"))
 	
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher_list.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher_list.js
index 129f3cd..e31cee8 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher_list.js
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher_list.js
@@ -6,6 +6,7 @@
 			'`tabJournal Voucher`.remark',
 			'`tabJournal Voucher`.total_debit',
 			'`tabJournal Voucher`.company',
+			"`tabJournal Voucher`.posting_date",
 		]);
 		this.stats = this.stats.concat(['voucher_type', 'company']);
 	},
@@ -31,6 +32,8 @@
 			},
 			css: {'text-align':'right'}
 		},
-		{width: '12%', content: 'modified', css: {'text-align': 'right', 'color':'#777'}}		
+		{width: '12%', content:'posting_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Journal Voucher Date", type: "date"}
 	],
 });
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index fe65e95..d9c3fb1 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -174,15 +174,13 @@
 		self.doclist = get_obj('GL Control').get_advances(self, self.doc.credit_to, 'Purchase Invoice Advance','advance_allocation_details','debit')
 		
 		
-	# ============= OTHER CHARGES ====================
-	
-	# Get Tax rate if account type is TAX
-	# ------------------------------------
 	def get_rate(self,arg):
 		return get_obj('Purchase Common').get_rate(arg,self)
 
-	# Get Purchase Taxes and Charges Master
-	# -----------------------------------------------------------
+	def load_default_taxes(self):
+		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
+	
+	
 	def get_purchase_tax_details(self):
 		self.doclist =  get_obj('Purchase Common').get_purchase_tax_details(self)
 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js
index c0c6625..f9dd4cd 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice_list.js
@@ -9,6 +9,7 @@
 			'IFNULL(`tabPurchase Invoice`.grand_total_import, 0) as grand_total_import',
 			'IFNULL(`tabPurchase Invoice`.grand_total, 0) as grand_total',
 			'IFNULL(`tabPurchase Invoice`.outstanding_amount, 0) as outstanding_amount',
+			"`tabPurchase Invoice`.posting_date"
 		]);
 		this.stats = this.stats.concat(['company']);
 	},
@@ -40,8 +41,8 @@
 			css: {'text-align':'right'}
 		},
 		{width: '10%', content: 'paid', type:'bar-graph', label:'Paid'},
-		{width: '12%', content:'modified', css: {
-			'text-align': 'right', 'color':'#777'
-		}},
+		{width: '12%', content:'posting_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Purchase Invoice Date", type: "date"},
 	]
 });
diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt
index 8add7af..5c72c2c 100644
--- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt
+++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-07-03 13:30:50',
+		'creation': '2012-05-15 12:14:32',
 		'docstatus': 0,
-		'modified': '2012-07-12 14:10:35',
+		'modified': '2012-08-17 09:57:04',
 		'modified_by': u'Administrator',
 		'owner': u'wasim@webnotestech.com'
 	},
@@ -110,6 +110,25 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'is_default',
+		'fieldtype': u'Check',
+		'label': u'Default'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'company',
+		'fieldtype': u'Link',
+		'in_filter': 1,
+		'label': u'Company',
+		'options': u'Company',
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldname': u'purchase_tax_details',
 		'fieldtype': u'Table',
 		'label': u'Purchase Taxes and Charges',
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index 4563532..9e0a4eb 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -78,35 +78,32 @@
 	'source', 'cancel_reason', 'total_advance', 'gross_profit',
 	'gross_profit_percent', 'get_advances_received',
 	'advance_adjustment_details', 'sales_partner', 'commission_rate',
-	'total_commission'];
+	'total_commission', 'advances'];
 	
 	item_flds_normal = ['sales_order', 'delivery_note']
 	item_flds_pos = ['warehouse', 'serial_no', 'batch_no', 'actual_qty', 'delivered_qty']
 	
 	if(cint(doc.is_pos) == 1) {
 		hide_field(par_flds);
-		$(cur_frm.fields_dict.payments_section.row.wrapper).toggle(true);
-		$(cur_frm.fields_dict.advances.row.wrapper).toggle(false);
+		unhide_field('payments_section');
 		for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], false);
 		for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], (doc.update_stock==1?true:false));
 	} else {
+		hide_field('payments_section');
 		unhide_field(par_flds);
-		$(cur_frm.fields_dict.payments_section.row.wrapper).toggle(false);
-		$(cur_frm.fields_dict.advances.row.wrapper).toggle(true);
 		for(f in item_flds_normal) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_normal[f], true);
 		for(f in item_flds_pos) cur_frm.fields_dict['entries'].grid.set_column_disp(item_flds_pos[f], false);
 	}
-	if (doc.docstatus==1) $(cur_frm.fields_dict.recurring_invoice.row.wrapper).toggle(true);
-	else $(cur_frm.fields_dict.recurring_invoice.row.wrapper).toggle(false);
+	if (doc.docstatus==1) unhide_field('recurring_invoice');
+	else hide_field('recurring_invoice');
 
-	if(doc.customer) $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(true);
-	else $(cur_frm.fields_dict.contact_section.row.wrapper).toggle(false);
+	if(doc.customer) unhide_field('contact_section');
+	else hide_field('contact_section');
 
 	// India related fields
 	var cp = wn.control_panel;
 	if (cp.country == 'India') unhide_field(['c_form_applicable', 'c_form_no']);
 	else hide_field(['c_form_applicable', 'c_form_no']);
-
 }
 
 
@@ -114,7 +111,6 @@
 // -------
 cur_frm.cscript.refresh = function(doc, dt, dn) {
 	cur_frm.cscript.is_opening(doc, dt, dn);
-	cur_frm.cscript.hide_fields(doc, dt, dn);
 	erpnext.hide_naming_series();
 
 	// Show / Hide button
@@ -131,6 +127,8 @@
 		if(doc.outstanding_amount!=0)
 			cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
 	}
+	cur_frm.cscript.hide_fields(doc, dt, dn);
+	
 }
 
 //fetch retail transaction related fields
@@ -191,7 +189,7 @@
 	var args = onload ? 'onload':''
 	if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', args, callback);
 
-	if(doc.customer) unhide_field(['customer_address','contact_person', 'territory','customer_group']);
+	if(doc.customer) unhide_field('contact_section');
 	
 }
 
@@ -231,7 +229,7 @@
 	var callback = function(r,rt) {
 			var doc = locals[cur_frm.doctype][cur_frm.docname];
 			if(doc.customer) $c_obj(make_doclist(dt,dn), 'get_default_customer_address', '', callback2);
-			if(doc.customer) unhide_field(['customer_address','contact_person','territory','customer_group']);
+			if(doc.customer) unhide_field('contact_section');
 			cur_frm.refresh();
 	}
 
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt
index b1368d1..ad92d22 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-07-13 11:57:13',
+		'creation': '2012-07-18 16:02:44',
 		'docstatus': 0,
-		'modified': '2012-07-16 16:25:11',
+		'modified': '2012-09-07 11:56:59',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -55,6 +55,66 @@
 		'name': u'Sales Invoice'
 	},
 
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': u'DocPerm',
+		'permlevel': 1,
+		'role': u'Accounts Manager',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': u'DocPerm',
+		'permlevel': 0,
+		'role': u'Accounts Manager',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 1,
+		'cancel': 1,
+		'create': 1,
+		'doctype': u'DocPerm',
+		'permlevel': 0,
+		'role': u'Accounts User',
+		'submit': 1,
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': u'DocPerm',
+		'permlevel': 1,
+		'role': u'Accounts User',
+		'submit': 0,
+		'write': 0
+	},
+
+	# DocPerm
+	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': u'DocPerm',
+		'permlevel': 0,
+		'role': u'Customer',
+		'submit': 0,
+		'write': 0
+	},
+
 	# DocField
 	{
 		'doctype': u'DocField',
@@ -812,7 +872,7 @@
 		'doctype': u'DocField',
 		'fieldname': u'write_off_outstanding_amount_automatically',
 		'fieldtype': u'Check',
-		'label': u'Write Off Outstanding Amount Automatically',
+		'label': u'Write Off Outstanding Amount',
 		'permlevel': 0,
 		'print_hide': 1
 	},
@@ -1487,6 +1547,7 @@
 	# DocField
 	{
 		'allow_on_submit': 1,
+		'colour': u'White:FFF',
 		'depends_on': u'eval:doc.convert_into_recurring_invoice==1',
 		'description': u'Start date of the invoice period',
 		'doctype': u'DocField',
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js
index ae923f4..1c3b2d3 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js
@@ -8,7 +8,8 @@
 			"ifnull(`tabSales Invoice`.outstanding_amount,0) as outstanding_amount", 
 			"ifnull(`tabSales Invoice`.grand_total,0) as grand_total", 
 			"`tabSales Invoice`.currency", 
-			"ifnull(`tabSales Invoice`.grand_total_export,0) as grand_total_export"
+			"ifnull(`tabSales Invoice`.grand_total_export,0) as grand_total_export",
+			"`tabSales Invoice`.posting_date",
 		]);
 	},
 	prepare_data: function(data) {
@@ -35,6 +36,8 @@
 			css: {'text-align':'right'}
 		},
 		{width: '10%', content: 'paid', type:'bar-graph', label:'Paid'},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'posting_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Sales Invoice Date", type: "date"}
 	]
 });
diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.js b/erpnext/accounts/page/accounts_browser/accounts_browser.js
index 5bc2e35..55d6be9 100644
--- a/erpnext/accounts/page/accounts_browser/accounts_browser.js
+++ b/erpnext/accounts/page/accounts_browser/accounts_browser.js
@@ -22,7 +22,12 @@
 
 pscript['onload_Accounts Browser'] = function(wrapper){
 	wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
-	wrapper.appframe.add_button('New Company', function() { newdoc('Company'); }, 'icon-plus');
+	
+	if (wn.boot.profile.can_create.indexOf("Company") !== -1) {
+		wrapper.appframe.add_button('New Company', function() { newdoc('Company'); },
+			'icon-plus');
+	}
+	
 	wrapper.appframe.add_button('Refresh', function() {  	
 			wrapper.$company_select.change();
 		}, 'icon-refresh');
@@ -35,17 +40,6 @@
 		})
 		.appendTo(wrapper.appframe.$w.find('.appframe-toolbar'));
 		
-	// default company
-	if(sys_defaults.company) {
-		$('<option>')
-			.html(sys_defaults.company)
-			.attr('value', sys_defaults.company)
-			.appendTo(wrapper.$company_select);
-
-		wrapper.$company_select
-			.val(sys_defaults.company).change();
-	}
-
 	// load up companies
 	wn.call({
 		method:'accounts.page.accounts_browser.accounts_browser.get_companies',
@@ -54,7 +48,7 @@
 			$.each(r.message, function(i, v) {
 				$('<option>').html(v).attr('value', v).appendTo(wrapper.$company_select);
 			});
-			wrapper.$company_select.val(sys_defaults.company || r[0]);
+			wrapper.$company_select.val(sys_defaults.company || r[0]).change();
 		}
 	});
 }
@@ -120,15 +114,23 @@
 		if(!data) return;
 
 		link.toolbar = $('<span class="tree-node-toolbar"></span>').insertAfter(link);
+		
+		var node_links = [];
 		// edit
-		$('<a href="#!Form/'+encodeURIComponent(this.ctype)+'/'
-			+encodeURIComponent(data.value)+'">Edit</a>').appendTo(link.toolbar);
-
-		if(data.expandable) {
-			link.toolbar.append(' | <a onclick="erpnext.account_chart.new_node();">Add Child</a>');
-		} else if(this.ctype=='Account') {
-			link.toolbar.append(' | <a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
+		if (wn.boot.profile.can_read.indexOf(this.ctype) !== -1) {
+			node_links.push('<a href="#!Form/'+encodeURIComponent(this.ctype)+'/'
+				+encodeURIComponent(data.value)+'">Edit</a>');
 		}
+		if (data.expandable) {
+			if (wn.boot.profile.can_create.indexOf(this.ctype) !== -1 ||
+					wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
+				node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
+			}
+		} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
+			node_links.push('<a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
+		}
+		
+		link.toolbar.append(node_links.join(" | "));
 	},
 	show_ledger: function() {
 		var me = this;
diff --git a/erpnext/accounts/page/accounts_browser/accounts_browser.py b/erpnext/accounts/page/accounts_browser/accounts_browser.py
index f2c0d9c..aa955ae 100644
--- a/erpnext/accounts/page/accounts_browser/accounts_browser.py
+++ b/erpnext/accounts/page/accounts_browser/accounts_browser.py
@@ -4,7 +4,21 @@
 
 @webnotes.whitelist()
 def get_companies():
-	return [r[0] for r in webnotes.conn.sql("""select name from tabCompany where docstatus!=2""")]
+	"""get a list of companies based on permission"""
+	
+	# check if match permission exists
+	res = webnotes.conn.sql("""select role, `match` from `tabDocPerm`
+		where parent='Account' and permlevel=0 and `read`=1""", as_dict=1)
+		
+	match = any((r["match"] for r in res 
+		if r["role"] in webnotes.user.roles and r["match"]=="company"))
+	
+	# if match == company is specified and companies are specified in user defaults
+	if match and webnotes.user.get_defaults().get("company"):
+		return webnotes.user.get_defaults().get("company")
+	else:
+		return [r[0] for r in webnotes.conn.sql("""select name from tabCompany
+			where docstatus!=2""")]
 	
 @webnotes.whitelist()
 def get_children():
diff --git a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.js b/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.js
deleted file mode 100644
index 8bcfa15..0000000
--- a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.js
+++ /dev/null
@@ -1,34 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-// 
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-report.customize_filters = function() {
-  this.hide_all_filters();
-  this.add_filter({fieldname:'show_group_balance', label:'Show Group Balance', fieldtype:'Select', options:NEWLINE+'Yes'+NEWLINE+'No',ignore : 1, parent:'Account'});
-  this.add_filter({fieldname:'level', label:'Level', fieldtype:'Data', default:3,ignore : 1, parent:'Account'});
-  
-  this.add_filter({fieldname:'from_date', label:'Date', fieldtype:'Date', parent:'Account'});
-
-  
-  this.filter_fields_dict['Account'+FILTER_SEP +'Company'].df.filter_hide = 0;
-  //this.filter_fields_dict['Account'+FILTER_SEP +'From Date'].df.filter_hide = 0;
-  //this.filter_fields_dict['Account'+FILTER_SEP +'To Date'].df.filter_hide = 0;
-
-  //this.large_report = 1;
-}
-
-report.aftertableprint = function(t) {
-   $yt(t,'*',1,{whiteSpace:'pre'});
-}
\ No newline at end of file
diff --git a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.sql b/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.sql
deleted file mode 100644
index 381e8de..0000000
--- a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.sql
+++ /dev/null
@@ -1,9 +0,0 @@
-SELECT 
-  DISTINCT node.name AS name 
-  FROM tabAccount AS node, tabAccount AS parent 
-  WHERE node.lft BETWEEN parent.lft AND parent.rgt 
-    AND node.company = '%(company)s' 
-    AND node.is_pl_account = 'No' 
-    AND node.level=%(level)s
-    AND ifnull(node.account_type,'') != 'Bank or Cash'
-  ORDER BY node.lft
diff --git a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.txt b/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.txt
deleted file mode 100644
index a9e748e..0000000
--- a/erpnext/accounts/search_criteria/cash_flow_statement/cash_flow_statement.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-# Search Criteria, cash_flow_statement
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2012-04-11 17:36:48',
-		'docstatus': 0,
-		'modified': '2012-04-18 12:17:52',
-		'modified_by': u'Administrator',
-		'owner': u'Administrator'
-	},
-
-	# These values are common for all Search Criteria
-	{
-		'columns': u'Account\x01ID',
-		'criteria_name': u'Cash Flow Statement',
-		'dis_filters': u'fiscal_year',
-		'doc_type': u'Account',
-		'doctype': 'Search Criteria',
-		'filters': u"{'Account\x01Group or Ledger':'Ledger','Account\x01Is PL Account':'','Account\x01Is Active':'','Account\x01Account Type':'','Account\x01Company':'','Account\x01Fiscal Year':'','Account\x01Show Group Balance':'','Account\x01Level':'2'}",
-		'module': u'Accounts',
-		'name': '__common__',
-		'sort_by': u'`tabAccount`.`name`',
-		'sort_order': u'DESC',
-		'standard': u'Yes'
-	},
-
-	# Search Criteria, cash_flow_statement
-	{
-		'doctype': 'Search Criteria',
-		'name': u'cash_flow_statement'
-	}
-]
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 8a1c9ee..33c05df 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -29,10 +29,26 @@
 		}
 }
 
+cur_frm.cscript.load_taxes = function(doc, cdt, cdn, callback) {
+	// run if this is not executed from dt_map...
+	doc = locals[doc.doctype][doc.name];
+	if(doc.supplier || getchildren('Purchase Taxes and Charges', doc.name, 'purchase_tax_details', doc.doctype).length) {
+		if(callback) {
+			callback(doc, cdt, cdn);
+		}
+	} else {
+		$c_obj(make_doclist(doc.doctype, doc.name),'load_default_taxes','',function(r,rt){
+			refresh_field('purchase_tax_details');
+			if(callback) callback(doc, cdt, cdn);
+		});
+	}
+}
+
+
 
 // Gets called after existing item details are update to fill in
 // remaining default values
-cur_frm.cscript.load_defaults = function(doc, dt, dn) {
+cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) {
 	if(!cur_frm.doc.__islocal) { return; }
 
 	doc = locals[doc.doctype][doc.name];
@@ -46,6 +62,7 @@
 		LocalDB.set_default_values(children[i]);
 	}
 	refresh_field(cur_frm.cscript.fname);
+	cur_frm.cscript.load_taxes(doc, dt, dn, callback);
 }
 
 // Update existing item details
@@ -58,10 +75,11 @@
 			if(!r.exc) {
 				refresh_field(cur_frm.cscript.fname);
 				doc = locals[doc.doctype][doc.name];
-				cur_frm.cscript.load_defaults(doc, dt, dn);
-				if(callback) callback(doc, dt, dn);
+				cur_frm.cscript.load_defaults(doc, dt, dn, callback);
 			}
 		});
+	} else {
+		cur_frm.cscript.load_taxes(doc, dt, dn, callback);
 	}
 }
 
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py
index b9e689f..b8424ab 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.py
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.py
@@ -624,15 +624,23 @@
 			msgprint("'%s' Not Within The Fiscal Year"%(dn))
 			raise Exception			
 
-
-#---Other charges starting point------------------------
-
-	# Get other charges from Master
-	# =================================================================================
-	def get_purchase_tax_details(self,obj):
+	def load_default_taxes(self, obj):
+		return self.get_purchase_tax_details(obj, 1)
+	
+	def get_purchase_tax_details(self,obj, default = 0):
 		obj.doclist = self.doc.clear_table(obj.doclist,'purchase_tax_details')
+		
+		if default: add_cond = " and ifnull(t2.is_default,0) = 1"
+		else: add_cond = " and t1.parent = '"+cstr(obj.doc.purchase_other_charges)+"'"
+
+		other_charge = sql("""
+			select t1.*
+			from `tabPurchase Taxes and Charges` t1, `tabPurchase Taxes and Charges Master` t2
+			where t1.parent = t2.name %s
+			order by t1.idx
+		"""% add_cond, as_dict = 1)
+		
 		idx = 0
-		other_charge = sql("select category, add_deduct_tax, charge_type,row_id,description,account_head,rate,tax_amount from `tabPurchase Taxes and Charges` where parent = '%s' order by idx" %(obj.doc.purchase_other_charges), as_dict = 1)
 		for other in other_charge:
 			d =	addchild(obj.doc, 'purchase_tax_details', 'Purchase Taxes and Charges', 1, obj.doclist)
 			d.category = other['category']
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index a1983c3..4e8c2c0 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -36,7 +36,10 @@
 }
 
 cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
-	if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
+	var callback = function(doc, dt, dn) {
+		if(doc.__islocal) cur_frm.cscript.get_default_schedule_date(doc);
+	}
+	cur_frm.cscript.update_item_details(doc, dt, dn, callback);
 }
 
 cur_frm.cscript.refresh = function(doc, cdt, cdn) { 
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 533e8ad..65efd37 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -57,6 +57,7 @@
 
 	# Get Item Details
 	def get_item_details(self, arg =''):
+		import json
 		if arg:
 			return get_obj(dt='Purchase Common').get_item_details(self,arg)
 		else:
@@ -360,13 +361,11 @@
 		self.update_rw_material_detail()
 		
 
-# OTHER CHARGES TRIGGER FUNCTIONS
-# ====================================================================================
-	
-	# *********** Get Tax rate if account type is TAX ********************
 	def get_rate(self,arg):
-		return get_obj('Purchase Common').get_rate(arg,self)
+		return get_obj('Purchase Common').get_rate(arg,self)	
+	
+	def load_default_taxes(self):
+		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
 
-	# **** Pull details from other charges master (Get Other Charges) ****
 	def get_purchase_tax_details(self):
 		self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order_list.js b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
index 0f90e12..69f97f5 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order_list.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order_list.js
@@ -7,7 +7,9 @@
 			"ifnull(`tabPurchase Order`.per_received,0) as per_received",
 			"ifnull(`tabPurchase Order`.per_billed,0) as per_billed",
 			"`tabPurchase Order`.currency", 
-			"ifnull(`tabPurchase Order`.grand_total_import,0) as grand_total_import"
+			"ifnull(`tabPurchase Order`.grand_total_import,0) as grand_total_import",
+			"`tabPurchase Order`.transaction_date",
+			
 		]);
 		this.stats = this.stats.concat(['status', 'company']);
 	},
@@ -27,7 +29,9 @@
 		},
 		{width: '8%', content: 'per_received', type:'bar-graph', label:'Delivered'},
 		{width: '8%', content: 'per_billed', type:'bar-graph', label:'Billed'},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'transaction_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Purchase Order Date", type: "date"}
 	]
 
 });
diff --git a/erpnext/buying/doctype/purchase_request/purchase_request_list.js b/erpnext/buying/doctype/purchase_request/purchase_request_list.js
index e4266c7..967c2d4 100644
--- a/erpnext/buying/doctype/purchase_request/purchase_request_list.js
+++ b/erpnext/buying/doctype/purchase_request/purchase_request_list.js
@@ -6,6 +6,7 @@
 			"`tabPurchase Request`.status",
 			"IFNULL(`tabPurchase Request`.per_ordered, 0) as per_ordered",
 			"`tabPurchase Request`.remark",
+			"`tabPurchase Request`.transaction_date",
 		]);
 		this.stats = this.stats.concat(['status', 'company']);
 	},
@@ -28,7 +29,9 @@
 		{width: '17%', content:'name'},
 		{width: '50%', content:'status_html+remark+tags', css: {'color': '#222'}},
 		{width: '10%', content: 'per_ordered', type:'bar-graph', label:'Ordered'},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'transaction_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Quotation Date", type: "date"}
 	]
 });
 
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
index 430d1ee..6135ad4 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js
@@ -38,6 +38,7 @@
 cur_frm.cscript.refresh = function(doc, dt, dn) {
 	erpnext.hide_naming_series();
 	cur_frm.cscript.dynamic_label(doc, dt, dn);
+	cur_frm.cscript.load_taxes(doc, dt, dn);
 	
 	cur_frm.cscript.toggle_contact_section(doc);
 	
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
index 1577eab..057f8da 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -73,6 +73,9 @@
 					d.purchase_ref_rate = d.discount_rate = d.purchase_rate = 0.0
 					d.import_ref_rate = d.import_rate = 0.0
 	
+	def load_default_taxes(self):
+		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
+	
 	def get_purchase_tax_details(self):
 		self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
 
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation_list.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_list.js
new file mode 100644
index 0000000..60b1f52
--- /dev/null
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_list.js
@@ -0,0 +1,33 @@
+// render
+wn.doclistviews['Supplier Quotation'] = wn.views.ListView.extend({
+	init: function(d) {
+		this._super(d)
+		this.fields = this.fields.concat([
+			"`tabSupplier Quotation`.supplier_name",
+			"`tabSupplier Quotation`.currency", 
+			"ifnull(`tabSupplier Quotation`.grand_total_import,0) as grand_total_import",
+			"`tabSupplier Quotation`.transaction_date",
+		]);
+		this.stats = this.stats.concat(['status', 'company']);
+	},
+	
+	columns: [
+		{width: '3%', content: 'check'},
+		{width: '5%', content:'avatar'},
+		{width: '3%', content:'docstatus'},
+		{width: '15%', content:'name'},
+		{width: '44%', content:'supplier_name+tags', css: {color:'#222'}},
+		{
+			width: '18%', 
+			content: function(parent, data) { 
+				$(parent).html(data.currency + ' ' + fmt_money(data.grand_total_import)) 
+			},
+			css: {'text-align':'right'}
+		},
+		{width: '12%', content:'transaction_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Supplier Quotation Date", type: "date"}
+	]
+
+});
+
diff --git a/erpnext/buying/search_criteria/itemwise_purchase_details/itemwise_purchase_details.js b/erpnext/buying/search_criteria/itemwise_purchase_details/itemwise_purchase_details.js
index 603f915..139d69e 100644
--- a/erpnext/buying/search_criteria/itemwise_purchase_details/itemwise_purchase_details.js
+++ b/erpnext/buying/search_criteria/itemwise_purchase_details/itemwise_purchase_details.js
@@ -15,7 +15,7 @@
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 report.customize_filters = function() {
-  this.filter_fields_dict['Purchase Order'+FILTER_SEP +'From PO Date'].df['report_default'] = sys_defaults.year_start_date;
-  this.filter_fields_dict['Purchase Order'+FILTER_SEP +'To PO Date'].df['report_default'] = dateutil.obj_to_str(new Date());
+  this.filter_fields_dict['Purchase Order'+FILTER_SEP +'From Purchase Order Date'].df['report_default'] = sys_defaults.year_start_date;
+  this.filter_fields_dict['Purchase Order'+FILTER_SEP +'To Purchase Order Date'].df['report_default'] = dateutil.obj_to_str(new Date());
 
 }
\ No newline at end of file
diff --git a/erpnext/home/page/profile_settings/profile_settings.py b/erpnext/home/page/profile_settings/profile_settings.py
index 97d286e..0de424f 100644
--- a/erpnext/home/page/profile_settings/profile_settings.py
+++ b/erpnext/home/page/profile_settings/profile_settings.py
@@ -34,11 +34,14 @@
 	check_demo()
 	arg = load_json(arg)
 	
-	if not webnotes.conn.sql('select name from tabProfile where name=%s and password=password(%s)', (webnotes.session['user'], arg['old_password'])):
+	if not webnotes.conn.sql("""select * from `__Auth` where `user`=%s
+			and password=password(%s)""",
+			(webnotes.session["user"], arg["old_password"])):
 		webnotes.msgprint('Old password is not correct', raise_exception=1)
-	
-	from webnotes.utils import nowdate
-	webnotes.conn.sql("update tabProfile set password=password(%s), modified=%s where name=%s",(arg['new_password'], nowdate(), webnotes.session['user']))
+
+	webnotes.conn.sql("""update `__Auth` set password=password(%s)
+		where `user`=%s""", (arg["new_password"], webnotes.session["user"]))
+
 	webnotes.msgprint('Password Updated');
 
 @webnotes.whitelist()
diff --git a/erpnext/hr/page/hr_home/hr_home.html b/erpnext/hr/page/hr_home/hr_home.html
index 7f8fe73..36183b0 100644
--- a/erpnext/hr/page/hr_home/hr_home.html
+++ b/erpnext/hr/page/hr_home/hr_home.html
@@ -119,6 +119,16 @@
 					</div>
 				</div>
 			</div>
+			<div class="section">
+				<div class="section-head">Expense Claim</div>
+				<div class="section-body">
+					<div class="section-item">
+						<a class="section-link" 
+							title = "Types of Expense Claim"
+							href="#!List/Expense Claim Type">Expense Claim Type</a>
+					</div>
+				</div>
+			</div>
 		</div>
 	</div>
 	<div style="clear: both;"></div>
diff --git a/erpnext/patches/august_2012/changed_blog_date_format.py b/erpnext/patches/august_2012/changed_blog_date_format.py
new file mode 100644
index 0000000..047a4d9
--- /dev/null
+++ b/erpnext/patches/august_2012/changed_blog_date_format.py
@@ -0,0 +1,5 @@
+from __future__ import unicode_literals
+def execute():
+	import webnotes
+	from webnotes.model.doclist import DocList
+	DocList("Website Settings", "Website Settings").save()
\ No newline at end of file
diff --git a/erpnext/patches/august_2012/reload_stock_ledger.py b/erpnext/patches/august_2012/reload_stock_ledger.py
new file mode 100644
index 0000000..d0ec9ee
--- /dev/null
+++ b/erpnext/patches/august_2012/reload_stock_ledger.py
@@ -0,0 +1,4 @@
+def execute():
+	import webnotes
+	from webnotes.modules import reload_doc
+	reload_doc('stock', 'Report', 'Stock Ledger')
\ No newline at end of file
diff --git a/erpnext/patches/august_2012/remove_cash_flow_statement.py b/erpnext/patches/august_2012/remove_cash_flow_statement.py
new file mode 100644
index 0000000..739a4f2
--- /dev/null
+++ b/erpnext/patches/august_2012/remove_cash_flow_statement.py
@@ -0,0 +1,4 @@
+from __future__ import unicode_literals
+def execute():
+	import webnotes
+	webnotes.conn.sql("delete from `tabSearch Criteria` where name = 'cash_flow_statement'")
\ No newline at end of file
diff --git a/erpnext/patches/august_2012/repost_billed_amt.py b/erpnext/patches/august_2012/repost_billed_amt.py
new file mode 100644
index 0000000..4ff7afb
--- /dev/null
+++ b/erpnext/patches/august_2012/repost_billed_amt.py
@@ -0,0 +1,10 @@
+from __future__ import unicode_literals
+def execute():
+	import webnotes
+	from webnotes.model.code import get_obj
+	from selling.doctype.sales_common.sales_common import StatusUpdater
+	
+	invoices = webnotes.conn.sql("select name from `tabSales Invoice` where docstatus = 1")
+	for inv in invoices:
+		inv_obj = get_obj('Sales Invoice', inv[0], with_children=1)
+		StatusUpdater(inv_obj, 1).update_all_qty()
\ No newline at end of file
diff --git a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
index b552021..40e081c 100644
--- a/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
+++ b/erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
@@ -11,8 +11,10 @@
 		pass
 	webnotes.conn.begin()
 
+	webnotes.conn.auto_commit_on_many_writes = 1
 	repost_reserved_qty()
 	cleanup_wrong_sle()
+	webnotes.conn.auto_commit_on_many_writes = 0
 
 def repost_reserved_qty():
 	from webnotes.utils import flt
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index 71fc6b3..be7cca2 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -552,5 +552,29 @@
 	{
 		'patch_module': 'patches.august_2012',
 		'patch_file': 'change_profile_permission',
-	}
-]
\ No newline at end of file
+	},
+	{
+		'patch_module': 'patches.august_2012',
+		'patch_file': 'changed_blog_date_format',
+	},
+	{
+		'patch_module': 'patches.august_2012',
+		'patch_file': 'repost_billed_amt',
+	},
+	{
+		'patch_module': 'patches.august_2012',
+		'patch_file': 'remove_cash_flow_statement',
+	},
+	{
+		'patch_module': 'patches.august_2012',
+		'patch_file': 'reload_stock_ledger',
+	},
+	{
+		'patch_module': 'patches.september_2012',
+		'patch_file': 'stock_report_permissions_for_accounts',
+	},
+	{
+		'patch_module': 'patches.september_2012',
+		'patch_file': 'communication_delete_permission',
+	},
+]
diff --git a/erpnext/patches/september_2012/__init__.py b/erpnext/patches/september_2012/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/patches/september_2012/__init__.py
diff --git a/erpnext/patches/september_2012/communication_delete_permission.py b/erpnext/patches/september_2012/communication_delete_permission.py
new file mode 100644
index 0000000..68aea40
--- /dev/null
+++ b/erpnext/patches/september_2012/communication_delete_permission.py
@@ -0,0 +1,21 @@
+def execute():
+	import webnotes
+	from webnotes.model.doc import addchild
+	from webnotes.model.code import get_obj
+	
+	existing = webnotes.conn.sql("""select role, name from `tabDocPerm`
+		where permlevel=0 and parent='Communication'""")
+
+	for role in ("Support Manager", "System Manager"):
+		if role not in map(lambda x: x[0], existing):
+			doctype_obj = get_obj("DocType", "Communication", with_children=1)
+			ch = addchild(doctype_obj.doc, "permissions", "DocPerm")
+			ch.permlevel = 0
+			ch.role = role
+			ch.read = 1
+			ch.write = 1
+			ch.create = 1
+			ch.cancel = 1
+			ch.save()
+		else:
+			webnotes.conn.set_value("DocPerm", dict(existing).get(role), "cancel", 1)
diff --git a/erpnext/patches/september_2012/stock_report_permissions_for_accounts.py b/erpnext/patches/september_2012/stock_report_permissions_for_accounts.py
new file mode 100644
index 0000000..26af06b
--- /dev/null
+++ b/erpnext/patches/september_2012/stock_report_permissions_for_accounts.py
@@ -0,0 +1,17 @@
+def execute():
+	import webnotes
+	from webnotes.model.doc import addchild
+	from webnotes.model.code import get_obj
+	
+	for parent in ("Stock Ledger Entry", "Bin"):
+		existing = webnotes.conn.sql("""select role from `tabDocPerm`
+			where permlevel=0 and parent=%s""", (parent,))
+	
+		if "Accounts Manager" not in map(lambda x: x[0], existing):
+			doctype_obj = get_obj("DocType", parent, with_children=1)
+			ch = addchild(doctype_obj.doc, "permissions", "DocPerm")
+			ch.permlevel = 0
+			ch.role = "Accounts Manager"
+			ch.read = 1
+			ch.save()
+		
\ No newline at end of file
diff --git a/erpnext/production/doctype/bom/bom.py b/erpnext/production/doctype/bom/bom.py
index 83a3165..5f6954f 100644
--- a/erpnext/production/doctype/bom/bom.py
+++ b/erpnext/production/doctype/bom/bom.py
@@ -198,6 +198,7 @@
 			hour_rate = sql("select hour_rate from `tabWorkstation` where name = %s", cstr(d.workstation))
 			d.hour_rate = hour_rate and flt(hour_rate[0][0]) or 0
 			d.operating_cost = flt(d.hour_rate) * flt(d.time_in_mins) / 60
+			d.save()
 			total_op_cost += d.operating_cost
 		self.doc.operating_cost = total_op_cost
 
@@ -214,6 +215,7 @@
 				d.fields[k] = ret[k]
 
 			d.amount = flt(d.rate) * flt(d.qty)
+			d.save()
 			total_rm_cost += d.amount
 		self.doc.raw_material_cost = total_rm_cost
 
diff --git a/erpnext/selling/doctype/lead/lead.py b/erpnext/selling/doctype/lead/lead.py
index ddccbc1..eda3cd6 100644
--- a/erpnext/selling/doctype/lead/lead.py
+++ b/erpnext/selling/doctype/lead/lead.py
@@ -144,4 +144,4 @@
 		
 		if receiver_list:
 			msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
-			self.add_in_follow_up(self.doc.sms_message,'SMS')
+			# self.add_in_follow_up(self.doc.sms_message,'SMS')
diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js
index 4487c89..52cb5fd 100644
--- a/erpnext/selling/doctype/opportunity/opportunity.js
+++ b/erpnext/selling/doctype/opportunity/opportunity.js
@@ -18,7 +18,7 @@
 wn.require('erpnext/support/doctype/communication/communication.js');
 
 cur_frm.cscript.refresh = function(doc, cdt, cdn){
-    erpnext.hide_naming_series();
+	erpnext.hide_naming_series();
 	
 	cur_frm.clear_custom_buttons();
 	if(doc.docstatus == 1) {
@@ -62,7 +62,6 @@
 // fetch
 // ===============================================================
 cur_frm.cscript.set_fetch = function() {
-
 	// item
 	cur_frm.add_fetch('item_code', 'item_name', 'item_name');
 	cur_frm.add_fetch('item_code', 'stock_uom', 'uom');
@@ -71,7 +70,6 @@
 	cur_frm.add_fetch('item_code', 'brand', 'brand');
 
 	// customer
-
 }
 
 // hide - unhide fields on basis of enquiry_from lead or customer
diff --git a/erpnext/selling/doctype/opportunity/opportunity_list.js b/erpnext/selling/doctype/opportunity/opportunity_list.js
index a661d81..949422e 100644
--- a/erpnext/selling/doctype/opportunity/opportunity_list.js
+++ b/erpnext/selling/doctype/opportunity/opportunity_list.js
@@ -6,6 +6,7 @@
 			'tabOpportunity.lead_name',
 			'tabOpportunity.customer_name',
 			'tabOpportunity.status',
+			'tabOpportunity.transaction_date',
 		]);
 		this.stats = this.stats.concat(['status', 'source', 'enquiry_from', 'company']);
 	},
@@ -33,6 +34,8 @@
 		{width: '15%', content:'name'},
 		{width: '18%', content:'status_html'},
 		{width: '52%', content:'enquiry_name+tags', css: {color:'#222'}},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'transaction_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Opportunity Date", type: "date"}
 	]
 })
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 5e7828b..7bb94aa 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -88,14 +88,10 @@
 						'cost_center': doc.fields.get('cost_center'),
 						'warehouse': doc.fields.get('warehouse')
 					}
-					fields_dict = obj.get_item_details(arg, self)
-					if fields_dict:
-						doc.fields.update(fields_dict)
-					#ret = obj.get_item_defaults(arg)
-					#for r in ret:
-					#	if not doc.fields.get(r):
-					#		doc.fields[r] = ret[r]					
-
+					res = obj.get_item_details(arg, self) or {}
+					for r in res:
+						if not doc.fields.get(r):
+							doc.fields[r] = res[r]
 
 	# Re-calculates Basic Rate & amount based on Price List Selected
 	# --------------------------------------------------------------
@@ -160,7 +156,7 @@
 	#do not allow sales item in maintenance quotation and service item in sales quotation
 	#-----------------------------------------------------------------------------------------------
 	def validate_order_type(self):
-		if self.doc.order_type == 'Maintenance':
+		if self.doc.order_type in ['Maintenance', 'Service']:
 			for d in getlist(self.doclist, 'quotation_details'):
 				is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
 				is_service_item = is_service_item and is_service_item[0][0] or 'No'
diff --git a/erpnext/selling/doctype/quotation/quotation_list.js b/erpnext/selling/doctype/quotation/quotation_list.js
index d1fad5a..8530629 100644
--- a/erpnext/selling/doctype/quotation/quotation_list.js
+++ b/erpnext/selling/doctype/quotation/quotation_list.js
@@ -7,7 +7,8 @@
 			"`tabQuotation`.lead_name",
 			"`tabQuotation`.customer_name",
 			"`tabQuotation`.currency", 
-			"ifnull(`tabQuotation`.grand_total_export,0) as grand_total_export"
+			"ifnull(`tabQuotation`.grand_total_export,0) as grand_total_export",
+			"`tabQuotation`.transaction_date",
 		]);
 		this.stats = this.stats.concat(['status', 'quotation_to', 'company']);
 	},
@@ -34,7 +35,9 @@
 			},
 			css: {'text-align':'right'}
 		},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'transaction_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Quotation Date", type: "date"}
 	]
 
 });
diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js
index c229ece..fe5582d 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.js
+++ b/erpnext/selling/doctype/sales_common/sales_common.js
@@ -247,7 +247,7 @@
 
 // ******************** ITEM CODE ******************************** 
 cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
-	if (doc.order_type == 'Maintenance')
+	if (inList(['Maintenance', 'Service'], doc.order_type))
 		return 'SELECT tabItem.name,tabItem.item_name,tabItem.description \
 			FROM tabItem WHERE tabItem.is_service_item="Yes" \
 			AND tabItem.docstatus != 2 \
diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py
index bf16253..5411a5a 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.py
+++ b/erpnext/selling/doctype/sales_common/sales_common.py
@@ -687,14 +687,14 @@
 			self.validate_qty({
 				'source_dt'		:'Sales Invoice Item',
 				'compare_field'	:'billed_amt',
-				'compare_ref_field'	:'amount',
+				'compare_ref_field'	:'export_amount',
 				'target_dt'		:'Sales Order Item',
 				'join_field'	:'so_detail'
 			})
 			self.validate_qty({
 				'source_dt'		:'Sales Invoice Item',
 				'compare_field'	:'billed_amt',
-				'compare_ref_field'	:'amount',
+				'compare_ref_field'	:'export_amount',
 				'target_dt'		:'Delivery Note Item',
 				'join_field'	:'dn_detail'
 			}, no_tolerance =1)
@@ -734,7 +734,7 @@
 		tolerance = self.get_tolerance_for(item['item_code'])
 		overflow_percent = ((item[args['compare_field']] - item[args['compare_ref_field']]) / item[args['compare_ref_field']] * 100)
 	
-		if overflow_percent - tolerance > 0.0001:
+		if overflow_percent - tolerance > 0.01:
 			item['max_allowed'] = flt(item[args['compare_ref_field']] * (100+tolerance)/100)
 			item['reduce_by'] = item[args['compare_field']] - item['max_allowed']
 		
@@ -764,18 +764,19 @@
 				if item:
 					item = item[0]
 					item['idx'] = d.idx
-					item['compare_ref_field'] = args['compare_ref_field']
+					item['compare_ref_field'] = args['compare_ref_field'].replace('_', ' ')
 
 					if not item[args['compare_ref_field']]:
 						msgprint("As %(compare_ref_field)s for item: %(item_code)s in %(parenttype)s: %(parent)s is zero, system will not check over-delivery or over-billed" % item)
 					elif no_tolerance:
 						item['reduce_by'] = item[args['compare_field']] - item[args['compare_ref_field']]
-						msgprint("""
-							Row #%(idx)s: Max %(compare_ref_field)s allowed for <b>Item %(item_code)s</b> against 
-							<b>%(parenttype)s %(parent)s</b> is <b>""" % item 
-							+ cstr(item[args['compare_ref_field']]) + """</b>. 
+						if item['reduce_by'] > .01:
+							msgprint("""
+								Row #%(idx)s: Max %(compare_ref_field)s allowed for <b>Item %(item_code)s</b> against 
+								<b>%(parenttype)s %(parent)s</b> is <b>""" % item 
+								+ cstr(item[args['compare_ref_field']]) + """</b>. 
 							
-							You must reduce the %(compare_ref_field)s by %(reduce_by)s""" % item, raise_exception=1)
+								You must reduce the %(compare_ref_field)s by %(reduce_by)s""" % item, raise_exception=1)
 					
 					else:
 						self.check_overflow_with_tolerance(item, args)
@@ -806,9 +807,9 @@
 				'target_dt'				:'Sales Order Item',
 				'target_parent_dt'		:'Sales Order',
 				'target_parent_field'	:'per_billed',
-				'target_ref_field'		:'amount',
+				'target_ref_field'		:'export_amount',
 				'source_dt'				:'Sales Invoice Item',
-				'source_field'			:'amount',
+				'source_field'			:'export_amount',
 				'join_field'			:'so_detail',
 				'percent_join_field'	:'sales_order',
 				'status_field'			:'billing_status',
@@ -820,9 +821,9 @@
 				'target_dt'				:'Delivery Note Item',
 				'target_parent_dt'		:'Delivery Note',
 				'target_parent_field'	:'per_billed',
-				'target_ref_field'		:'amount',
+				'target_ref_field'		:'export_amount',
 				'source_dt'				:'Sales Invoice Item',
-				'source_field'			:'amount',
+				'source_field'			:'export_amount',
 				'join_field'			:'dn_detail',
 				'percent_join_field'	:'delivery_note',
 				'status_field'			:'billing_status',
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 4faa6a3..f4089be 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -54,8 +54,6 @@
 }
 
 
-// Refresh
-//==================
 cur_frm.cscript.refresh = function(doc, cdt, cdn) {
 	cur_frm.clear_custom_buttons();
 	erpnext.hide_naming_series();
@@ -69,17 +67,17 @@
 		if(doc.status != 'Stopped') {
 			cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms);
 			// delivery note
-			if(doc.per_delivered < 100 && doc.order_type!='Maintenance')
+			if(doc.per_delivered < 100 && doc.order_type=='Sales')
 				cur_frm.add_custom_button('Make Delivery', cur_frm.cscript['Make Delivery Note']);
 			
 			// maintenance
-			if(doc.per_delivered < 100 && doc.order_type=='Maintenance') {
+			if(doc.per_delivered < 100 && (doc.order_type !='Sales')) {
 				cur_frm.add_custom_button('Make Maint. Visit', cur_frm.cscript.make_maintenance_visit);
 				cur_frm.add_custom_button('Make Maint. Schedule', cur_frm.cscript['Make Maintenance Schedule']);
 			}
 
 			// indent
-			if(doc.order_type != 'Maintenance')
+			if(!doc.order_type || (doc.order_type == 'Sales'))
 				cur_frm.add_custom_button('Make ' + get_doctype_label('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
 			
 			// sales invoice
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 465d53e..32c2e26 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -252,43 +252,16 @@
 			msgprint("There are no items of the quotation selected.")
 			raise Exception
 
-	# validate sales/ service item against order type
-	#----------------------------------------------------
-	def validate_sales_mntc_item(self):
-		if self.doc.order_type == 'Maintenance':
-			item_field = 'is_service_item'
-			order_type = 'Maintenance Order'
-			item_type = 'service item'
-		else :
-			item_field = 'is_sales_item'
-			order_type = 'Sales Order'
-			item_type = 'sales item'
-		
-		for d in getlist(self.doclist, 'sales_order_details'):
-			res = sql("select %s from `tabItem` where name='%s'"% (item_field,d.item_code))
-			res = res and res[0][0] or 'No'
-			
-			if res == 'No':
-				msgprint("You can not select non "+item_type+" "+d.item_code+" in "+order_type)
-				raise Exception
-	
 	# validate sales/ maintenance quotation against order type
 	#------------------------------------------------------------------
 	def validate_sales_mntc_quotation(self):
 		for d in getlist(self.doclist, 'sales_order_details'):
 			if d.prevdoc_docname:
-				res = sql("select order_type from `tabQuotation` where name=%s", (d.prevdoc_docname))
-				res = res and res[0][0] or ''
-				
-				if self.doc.order_type== 'Maintenance' and res != 'Maintenance':
-					msgprint("You can not select non Maintenance Quotation against Maintenance Order")
-					raise Exception
-				elif self.doc.order_type != 'Maintenance' and res == 'Maintenance':
-					msgprint("You can not select non Sales Quotation against Sales Order")
-					raise Exception
+				res = sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.doc.order_type))
+				if not res:
+					msgprint("""Order Type (%s) should be same in Quotation: %s \
+						and current Sales Order""" % (self.doc.order_type, d.prevdoc_docname))
 
-	#do not allow sales item/quotation in maintenance order and service item/quotation in sales order
-	#-----------------------------------------------------------------------------------------------
 	def validate_order_type(self):
 		#validate delivery date
 		if self.doc.order_type == 'Sales' and not self.doc.delivery_date:
@@ -296,7 +269,6 @@
 			raise Exception
 		
 		self.validate_sales_mntc_quotation()
-		self.validate_sales_mntc_item()
 
 	#check for does customer belong to same project as entered..
 	#-------------------------------------------------------------------------------------------------
diff --git a/erpnext/selling/doctype/sales_order/sales_order_list.js b/erpnext/selling/doctype/sales_order/sales_order_list.js
index c15944b..a386f35 100644
--- a/erpnext/selling/doctype/sales_order/sales_order_list.js
+++ b/erpnext/selling/doctype/sales_order/sales_order_list.js
@@ -9,7 +9,8 @@
 			"ifnull(`tabSales Order`.per_delivered,0) as per_delivered", 
 			"ifnull(`tabSales Order`.per_billed,0) as per_billed",
 			"`tabSales Order`.currency", 
-			"ifnull(`tabSales Order`.grand_total_export,0) as grand_total_export"
+			"ifnull(`tabSales Order`.grand_total_export,0) as grand_total_export",
+			"`tabSales Order`.transaction_date",
 		]);
 		this.stats = this.stats.concat(['status', 'order_type', 'company']);
 	},
@@ -41,7 +42,9 @@
 			},
 		},
 		{width: '8%', content: 'per_billed', type:'bar-graph', label:'Billed'},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'transaction_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Sales Order Date", type: "date"}
 	]
 
 });
diff --git a/erpnext/selling/page/sales_browser/sales_browser.js b/erpnext/selling/page/sales_browser/sales_browser.js
index c98e0e4..8dde63d 100644
--- a/erpnext/selling/page/sales_browser/sales_browser.js
+++ b/erpnext/selling/page/sales_browser/sales_browser.js
@@ -84,12 +84,21 @@
 		link.toolbar = $('<span class="tree-node-toolbar"></span>').insertAfter(link);
 		
 		// edit
-		$('<a href="#!Form/'+encodeURIComponent(this.ctype)+'/'
-			+encodeURIComponent(data.value)+'">Edit</a>').appendTo(link.toolbar);
+		var node_links = [];
+		
+		if (wn.boot.profile.can_read.indexOf(this.ctype) !== -1) {
+			node_links.push('<a href="#!Form/'+encodeURIComponent(this.ctype)+'/'
+				+encodeURIComponent(data.value)+'">Edit</a>');
+		}
 
 		if(data.expandable) {
-			link.toolbar.append(' | <a onclick="erpnext.sales_chart.new_node();">Add Child</a>');
+			if (wn.boot.profile.can_create.indexOf(this.ctype) !== -1 ||
+					wn.boot.profile.in_create.indexOf(this.ctype) !== -1) {
+				node_links.push('<a onclick="erpnext.sales_chart.new_node();">Add Child</a>');
+			}
 		}
+		
+		link.toolbar.append(node_links.join(" | "));
 	},
 	new_node: function() {
 		var me = this;
diff --git a/erpnext/setup/doctype/notification_control/notification_control.js b/erpnext/setup/doctype/notification_control/notification_control.js
index 0ac33a1..b52520a 100644
--- a/erpnext/setup/doctype/notification_control/notification_control.js
+++ b/erpnext/setup/doctype/notification_control/notification_control.js
@@ -26,6 +26,7 @@
 }
 
 cur_frm.cscript.notify = function(doc, args) {
+	var doc = locals[doc.doctype][doc.name];
 	$c_obj(make_doclist(doc.doctype, doc.name), 'get_formatted_message', {
 		type: args['type'],
 		doctype: args['doctype'],
diff --git a/erpnext/setup/doctype/price_list/price_list.py b/erpnext/setup/doctype/price_list/price_list.py
index 02f6b89..fed2768 100644
--- a/erpnext/setup/doctype/price_list/price_list.py
+++ b/erpnext/setup/doctype/price_list/price_list.py
@@ -55,6 +55,7 @@
 		from core.page.data_import_tool.data_import_tool import read_csv_content
 		
 		data = read_csv_content(self.get_csv_data())
+		webnotes.conn.auto_commit_on_many_writes = 1
 				
 		updated = 0
 		
@@ -84,6 +85,7 @@
 					msgprint("[Ignored] Did not find Item '%s'" % line[1])
 		
 		msgprint("<b>%s</b> items updated" % updated)
+		webnotes.conn.auto_commit_on_many_writes = 0
 
 	# Update CSV data
 	def get_csv_data(self):
diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py
index f48cc50..348ec13 100644
--- a/erpnext/stock/doctype/bin/bin.py
+++ b/erpnext/stock/doctype/bin/bin.py
@@ -334,7 +334,7 @@
 
 		if get_value('Global Defaults', None, 'auto_indent'):
 			#check if re-order is required
-			ret = sql("select re_order_level, item_name, description, brand, item_group, lead_time_days, min_order_qty, email_notify, re_order_qty from tabItem where item_code = %s", (self.doc.item_code), as_dict=1)
+			ret = sql("select re_order_level, item_name, description, brand, item_group, lead_time_days, min_order_qty, email_notify, re_order_qty from tabItem where name = %s", (self.doc.item_code), as_dict=1)
 			
 			current_qty = sql("""
 				select sum(t1.actual_qty) + sum(t1.indented_qty) + sum(t1.ordered_qty) -sum(t1.reserved_qty)
@@ -345,7 +345,8 @@
 				and t1.docstatus != 2
 			""", self.doc.item_code)
 
-			if ((flt(ret[0]['re_order_level']) > flt(current_qty[0][0])) and ret[0]['re_order_level']):
+			if ret[0]["re_order_level"] and current_qty and \
+					(flt(ret[0]['re_order_level']) > flt(current_qty[0][0])):
 				self.create_auto_indent(ret[0], doc_type, doc_name, current_qty[0][0])
 
 	
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note_list.js b/erpnext/stock/doctype/delivery_note/delivery_note_list.js
index e65d75a..9c94fdb 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note_list.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note_list.js
@@ -4,7 +4,8 @@
 		this._super(d);
 		this.fields = this.fields.concat([
 			"`tabDelivery Note`.customer_name",
-			"`tabDelivery Note`.sales_order_no"
+			"`tabDelivery Note`.sales_order_no",
+			"`tabDelivery Note`.posting_date",
 		]);
 	},
 	columns: [
@@ -14,6 +15,8 @@
 		{width: '15%', content:'name'},
 		{width: '47%', content:'customer_name+tags', css: {color:'#222'}},
 		{width: '15%', content:'sales_order_no', type:'link', doctype:'Sales Order'},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'posting_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Delivery Note Date", type: "date"}
 	]
 });
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index caf4d5a..2be671e 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -469,15 +469,11 @@
 				d.current_stock = bin and flt(bin[0]['actual_qty']) or 0
 
 
-
-
-# OTHER CHARGES TRIGGER FUNCTIONS
-# ====================================================================================
-
-	# *********** Get Tax rate if account type is TAX ********************
 	def get_rate(self,arg):
 		return get_obj('Purchase Common').get_rate(arg,self)
-
-	# **** Pull details from other charges master (Get Other Charges) ****
+	
+	def load_default_taxes(self):
+		self.doclist = get_obj('Purchase Common').load_default_taxes(self)
+	
 	def get_purchase_tax_details(self):
 		self.doclist = get_obj('Purchase Common').get_purchase_tax_details(self)
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js
index ae42eac..e04ef7e 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt_list.js
@@ -5,6 +5,7 @@
 		this.fields = this.fields.concat([
 			"`tabPurchase Receipt`.supplier_name",
 			"group_concat(`tabPurchase Receipt Item`.prevdoc_docname) as purchase_order_no",
+			"`tabPurchase Receipt`.posting_date",
 		]);
 		this.group_by = "`tabPurchase Receipt`.name";
 	},
@@ -14,7 +15,9 @@
 			data.purchase_order_no = data.purchase_order_no.split(",");
 			var po_list = [];
 			$.each(data.purchase_order_no, function(i, v){
-				if(po_list.indexOf(v)==-1) po_list.push(v);
+				if(po_list.indexOf(v)==-1) po_list.push(
+					repl("<a href=\"#Form/Purchase Order/%(name)s\">%(name)s</a>",
+					{name: v}));
 			});
 			data.purchase_order_no = po_list.join(", ");
 		}
@@ -26,6 +29,8 @@
 		{width: '15%', content:'name'},
 		{width: '32%', content:'supplier_name+tags', css: {color:'#222'}},
 		{width: '30%', content:'purchase_order_no'},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'posting_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Purhcase Receipt Date", type: "date"}
 	]
 });
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry_list.js b/erpnext/stock/doctype/stock_entry/stock_entry_list.js
index 90f43a7..60526cb 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry_list.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry_list.js
@@ -6,6 +6,7 @@
 			"`tabStock Entry`.purpose",
 			"`tabStock Entry`.from_warehouse",
 			"`tabStock Entry`.to_warehouse",
+			"`tabStock Entry`.posting_date",
 		]);
 	},
 	columns: [
@@ -16,6 +17,8 @@
 		{width: '15%', content:'purpose+tags', css: {color:'#222'}},
 		{width: '18%', content:'from_warehouse', template: 'From %(from_warehouse)s'},
 		{width: '18%', content:'to_warehouse', template: 'To %(to_warehouse)s'},
-		{width: '12%', content:'modified', css: {'text-align': 'right', 'color':'#777'}}
+		{width: '12%', content:'posting_date',
+			css: {'text-align': 'right', 'color':'#777'},
+			title: "Stock Entry Date", type: "date"}
 	]
 });
diff --git a/erpnext/stock/report/stock_ledger/stock_ledger.txt b/erpnext/stock/report/stock_ledger/stock_ledger.txt
new file mode 100644
index 0000000..d0c5184
--- /dev/null
+++ b/erpnext/stock/report/stock_ledger/stock_ledger.txt
@@ -0,0 +1,26 @@
+# Report, Stock Ledger
+[
+
+	# These values are common in all dictionaries
+	{
+		'creation': '2012-09-06 18:47:05',
+		'docstatus': 0,
+		'modified': '2012-09-06 18:48:22',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
+	},
+
+	# These values are common for all Report
+	{
+		'doctype': 'Report',
+		'json': u'{"filters":[["Stock Ledger Entry","is_cancelled","=","No"]],"columns":[["item_code","Stock Ledger Entry"],["warehouse","Stock Ledger Entry"],["posting_date","Stock Ledger Entry"],["posting_time","Stock Ledger Entry"],["actual_qty","Stock Ledger Entry"],["bin_aqat","Stock Ledger Entry"],["voucher_type","Stock Ledger Entry"],["voucher_no","Stock Ledger Entry"]],"sort_by":"Stock Ledger Entry.posting_date","sort_order":"desc","sort_by_next":"Stock Ledger Entry.posting_time","sort_order_next":"desc"}',
+		'name': '__common__',
+		'ref_doctype': u'Stock Ledger Entry'
+	},
+
+	# Report, Stock Ledger
+	{
+		'doctype': 'Report',
+		'name': u'Stock Ledger'
+	}
+]
\ No newline at end of file
diff --git a/erpnext/support/doctype/communication/communication.js b/erpnext/support/doctype/communication/communication.js
index d6af592..af92710 100644
--- a/erpnext/support/doctype/communication/communication.js
+++ b/erpnext/support/doctype/communication/communication.js
@@ -64,7 +64,7 @@
 		ListView, function(doctype) {
 			var new_doc = LocalDB.create(doctype);
 			new_doc = locals[doctype][new_doc];
-			new_doc[doc.doctype.toLowerCase()] = doc.name;
+			new_doc[doc.doctype.toLowerCase().replace(" ", "_")] = doc.name;
 			loaddoc(new_doc.doctype, new_doc.name);
 		});
 }
@@ -79,7 +79,7 @@
 		var RecordListView = wn.views.RecordListView.extend({
 			default_docstatus: ['0', '1', '2'],
 			default_filters: [
-				[doctype, doc.doctype.toLowerCase(), '=', doc.name],
+				[doctype, doc.doctype.toLowerCase().replace(" ", "_"), '=', doc.name],
 			],
 		});
 		
@@ -90,6 +90,9 @@
 		}
 		
 		var record_list_view = new RecordListView(doctype, wrapper, ListView);
+		if (!cur_frm[doctype.toLowerCase().replace(" ", "_") + "_list"]) {
+			cur_frm[doctype.toLowerCase().replace(" ", "_") + "_list"] = record_list_view;
+		}
 	});
 }
 
@@ -110,4 +113,9 @@
 			},
 		});
 	}
+}
+
+cur_frm.cscript.hide_dialog = function() {
+	if(cur_frm.communication_list)
+		cur_frm.communication_list.run();
 }
\ No newline at end of file
diff --git a/erpnext/support/doctype/communication/communication.txt b/erpnext/support/doctype/communication/communication.txt
index d504476..887e4a8 100644
--- a/erpnext/support/doctype/communication/communication.txt
+++ b/erpnext/support/doctype/communication/communication.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2012-06-26 11:58:13',
 		'docstatus': 0,
-		'modified': '2012-08-03 16:10:35',
+		'modified': '2012-08-31 16:44:13',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -16,6 +16,7 @@
 		'description': u'Keep a track of all communications',
 		'doctype': 'DocType',
 		'document_type': u'Master',
+		'in_dialog': 1,
 		'module': u'Support',
 		'name': '__common__',
 		'version': 1
@@ -150,6 +151,15 @@
 	# DocField
 	{
 		'doctype': u'DocField',
+		'fieldname': u'next_communication_date',
+		'fieldtype': u'Date',
+		'label': u'Next Communcation On',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
 		'fieldname': u'column_break2',
 		'fieldtype': u'Column Break',
 		'permlevel': 0
@@ -178,7 +188,7 @@
 	{
 		'doctype': u'DocField',
 		'fieldname': u'content',
-		'fieldtype': u'Text Editor',
+		'fieldtype': u'Text',
 		'label': u'Content',
 		'permlevel': 0,
 		'reqd': 0
diff --git a/erpnext/support/doctype/communication/communication_list.js b/erpnext/support/doctype/communication/communication_list.js
index ec87692..8c8d98c 100644
--- a/erpnext/support/doctype/communication/communication_list.js
+++ b/erpnext/support/doctype/communication/communication_list.js
@@ -36,4 +36,8 @@
 		{width: '12%', content:'when',
 			css: {'text-align': 'right', 'color':'#777'}}		
 	],
+	
+	make_new_doc: function(new_doctype) {
+		new_doc(new_doctype, 1);
+	}
 });
\ No newline at end of file
diff --git a/erpnext/support/doctype/newsletter/__init__.py b/erpnext/support/doctype/newsletter/__init__.py
new file mode 100644
index 0000000..baffc48
--- /dev/null
+++ b/erpnext/support/doctype/newsletter/__init__.py
@@ -0,0 +1 @@
+from __future__ import unicode_literals
diff --git a/erpnext/support/doctype/newsletter/newsletter.js b/erpnext/support/doctype/newsletter/newsletter.js
new file mode 100644
index 0000000..1f75edc
--- /dev/null
+++ b/erpnext/support/doctype/newsletter/newsletter.js
@@ -0,0 +1,26 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+// 
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+cur_frm.cscript.refresh = function(doc) {
+	erpnext.hide_naming_series();
+	if(!doc.__islocal && !cint(doc.email_sent) && !doc.__unsaved) {
+		cur_frm.add_custom_button('Send', function() {
+			$c_obj(make_doclist(doc.doctype, doc.name), 'send_emails', '', function(r) {
+				cur_frm.refresh();
+			});
+		})
+	}
+}
\ No newline at end of file
diff --git a/erpnext/support/doctype/newsletter/newsletter.py b/erpnext/support/doctype/newsletter/newsletter.py
new file mode 100644
index 0000000..fdbb323
--- /dev/null
+++ b/erpnext/support/doctype/newsletter/newsletter.py
@@ -0,0 +1,112 @@
+# ERPNext - web based ERP (http://erpnext.com)
+# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import unicode_literals
+
+import webnotes
+import webnotes.utils
+
+class DocType():
+	def __init__(self, d, dl):
+		self.doc, self.doclist = d, dl
+		self.dt_map = {
+			"Contact": {
+				"email_field": "email_id",
+				"first_name_field": "first_name",
+			},
+			"Lead": {
+				"email_field": "email_id",
+				"first_name_field": "lead_name"
+			}
+		}
+		self.query_map = {
+			"contacts": """select distinct email_id from `tabContact`
+				where ifnull(email_id, '') != '' """,
+			"customer_contacts": """select distinct email_id from `tabContact`
+				where ifnull(customer, '') != '' and ifnull(email_id, '') != '' """,
+			"leads": """select distinct email_id from `tabLead`
+				where ifnull(email_id, '') != '' """,
+			"active_leads": """select distinct email_id from `tabLead`
+				where status = "Open" and ifnull(email_id, '') != '' """,
+			"blog_subscribers": """select distinct email_id from `tabLead`
+				where ifnull(blog_subscriber,0) = 1 and ifnull(email_id, '') != '' """
+		}
+		
+	def autoname(self):
+		from webnotes.model.doc import make_autoname
+		self.doc.name = make_autoname(self.doc.naming_series+ '.#####')
+		
+	def send_emails(self):
+		"""send emails to leads and customers"""		
+		# TODO: create unsubscribed check in customer
+		if self.doc.email_sent:
+			webnotes.msgprint("""Newsletter has already been sent""", raise_exception=1)
+		
+		self.all_recipients = []
+		self.send_count = {}
+		
+		if self.doc.contacts:
+			self.send("contacts", "Contact")
+		elif self.doc.customer_contacts:
+			self.send("customer_contacts", "Contact")
+		
+		if self.doc.leads:
+			self.send("leads", "Lead")
+		else:
+			if self.doc.active_leads:
+				self.send("active_leads", "Lead")
+				
+			if self.doc.blog_subscribers:
+				self.send("blog_subscribers", "Lead")
+		
+		webnotes.conn.set(self.doc, "email_sent", 1)
+		webnotes.msgprint("""Scheduled to send to %s""" % \
+			", ".join(["%d %s(s)" % (self.send_count[s], s) for s in self.send_count]))
+			
+	def test_send(self, doctype="Lead"):
+		args = self.dt_map[doctype]
+		sender = webnotes.utils.get_email_id(self.doc.owner)
+		recipients = self.doc.test_email_id.split(",")
+		from webnotes.utils.email_lib.bulk import send
+		send(recipients = recipients, sender = sender, 
+			subject = self.doc.subject, message = self.get_message(),
+			doctype = doctype, email_field = args["email_field"],
+			first_name_field = args["first_name_field"], last_name_field = "")
+		webnotes.msgprint("""Scheduled to send to %s""" % self.doc.test_email_id)
+		
+	def get_recipients(self, key):
+		recipients = webnotes.conn.sql(self.query_map[key])
+		recipients = [r[0] for r in recipients if r not in self.all_recipients]
+		self.all_recipients += recipients
+		return recipients
+		
+	def get_message(self):
+		if not hasattr(self, "message"):
+			import markdown2
+			self.message = markdown2.markdown(self.doc.message)
+		return self.message
+		
+	def send(self, query_key, doctype):
+		recipients = self.get_recipients(query_key)
+		sender = webnotes.utils.get_email_id(self.doc.owner)
+		args = self.dt_map[doctype]
+		self.send_count[doctype] = self.send_count.setdefault(doctype, 0) + len(recipients)
+		
+		from webnotes.utils.email_lib.bulk import send
+		send(recipients = recipients, sender = sender, 
+			subject = self.doc.subject, message = self.get_message(),
+			doctype = doctype, email_field = args["email_field"],
+			first_name_field = args["first_name_field"], last_name_field = "")
\ No newline at end of file
diff --git a/erpnext/support/doctype/newsletter/newsletter.txt b/erpnext/support/doctype/newsletter/newsletter.txt
new file mode 100644
index 0000000..ef3033d
--- /dev/null
+++ b/erpnext/support/doctype/newsletter/newsletter.txt
@@ -0,0 +1,233 @@
+# DocType, Newsletter
+[
+
+	# These values are common in all dictionaries
+	{
+		u'creation': '2012-08-23 18:49:12',
+		u'docstatus': 0,
+		u'modified': '2012-08-24 14:45:00',
+		u'modified_by': u'Administrator',
+		u'owner': u'Administrator'
+	},
+
+	# These values are common for all DocType
+	{
+		'description': u'Create and Send Newsletters',
+		u'doctype': u'DocType',
+		'document_type': u'Other',
+		'module': u'Support',
+		u'name': u'__common__',
+		'version': 1
+	},
+
+	# These values are common for all DocField
+	{
+		u'doctype': u'DocField',
+		u'name': u'__common__',
+		'parent': u'Newsletter',
+		'parentfield': u'fields',
+		'parenttype': u'DocType'
+	},
+
+	# These values are common for all DocPerm
+	{
+		u'doctype': u'DocPerm',
+		u'name': u'__common__',
+		'parent': u'Newsletter',
+		'parentfield': u'permissions',
+		'parenttype': u'DocType',
+		'read': 1
+	},
+
+	# DocType, Newsletter
+	{
+		u'doctype': u'DocType',
+		u'name': u'Newsletter'
+	},
+
+	# DocField
+	{
+		u'doctype': u'DocField',
+		'fieldname': u'basic_info',
+		'fieldtype': u'Section Break',
+		'label': u'Basic Info',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'default': u'NL-',
+		u'doctype': u'DocField',
+		'fieldname': u'naming_series',
+		'fieldtype': u'Select',
+		'label': u'Naming Series',
+		'options': u'NL-',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'description': u'A Lead with this email id should exist',
+		u'doctype': u'DocField',
+		'fieldname': u'test_email_id',
+		'fieldtype': u'Data',
+		'label': u'Test Email Id',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		u'doctype': u'DocField',
+		'fieldname': u'test_send',
+		'fieldtype': u'Button',
+		'label': u'Test',
+		'options': u'test_send',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		u'doctype': u'DocField',
+		'fieldname': u'column_break1',
+		'fieldtype': u'Column Break',
+		'label': u'Send To',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		u'doctype': u'DocField',
+		'fieldname': u'contacts',
+		'fieldtype': u'Check',
+		'label': u'All Contacts',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		u'doctype': u'DocField',
+		'fieldname': u'customer_contacts',
+		'fieldtype': u'Check',
+		'label': u'All Customer Contacts',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		u'doctype': u'DocField',
+		'fieldname': u'leads',
+		'fieldtype': u'Check',
+		'label': u'All Leads',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		u'doctype': u'DocField',
+		'fieldname': u'active_leads',
+		'fieldtype': u'Check',
+		'label': u'All Active Leads',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		u'doctype': u'DocField',
+		'fieldname': u'blog_subscribers',
+		'fieldtype': u'Check',
+		'label': u'All Blog Subscribers',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		u'doctype': u'DocField',
+		'fieldname': u'newsletter_content',
+		'fieldtype': u'Section Break',
+		'label': u'Newsletter Content',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		u'doctype': u'DocField',
+		'fieldname': u'subject',
+		'fieldtype': u'Small Text',
+		'label': u'Subject',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		u'doctype': u'DocField',
+		'fieldname': u'message',
+		'fieldtype': u'Code',
+		'label': u'Message',
+		'options': u'Markdown',
+		'permlevel': 0,
+		'reqd': 0
+	},
+
+	# DocField
+	{
+		u'doctype': u'DocField',
+		'fieldname': u'newsletter_status',
+		'fieldtype': u'Section Break',
+		'label': u'Newsletter Status',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		u'doctype': u'DocField',
+		'fieldname': u'email_sent',
+		'fieldtype': u'Check',
+		'label': u'Email Sent?',
+		'no_copy': 1,
+		'permlevel': 1
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		u'doctype': u'DocPerm',
+		'permlevel': 0,
+		'role': u'Sales Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		'cancel': 1,
+		'create': 1,
+		u'doctype': u'DocPerm',
+		'permlevel': 0,
+		'role': u'Support Manager',
+		'write': 1
+	},
+
+	# DocPerm
+	{
+		u'doctype': u'DocPerm',
+		'permlevel': 1,
+		'role': u'Sales Manager'
+	},
+
+	# DocPerm
+	{
+		u'doctype': u'DocPerm',
+		'permlevel': 1,
+		'role': u'Support Manager'
+	}
+]
\ No newline at end of file
diff --git a/erpnext/support/doctype/newsletter/newsletter_list.js b/erpnext/support/doctype/newsletter/newsletter_list.js
new file mode 100644
index 0000000..485fb83
--- /dev/null
+++ b/erpnext/support/doctype/newsletter/newsletter_list.js
@@ -0,0 +1,34 @@
+// ERPNext - web based ERP (http://erpnext.com)
+// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
+// 
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+wn.doclistviews['Newsletter'] = wn.views.ListView.extend({
+	init: function(doclistview) {
+		this._super(doclistview);
+		this.fields = this.fields.concat([
+			"`tabNewsletter`.subject",
+			"`tabNewsletter`.email_sent",
+		]);
+	},
+
+	columns: [
+		{width: '3%', content: 'check'},
+		{width: '5%', content: 'avatar'},
+		{width: '15%', content: 'name'},
+		{width: '55%', content: 'subject+tags'},
+		{width: '22%', content:'modified',
+			css: {'text-align': 'right', 'color':'#777'}}		
+	],
+});
\ No newline at end of file
diff --git a/erpnext/support/doctype/support_ticket/__init__.py b/erpnext/support/doctype/support_ticket/__init__.py
index bf69228..f0502f6 100644
--- a/erpnext/support/doctype/support_ticket/__init__.py
+++ b/erpnext/support/doctype/support_ticket/__init__.py
@@ -93,6 +93,7 @@
 				webnotes.conn.commit()
 				# extract attachments
 				self.save_attachments(st.doc, mail.attachments)
+				webnotes.conn.begin()
 				return
 				
 		from webnotes.model.doctype import get_property
@@ -123,9 +124,9 @@
 				self.send_auto_reply(d)
 
 			webnotes.conn.commit()
-			
 			# extract attachments
 			self.save_attachments(d, mail.attachments)
+			webnotes.conn.begin()
 			
 
 	def save_attachments(self, doc, attachment_list=[]):
diff --git a/erpnext/support/page/support_home/support_home.html b/erpnext/support/page/support_home/support_home.html
index ebc6f71..d703662 100644
--- a/erpnext/support/page/support_home/support_home.html
+++ b/erpnext/support/page/support_home/support_home.html
@@ -14,6 +14,9 @@
 			<h4><a href="#!List/Maintenance Visit">Maintenance Visit</a></h4>
 			<p class="help">Visit report for maintenance visit</p>
 			<br>
+			<h4><a href="#!List/Newsletter">Newsletter</a></h4>
+			<p class="help">Send Newsletters to your contacts</p>
+			<br>
 			<h4><a href="#!List/Communication">Communication</a></h4>
 			<p class="help">Communication Log</p>
 		</div>
diff --git a/erpnext/utilities/page/todo/todo.py b/erpnext/utilities/page/todo/todo.py
index 37f9295..f0de04e 100644
--- a/erpnext/utilities/page/todo/todo.py
+++ b/erpnext/utilities/page/todo/todo.py
@@ -49,7 +49,7 @@
 def delete(arg=None):
 	name = webnotes.form_dict['name']
 	d = Document('ToDo', name)
-	if d and d.name:
+	if d and d.name and d.owner != webnotes.session['user']:
 		notify_assignment(d)
 	webnotes.conn.sql("delete from `tabToDo` where name = %s", name)
 
diff --git a/erpnext/website/blog.py b/erpnext/website/blog.py
index e89e2df..0e13107 100644
--- a/erpnext/website/blog.py
+++ b/erpnext/website/blog.py
@@ -92,7 +92,7 @@
 	import website.web_cache
 	
 	if not args: args = webnotes.form_dict
-	args['comment'] = markdown2.markdown(args.get('comment') or '')
+	args['comment'] = unicode(markdown2.markdown(args.get('comment') or ''))
 	
 	comment = webnotes.widgets.form.comments.add_comment(args)
 	
@@ -101,7 +101,7 @@
 		args.get('comment_doctype'), args.get('comment_docname'))
 	
 	
-	comment['comment_date'] = webnotes.utils.pretty_date(comment['creation'])
+	comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
 	template_args = { 'comment_list': [comment], 'template': 'html/comment.html' }
 	
 	# get html of comment row
diff --git a/erpnext/website/doctype/blog/blog.py b/erpnext/website/doctype/blog/blog.py
index c1b25f6..56f6c86 100644
--- a/erpnext/website/doctype/blog/blog.py
+++ b/erpnext/website/doctype/blog/blog.py
@@ -15,11 +15,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from __future__ import unicode_literals
-"""
-record of files
-
-naming for same name files: file.gif, file-1.gif, file-2.gif etc
-"""
 
 import webnotes
 import website.utils
@@ -84,4 +79,4 @@
 		
 		self.doc.comment_list = comment_list or []
 		for comment in self.doc.comment_list:
-			comment['comment_date'] = webnotes.utils.pretty_date(comment['creation'])
\ No newline at end of file
+			comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
diff --git a/erpnext/website/templates/html/outer.html b/erpnext/website/templates/html/outer.html
index 47184fa..a671d98 100644
--- a/erpnext/website/templates/html/outer.html
+++ b/erpnext/website/templates/html/outer.html
@@ -14,18 +14,34 @@
 				<ul class="nav">
 					{% for page in top_bar_items %}
 						{% if not page.parent_label %}
-						<li data-label="{{ page.label }}">
-							<a href="{{ page.url }}" {{ page.target }}>
+						<li data-label="{{ page.label }}"
+							{% if page.child_items %}
+								class="dropdown"
+							{% endif %}>
+							<a href="{{ page.url or '#' }}" 
+								{% if page.child_items %}
+									class="dropdown-toggle"
+									onclick="return false;"
+									data-toggle="dropdown"
+								{% endif %}
+								{{ page.target or ''}}>
 							{{ page.label }}
 							{% if page.child_items %}
+								<b class="caret"></b>
+							</a>
 								<ul class="dropdown-menu">
 								{% for child in page.child_items %}
 									<li data-label="{{ child.label }}">
-										<a href="{{ child.url }}" {{ child.target }}>
+										<a href="{{ child.url }}" {{ child.target or '' }}>
+											{{ child.label }}
+										</a>
+									</li>
 								{% endfor %}
 								</ul>
+							{% else %}
+							</a>
 							{% endif %}
-							</a></li>
+							</li>
 						{% endif %}
 					{% endfor %}
 				</ul>
@@ -35,7 +51,8 @@
 				</ul>
 			</div>
 			</div>
-			</div>	
+			</div>
+			<script>$('.dropdown-toggle').dropdown()</script>
 	</header>
 	<div id="body_div">
 		<div class="content" id="page-{{ name }}" style="display: block;">
diff --git a/erpnext/website/templates/js/blog.js b/erpnext/website/templates/js/blog.js
index 76b9fb6..8c9b9d7 100644
--- a/erpnext/website/templates/js/blog.js
+++ b/erpnext/website/templates/js/blog.js
@@ -24,7 +24,7 @@
 		render_row: function(parent, data) {
 			if(!data.comments) {
 				data.comment_text = 'No comments yet.'
-			} else if (data.comments=1) {
+			} else if (data.comments===1) {
 				data.comment_text = '1 comment.'
 			} else {
 				data.comment_text = data.comments + ' comments.'
diff --git a/erpnext/website/web_cache.py b/erpnext/website/web_cache.py
index 7b3de0a..9892dac 100644
--- a/erpnext/website/web_cache.py
+++ b/erpnext/website/web_cache.py
@@ -139,11 +139,26 @@
 		env dict for outer template
 	"""
 	import webnotes
+	
+	all_top_items = webnotes.conn.sql("""\
+		select * from `tabTop Bar Item`
+		where parent='Website Settings' and parentfield='top_bar_items'
+		order by idx asc""", as_dict=1)
+		
+	top_items = [d for d in all_top_items if not d['parent_label']]
+	
+	# attach child items to top bar
+	for d in all_top_items:
+		if d['parent_label']:
+			for t in top_items:
+				if t['label']==d['parent_label']:
+					if not 'child_items' in t:
+						t['child_items'] = []
+					t['child_items'].append(d)
+					break
+	
 	return {
-		'top_bar_items': webnotes.conn.sql("""\
-			select * from `tabTop Bar Item`
-			where parent='Website Settings' and parentfield='top_bar_items'
-			order by idx asc""", as_dict=1),
+		'top_bar_items': top_items,
 	
 		'footer_items': webnotes.conn.sql("""\
 			select * from `tabTop Bar Item`
diff --git a/public/js/all-app.js b/public/js/all-app.js
index 8130829..3728430 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -305,7 +305,7 @@
 if(icon){$('<i>').addClass(icon).appendTo($button);}
 $button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
 if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');}
-if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){me.make_new_doc(me.new_doctype);},'icon-plus');}
+if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){(me.custom_new_doc||me.make_new_doc)(me.new_doctype);},'icon-plus');}
 if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');}
 if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
 this.onrun=a0;if(a0&&a0.callback)
@@ -321,7 +321,7 @@
  *	lib/js/wn/ui/filters.js
  */
 wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});this.$w.find('.search-btn').bind('click',function(){me.listobj.run();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
-this.add_filter();},add_filter:function(fieldname,condition,value){this.push_new_filter(fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
+this.add_filter();},add_filter:function(tablename,fieldname,condition,value){this.push_new_filter(tablename,fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(tablename,fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,tablename:tablename,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
 values.push(f.get_value());})
 return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
 this.filters=fl;},get_filter:function(fieldname){for(var i in this.filters){if(this.filters[i].field.df.fieldname==fieldname)
@@ -339,21 +339,22 @@
   </select>\
   <span class="filter_field"></span>\
   <a class="close">&times;</a>\
-  </div>');this.$w=this.flist.$w.find('.list_filter:last-child');},make_select:function(){this.fieldselect=new wn.ui.FieldSelect(this.$w.find('.fieldname_select_area'),this.doctype,this.filter_fields);},set_events:function(){var me=this;this.fieldselect.$select.bind('change',function(){me.set_field(this.value);});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.field.get_value();me.field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);}
+  </div>');this.$w=this.flist.$w.find('.list_filter:last-child');},make_select:function(){this.fieldselect=new wn.ui.FieldSelect(this.$w.find('.fieldname_select_area'),this.doctype,this.filter_fields);},set_events:function(){var me=this;this.fieldselect.$select.bind('change',function(){var $selected=$(this).find("option:selected")
+me.set_field($selected.attr("table"),$selected.attr("fieldname"));});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.field.get_value();me.field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);}
 if(value){me.flist.listobj.run();}
-me.flist.update_filters();return false;});me.$w.find('.condition').change(function(){if($(this).val()=='in'){me.set_field(me.field.df.fieldname,'Data');if(!me.field.desc_area)
-me.field.desc_area=$a(me.field.wrapper,'span','help',null,'values separated by comma');}else{me.set_field(me.field.df.fieldname);}});if(me.fieldname){this.set_values(me.fieldname,me.condition,me.value);}else{me.set_field('name');}},set_values:function(fieldname,condition,value){this.set_field(fieldname);if(condition)this.$w.find('.condition').val(condition).change();if(value)this.field.set_input(value)},set_field:function(fieldname,fieldtype){var me=this;var cur=me.field?{fieldname:me.field.df.fieldname,fieldtype:me.field.df.fieldtype}:{}
-var df=me.fieldselect.fields_by_name[fieldname];this.set_fieldtype(df,fieldtype);if(me.field&&cur.fieldname==fieldname&&df.fieldtype==cur.fieldtype){return;}
-me.fieldselect.$select.val(fieldname);var field_area=me.$w.find('.filter_field').empty().get(0);f=make_field(df,null,field_area,null,0,1);f.df.single_select=1;f.not_in_form=1;f.with_label=0;f.refresh();me.field=f;this.set_default_condition(df,fieldtype);$(me.field.wrapper).find(':input').keydown(function(ev){if(ev.which==13){me.flist.listobj.run();}})},set_fieldtype:function(df,fieldtype){if(df.original_type)
+me.flist.update_filters();return false;});me.$w.find('.condition').change(function(){if($(this).val()=='in'){me.set_field(me.field.df.parent,me.field.df.fieldname,'Data');if(!me.field.desc_area)
+me.field.desc_area=$a(me.field.wrapper,'span','help',null,'values separated by comma');}else{me.set_field(me.field.df.parent,me.field.df.fieldname);}});if(me.fieldname){this.set_values(me.tablename,me.fieldname,me.condition,me.value);}else{me.set_field(me.doctype,'name');}},set_values:function(tablename,fieldname,condition,value){this.set_field(tablename,fieldname);if(condition)this.$w.find('.condition').val(condition).change();if(value)this.field.set_input(value)},set_field:function(tablename,fieldname,fieldtype){var me=this;var cur=me.field?{fieldname:me.field.df.fieldname,fieldtype:me.field.df.fieldtype,parent:me.field.df.parent,}:{}
+var df=me.fieldselect.fields_by_name[tablename][fieldname];this.set_fieldtype(df,fieldtype);if(me.field&&cur.fieldname==fieldname&&df.fieldtype==cur.fieldtype&&df.parent==cur.parent){return;}
+me.fieldselect.$select.val(tablename+"."+fieldname);var field_area=me.$w.find('.filter_field').empty().get(0);f=make_field(df,null,field_area,null,0,1);f.df.single_select=1;f.not_in_form=1;f.with_label=0;f.refresh();me.field=f;this.set_default_condition(df,fieldtype);$(me.field.wrapper).find(':input').keydown(function(ev){if(ev.which==13){me.flist.listobj.run();}})},set_fieldtype:function(df,fieldtype){if(df.original_type)
 df.fieldtype=df.original_type;else
 df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.fieldtype=fieldtype;return;}
 if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
-if(cond=='like'){val=val+'%';}
+if(cond=='like'){if((val.length===0)||(val.lastIndexOf("%")!==(val.length-1))){val=(val||"")+'%';}}
 return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
 this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype},{fieldname:'docstatus',fieldtype:'Int',label:'Doc Status',parent:me.doctype},];var doctype_obj=locals['DocType'][me.doctype];if(doctype_obj&&cint(doctype_obj.istable)){std_filters=std_filters.concat([{fieldname:'parent',fieldtype:'Data',label:'Parent',parent:me.doctype}]);}
 if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
 $.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
-if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!(me.fields_by_name[df.fieldname]&&me.fields_by_name[df.fieldname]['parent']==df.parent)){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
+if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!(me.fields_by_name[df.parent]&&me.fields_by_name[df.parent][df.fieldname])){this.$select.append($('<option>',{value:table+"."+df.fieldname,fieldname:df.fieldname,table:df.parent}).text(label));if(!me.fields_by_name[df.parent])me.fields_by_name[df.parent]={};me.fields_by_name[df.parent][df.fieldname]=df;}}})
 /*
  *	lib/js/wn/views/container.js
  */
@@ -741,7 +742,7 @@
 LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
 if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
 me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
-_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
+_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
 LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
 if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
 me.set(val);if(_f.cur_grid_cell)
@@ -911,7 +912,7 @@
 wn.ui.Search=Class.extend({init:function(opts){$.extend(this,opts);var me=this;wn.model.with_doctype(this.doctype,function(r){me.make();me.dialog.show();me.list.$w.find('.list-filters input[type="text"]').focus();});},make:function(){var me=this;this.dialog=new wn.ui.Dialog({title:this.doctype+' Search',width:500});this.list=new wn.ui.Listing({parent:$(this.dialog.body),appframe:this.dialog.appframe,new_doctype:this.doctype,doctype:this.doctype,method:'webnotes.widgets.doclistview.get',show_filters:true,style:'compact',get_args:function(){if(me.query){me.page_length=50;return{query:me.query}}else{return{doctype:me.doctype,fields:['`tab'+me.doctype+'`.name'],filters:me.list.filter_list.get_filters(),docstatus:['0','1']}}},render_row:function(parent,data){$ln=$('<a style="cursor: pointer;" data-name="'+data.name+'">'
 +data.name+'</a>').appendTo(parent).click(function(){var val=$(this).attr('data-name');me.dialog.hide();if(me.callback)
 me.callback(val);else
-wn.set_route('Form',me.doctype,val);});}});this.list.filter_list.add_filter('name','like');this.list.run();}})
+wn.set_route('Form',me.doctype,val);});}});this.list.filter_list.add_filter(this.doctype,'name','like');this.list.run();}})
 /*
  *	lib/js/wn/ui/tree.js
  */
@@ -971,7 +972,7 @@
   </div>');this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs(this.appframe,locals.DocType[this.doctype].module,this.doctype);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();me.make_help();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},make_help:function(){if(this.meta.description){this.appframe.add_help_button(wn.markdown('## '+this.meta.name+'\n\n'
 +this.meta.description));}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
 else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
-this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){var me=this;this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});$(this.wrapper).find('button[list_view_doc="'+me.doctype+'"]').click(function(){me.make_new_doc(me.doctype);});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){var no_result_message=repl('<div class="well">\
+this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){var me=this;this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields,custom_new_doc:me.listview.make_new_doc||undefined,});$(this.wrapper).find('button[list_view_doc="'+me.doctype+'"]').click(function(){(me.listview.make_new_doc||me.make_new_doc)(me.doctype);});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){var no_result_message=repl('<div class="well">\
   <p>No %(doctype_label)s found</p>\
   <hr>\
   <p><button class="btn btn-info btn-small" list_view_doc="%(doctype)s">\
@@ -997,7 +998,7 @@
     <a href="#" data-label="%(label)s" data-field="%(field)s">\
      %(label)s</a> \
     (%(count)s)</div>\
-  </div>',args));this.setup_stat_item_click($item);return $item;},reload_stats:function(){this.$page.find('.layout-side-section .stat-wrapper').remove();this.init_stats();},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{filter.set_values(fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(fieldname,'like','%'+label);}else{this.filter_list.add_filter(fieldname,'=',label);}}
+  </div>',args));this.setup_stat_item_click($item);return $item;},reload_stats:function(){this.$page.find('.layout-side-section .stat-wrapper').remove();this.init_stats();},setup_stat_item_click:function($item){var me=this;$item.find('a').click(function(){var fieldname=$(this).attr('data-field');var label=$(this).attr('data-label');me.set_filter(fieldname,label);return false;});},set_filter:function(fieldname,label){var filter=this.filter_list.get_filter(fieldname);if(filter){var v=filter.field.get_value();if(v.indexOf(label)!=-1){return false;}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(this.doctype,fieldname,'like','%'+label);}else{filter.set_values(this.doctype,fieldname,'in',v+', '+label);}}}else{if(fieldname=='_user_tags'){this.filter_list.add_filter(this.doctype,fieldname,'like','%'+label);}else{this.filter_list.add_filter(this.doctype,fieldname,'=',label);}}
 this.run();}});wn.views.ListView=Class.extend({init:function(doclistview){this.doclistview=doclistview;this.doctype=doclistview.doctype;var t="`tab"+this.doctype+"`.";this.fields=[t+'name',t+'owner',t+'docstatus',t+'_user_tags',t+'modified'];this.stats=['_user_tags'];this.show_hide_check_column();},columns:[{width:'3%',content:'check'},{width:'4%',content:'avatar'},{width:'3%',content:'docstatus',css:{"text-align":"center"}},{width:'35%',content:'name'},{width:'40%',content:'tags',css:{'color':'#aaa'}},{width:'15%',content:'modified',css:{'text-align':'right','color':'#222'}}],render_column:function(data,parent,opts){var me=this;if(opts.css){$.each(opts.css,function(k,v){$(parent).css(k,v)});}
 if(opts.content.indexOf&&opts.content.indexOf('+')!=-1){$.map(opts.content.split('+'),function(v){me.render_column(data,parent,{content:v});});return;}
 if(typeof opts.content=='function'){opts.content(parent,data,me);}
@@ -1013,7 +1014,8 @@
 else if(opts.type=='link'&&opts.doctype){$(parent).append(repl('<a href="#!Form/'+opts.doctype+'/'
 +data[opts.content]+'">'+data[opts.content]+'</a>',data));}
 else if(opts.template){$(parent).append(repl(opts.template,data));}
-else if(data[opts.content]){$(parent).append(' '+data[opts.content]);}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('<td style="width: %(width)s"></td>',v);});var tr=$(row).html('<table><tbody><tr>'+rowhtml+'</tr></tbody></table>').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;this.prepare_when(data,data.modified);if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}
+else if(data[opts.content]){if(opts.type=="date"){data[opts.content]=wn.datetime.str_to_user(data[opts.content])}
+$(parent).append(repl('<span title="%(title)s"> %(content)s</span>',{"title":opts.title||opts.content,"content":data[opts.content]}));}},render:function(row,data){var me=this;this.prepare_data(data);rowhtml='';$.each(this.columns,function(i,v){rowhtml+=repl('<td style="width: %(width)s"></td>',v);});var tr=$(row).html('<table><tbody><tr>'+rowhtml+'</tr></tbody></table>').find('tr').get(0);$.each(this.columns,function(i,v){me.render_column(data,tr.cells[i],v);});},prepare_data:function(data){data.fullname=wn.user_info(data.owner).fullname;data.avatar=wn.user_info(data.owner).image;this.prepare_when(data,data.modified);if(data.docstatus==0||data.docstatus==null){data.docstatus_icon='icon-pencil';data.docstatus_title='Editable';}else if(data.docstatus==1){data.docstatus_icon='icon-lock';data.docstatus_title='Submitted';}else if(data.docstatus==2){data.docstatus_icon='icon-remove';data.docstatus_title='Cancelled';}
 for(key in data){if(data[key]==null){data[key]='';}}},prepare_when:function(data,date_str){if(!date_str)date_str=data.modified;data.when=dateutil.str_to_user(date_str).split(' ')[0];var diff=dateutil.get_diff(dateutil.get_today(),date_str.split(' ')[0]);if(diff==0){data.when=dateutil.comment_when(date_str);}
 if(diff==1){data.when='Yesterday'}
 if(diff==2){data.when='2 days ago'}},add_user_tags:function(parent,data){var me=this;if(data._user_tags){if($(parent).html().length>0){$(parent).append('<br />');}
@@ -1040,11 +1042,10 @@
 if(!rb.forbidden){wn.container.change_to('Report Builder');}});}}
 wn.views.reportview2={show:function(dt){var page_name=wn.get_route_str();if(wn.pages[page_name]){wn.container.change_to(wn.pages[page_name]);}else{var route=wn.get_route();if(route[1]){new wn.views.ReportViewPage(route[1],route[2]);}else{wn.set_route('404');}}}}
 wn.views.ReportViewPage=Class.extend({init:function(doctype,docname){this.doctype=doctype;this.docname=docname;this.page_name=wn.get_route_str();this.make_page();var me=this;wn.model.with_doctype(doctype,function(){me.make_report_view();if(docname){wn.model.with_doc('Report',docname,function(r){me.reportview.set_columns_and_filters(JSON.parse(locals['Report'][docname].json));me.reportview.run();});}else{me.reportview.run();}});},make_page:function(){this.page=wn.container.add_page(this.page_name);wn.ui.make_app_page({parent:this.page,single_column:true});wn.container.change_to(this.page_name);},make_report_view:function(){this.page.appframe.add_breadcrumb(locals.DocType[this.doctype].module);this.reportview=new wn.views.ReportView(this.doctype,this.docname,this.page)}})
-wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname,page){var me=this;$(page).find('.layout-main').html('Loading Report...');this.import_slickgrid();$(page).find('.layout-main').empty();this.doctype=doctype;this.docname=docname;this.page=page;this.tab_name='`tab'+doctype+'`';this.setup();},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'&&df.fieldtype!='Table'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_selected_table_and_column(this.sort_by_select)
-+' '+this.sort_order_select.val()
-if(this.sort_by_next_select.val()){order_by+=', '+this.get_selected_table_and_column(this.sort_by_next_select)
-+' '+this.sort_order_next_select.val()}
-return order_by;},get_selected_table_and_column:function($select){return this.get_full_column_name([$select.val(),$select.find('option:selected').attr('table')])},get_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){var docfield=wn.meta.docfield_map[c[1]||me.doctype][c[0]];coldef={id:c[0],field:c[0],docfield:docfield,name:(docfield?docfield.label:toTitle(c[0])),width:(docfield?cint(docfield.width):120)||120}
+wn.views.ReportView=wn.ui.Listing.extend({init:function(doctype,docname,page){var me=this;$(page).find('.layout-main').html('Loading Report...');this.import_slickgrid();$(page).find('.layout-main').empty();this.doctype=doctype;this.docname=docname;this.page=page;this.tab_name='`tab'+doctype+'`';this.setup();},import_slickgrid:function(){wn.require('js/lib/slickgrid/slick.grid.css');wn.require('js/lib/slickgrid/slick-default-theme.css');wn.require('js/lib/slickgrid/jquery.event.drag.min.js');wn.require('js/lib/slickgrid/slick.core.js');wn.require('js/lib/slickgrid/slick.grid.js');wn.dom.set_style('.slick-cell { font-size: 12px; }');},set_init_columns:function(){var columns=[['name'],['owner']];$.each(wn.meta.docfield_list[this.doctype],function(i,df){if(df.in_filter&&df.fieldname!='naming_series'&&df.fieldtype!='Table'){columns.push([df.fieldname]);}});this.columns=columns;},setup:function(){var me=this;this.make({title:'Report: '+(this.docname?(this.doctype+' - '+this.docname):this.doctype),appframe:this.page.appframe,method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:$(this.page).find('.layout-main'),start:0,page_length:20,show_filters:true,new_doctype:this.doctype,allow_delete:true,});this.make_column_picker();this.make_sorter();this.make_export();this.set_init_columns();this.make_save();},set_columns_and_filters:function(opts){var me=this;if(opts.columns)this.columns=opts.columns;if(opts.filters)$.each(opts.filters,function(i,f){me.filter_list.add_filter(f[0],f[1],f[2],f[3]);});if(opts.sort_by)this.sort_by_select.val(opts.sort_by);if(opts.sort_order)this.sort_order_select.val(opts.sort_order);if(opts.sort_by_next)this.sort_by_next_select.val(opts.sort_by_next);if(opts.sort_order_next)this.sort_order_next_select.val(opts.sort_order_next);},get_args:function(){var me=this;return{doctype:this.doctype,fields:$.map(this.columns,function(v){return me.get_full_column_name(v)}),order_by:this.get_order_by(),filters:this.filter_list.get_filters(),docstatus:['0','1','2']}},get_order_by:function(){var order_by=this.get_selected_table_and_column(this.sort_by_select)
++' '+this.sort_order_select.val();if(this.sort_by_next_select.val()){order_by+=', '+this.get_selected_table_and_column(this.sort_by_next_select)
++' '+this.sort_order_next_select.val();}
+return order_by;},get_selected_table_and_column:function($select){return this.get_full_column_name([$select.find('option:selected').attr('fieldname'),$select.find('option:selected').attr('table')])},get_full_column_name:function(v){return(v[1]?('`tab'+v[1]+'`'):this.tab_name)+'.'+v[0];},build_columns:function(){var me=this;return $.map(this.columns,function(c){var docfield=wn.meta.docfield_map[c[1]||me.doctype][c[0]];coldef={id:c[0],field:c[0],docfield:docfield,name:(docfield?docfield.label:toTitle(c[0])),width:(docfield?cint(docfield.width):120)||120}
 if(c[0]=='name'){coldef.formatter=function(row,cell,value,columnDef,dataContext){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:me.doctype,name:value});}}else if(docfield&&docfield.fieldtype=='Link'){coldef.formatter=function(row,cell,value,columnDef,dataContext){if(value){return repl("<a href='#!Form/%(doctype)s/%(name)s'>%(name)s</a>",{doctype:columnDef.docfield.options,name:value});}else{return'';}}}
 return coldef;});},render_list:function(){var me=this;var columns=[{id:'_idx',field:'_idx',name:'Sr.',width:40}].concat(this.build_columns());$.each(this.data,function(i,v){v._idx=i+1;});var options={enableCellNavigation:true,enableColumnReorder:false};var grid=new Slick.Grid(this.$w.find('.result-list').css('border','1px solid grey').css('height','500px').get(0),this.data,columns,options);},make_column_picker:function(){var me=this;this.column_picker=new wn.ui.ColumnPicker(this);this.page.appframe.add_button('Pick Columns',function(){me.column_picker.show(me.columns);},'icon-th-list');},make_sorter:function(){var me=this;this.sort_dialog=new wn.ui.Dialog({title:'Sorting Preferences'});$(this.sort_dialog.body).html('<p class="help">Sort By</p>\
    <div class="sort-column"></div>\
@@ -1067,11 +1068,11 @@
    <div><button class="btn btn-small btn-add"><i class="icon-plus"></i>\
     Add Column</button></div>\
    <hr>\
-   <div><button class="btn btn-small btn-info">Update</div>');$.each(columns,function(i,c){me.add_column(c);});$(this.dialog.body).find('.column-list').sortable();$(this.dialog.body).find('.btn-add').click(function(){me.add_column('name');});$(this.dialog.body).find('.btn-info').click(function(){me.dialog.hide();me.list.columns=[];$(me.dialog.body).find('select').each(function(){me.list.columns.push([$(this).val(),$(this).find('option:selected').attr('table')]);})
+   <div><button class="btn btn-small btn-info">Update</div>');$.each(columns,function(i,c){me.add_column(c);});$(this.dialog.body).find('.column-list').sortable();$(this.dialog.body).find('.btn-add').click(function(){me.add_column(['name']);});$(this.dialog.body).find('.btn-info').click(function(){me.dialog.hide();me.list.columns=[];$(me.dialog.body).find('select').each(function(){var $selected=$(this).find('option:selected');me.list.columns.push([$selected.attr('fieldname'),$selected.attr('table')]);})
 me.list.run();});this.dialog.show();},add_column:function(c){var w=$('<div style="padding: 5px 5px 5px 35px; background-color: #eee; width: 70%; \
    margin-bottom: 10px; border-radius: 3px; cursor: move;">\
    <a class="close" style="margin-top: 5px;">&times</a>\
-   </div>').appendTo($(this.dialog.body).find('.column-list'));var fieldselect=new wn.ui.FieldSelect(w,this.doctype);fieldselect.$select.css('width','90%').val(c);w.find('.close').click(function(){$(this).parent().remove();});}});
+   </div>').appendTo($(this.dialog.body).find('.column-list'));var fieldselect=new wn.ui.FieldSelect(w,this.doctype);fieldselect.$select.css('width','90%').val((c[1]||this.doctype)+"."+c[0]);w.find('.close').click(function(){$(this).parent().remove();});}});
 /*
  *	lib/js/legacy/widgets/dialog.js
  */
@@ -1266,7 +1267,7 @@
 wn.set_route('Report',dt,rep_name);else
 wn.set_route('Report',dt);}
 function loaddoc(doctype,name,onload){wn.model.with_doctype(doctype,function(){if(locals.DocType[doctype].in_dialog){_f.edit_record(doctype,name);}else{wn.set_route('Form',doctype,name);}})}
-var load_doc=loaddoc;function new_doc(doctype,onload,in_dialog,on_save_callback,cdt,cdn,cnic){doctype=get_label_doctype(doctype);wn.model.with_doctype(doctype,function(){if(locals.DocType[doctype].in_dialog){var new_name=LocalDB.create(doctype);_f.edit_record(doctype,new_name);}else{wn.views.formview.create(doctype);}})}
+var load_doc=loaddoc;function new_doc(doctype,in_form){doctype=get_label_doctype(doctype);wn.model.with_doctype(doctype,function(){if(!in_form&&locals.DocType[doctype].in_dialog){var new_name=LocalDB.create(doctype);_f.edit_record(doctype,new_name);}else{wn.views.formview.create(doctype);}})}
 var newdoc=new_doc;var pscript={};function loadpage(page_name,call_back,no_history){wn.set_route(page_name);}
 function loaddocbrowser(dt){wn.set_route('List',dt);}
 /*
@@ -1574,7 +1575,7 @@
 LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
 if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
 me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
-_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
+_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
 LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
 if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
 me.set(val);if(_f.cur_grid_cell)
@@ -1699,7 +1700,7 @@
  */
 _f.FrmHeader=Class.extend({init:function(parent,frm){this.appframe=new wn.ui.AppFrame(parent)
 this.$w=this.appframe.$w;},refresh:function(){if(cur_frm.cscript.set_breadcrumbs){this.appframe.clear_breadcrumbs();cur_frm.cscript.set_breadcrumbs();}else{wn.views.breadcrumbs(this.appframe,cur_frm.meta.module,cur_frm.meta.name,cur_frm.docname);}
-this.refresh_labels();this.refresh_toolbar();},refresh_labels:function(){var labinfo={0:['Saved','label-success'],1:['Submitted','label-info'],2:['Cancelled','label-important']}[cint(cur_frm.doc.docstatus)];if(labinfo[0]=='Saved'&&cur_frm.meta.is_submittable){labinfo[0]='Saved, to Submit';}
+this.refresh_labels();this.refresh_toolbar();},refresh_labels:function(){cur_frm.doc=get_local(cur_frm.doc.doctype,cur_frm.doc.name);var labinfo={0:['Saved','label-success'],1:['Submitted','label-info'],2:['Cancelled','label-important']}[cint(cur_frm.doc.docstatus)];if(labinfo[0]=='Saved'&&cur_frm.meta.is_submittable){labinfo[0]='Saved, to Submit';}
 if(cur_frm.doc.__unsaved||cur_frm.doc.__islocal){labinfo[0]='Not Saved';labinfo[1]='label-warning'}
 this.set_label(labinfo);if(cur_frm.doc.__unsaved&&cint(cur_frm.doc.docstatus)==1&&this.appframe.buttons['Update']){this.appframe.buttons['Update'].toggle(true);}},set_label:function(labinfo){this.$w.find('.label').remove();$(repl('<span class="label %(lab_class)s">\
    %(lab_status)s</span>',{lab_status:labinfo[0],lab_class:labinfo[1]})).insertBefore(this.$w.find('.breadcrumb-area'))},refresh_toolbar:function(){if(cur_frm.meta.hide_toolbar){$('.appframe-toolbar').toggle(false);return;}
@@ -2141,11 +2142,11 @@
 refresh_many=function(flist,dn,table_field){for(var i in flist){if(table_field)refresh_field(flist[i],dn,table_field);else refresh_field(flist[i]);}}
 set_field_tip=function(n,txt){var df=wn.meta.get_docfield(cur_frm.doctype,n,cur_frm.docname);if(df)df.description=txt;if(cur_frm&&cur_frm.fields_dict){if(cur_frm.fields_dict[n])
 cur_frm.fields_dict[n].comment_area.innerHTML=replace_newlines(txt);else
-errprint('[set_field_tip] Unable to set field tip: '+n);}}
+console.log('[set_field_tip] Unable to set field tip: '+n);}}
 refresh_field=function(n,docname,table_field){if(typeof n==typeof[])refresh_many(n,docname,table_field);if(table_field){if(_f.frm_dialog&&_f.frm_dialog.display){_f.frm_dialog.cur_frm.refresh_field(n);}else{var g=_f.cur_grid_cell;if(g)var hc=g.grid.head_row.cells[g.cellIndex];if(g&&hc&&hc.fieldname==n&&g.row.docname==docname){hc.template.refresh();}else{cur_frm.fields_dict[table_field].grid.refresh_cell(docname,n);}}}else if(cur_frm){cur_frm.refresh_field(n)}}
 set_field_options=function(n,txt){cur_frm.set_df_property(n,'options',txt)}
 set_field_permlevel=function(n,level){cur_frm.set_df_property(n,'permlevel',level)}
-toggle_field=function(n,hidden){var df_obj=get_field_obj(n);var df=Meta.get_field(cur_frm.doctype,n,cur_frm.docname);if(df){if(df_obj.df.fieldtype==="Section Break"){$(df_obj.row.wrapper).toggle(hidden?false:true);}else if(df_obj.df.fieldtype==="Column Break"){$(df_obj.cell.wrapper).toggle(hidden?false:true);}else{df.hidden=hidden;refresh_field(n);}}
+toggle_field=function(n,hidden){var df=Meta.get_field(cur_frm.doctype,n,cur_frm.docname);if(df){df.hidden=hidden;refresh_field(n);}
 else{console.log((hidden?"hide_field":"unhide_field")+" cannot find field "+n);}}
 hide_field=function(n){if(cur_frm){if(n.substr)toggle_field(n,1);else{for(var i in n)toggle_field(n[i],1)}}}
 unhide_field=function(n){if(cur_frm){if(n.substr)toggle_field(n,0);else{for(var i in n)toggle_field(n[i],0)}}}
diff --git a/public/js/all-web.js b/public/js/all-web.js
index e231046..bdecfd4 100644
--- a/public/js/all-web.js
+++ b/public/js/all-web.js
@@ -192,7 +192,7 @@
 if(icon){$('<i>').addClass(icon).appendTo($button);}
 $button.html(label).click(click);return $button}},show_view:function($btn,$div,$btn_unsel,$div_unsel){$btn_unsel.removeClass('btn-info');$btn_unsel.find('i').removeClass('icon-white');$div_unsel.toggle(false);$btn.addClass('btn-info');$btn.find('i').addClass('icon-white');$div.toggle(true);},set_events:function(){var me=this;this.$w.find('.btn-more').click(function(){me.run({append:true});});if(this.title){this.$w.find('h3').html(this.title).toggle(true);}
 if(!(this.hide_refresh||this.no_refresh)){this.add_button('Refresh',function(){me.run();},'icon-refresh');}
-if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){me.make_new_doc(me.new_doctype);},'icon-plus');}
+if(this.new_doctype){this.add_button('New '+this.new_doctype,function(){(me.custom_new_doc||me.make_new_doc)(me.new_doctype);},'icon-plus');}
 if(me.show_filters){this.add_button('Show Filters',function(){me.filter_list.show_filters();},'icon-search').addClass('btn-filter');}
 if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
 this.onrun=a0;if(a0&&a0.callback)
@@ -208,7 +208,7 @@
  *	lib/js/wn/ui/filters.js
  */
 wn.ui.FilterList=Class.extend({init:function(opts){wn.require('js/fields.js');$.extend(this,opts);this.filters=[];this.$w=this.$parent;this.set_events();},set_events:function(){var me=this;this.$w.find('.add-filter-btn').bind('click',function(){me.add_filter();});this.$w.find('.search-btn').bind('click',function(){me.listobj.run();});},show_filters:function(){this.$w.find('.show_filters').toggle();if(!this.filters.length)
-this.add_filter();},add_filter:function(fieldname,condition,value){this.push_new_filter(fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
+this.add_filter();},add_filter:function(tablename,fieldname,condition,value){this.push_new_filter(tablename,fieldname,condition,value);if(fieldname){this.$w.find('.show_filters').toggle(true);}},push_new_filter:function(tablename,fieldname,condition,value){this.filters.push(new wn.ui.Filter({flist:this,tablename:tablename,fieldname:fieldname,condition:condition,value:value}));},get_filters:function(){var values=[];$.each(this.filters,function(i,f){if(f.field)
 values.push(f.get_value());})
 return values;},update_filters:function(){var fl=[];$.each(this.filters,function(i,f){if(f.field)fl.push(f);})
 this.filters=fl;},get_filter:function(fieldname){for(var i in this.filters){if(this.filters[i].field.df.fieldname==fieldname)
@@ -226,21 +226,22 @@
   </select>\
   <span class="filter_field"></span>\
   <a class="close">&times;</a>\
-  </div>');this.$w=this.flist.$w.find('.list_filter:last-child');},make_select:function(){this.fieldselect=new wn.ui.FieldSelect(this.$w.find('.fieldname_select_area'),this.doctype,this.filter_fields);},set_events:function(){var me=this;this.fieldselect.$select.bind('change',function(){me.set_field(this.value);});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.field.get_value();me.field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);}
+  </div>');this.$w=this.flist.$w.find('.list_filter:last-child');},make_select:function(){this.fieldselect=new wn.ui.FieldSelect(this.$w.find('.fieldname_select_area'),this.doctype,this.filter_fields);},set_events:function(){var me=this;this.fieldselect.$select.bind('change',function(){var $selected=$(this).find("option:selected")
+me.set_field($selected.attr("table"),$selected.attr("fieldname"));});this.$w.find('a.close').bind('click',function(){me.$w.css('display','none');var value=me.field.get_value();me.field=null;if(!me.flist.get_filters().length){me.flist.$w.find('.set_filters').toggle(true);me.flist.$w.find('.show_filters').toggle(false);}
 if(value){me.flist.listobj.run();}
-me.flist.update_filters();return false;});me.$w.find('.condition').change(function(){if($(this).val()=='in'){me.set_field(me.field.df.fieldname,'Data');if(!me.field.desc_area)
-me.field.desc_area=$a(me.field.wrapper,'span','help',null,'values separated by comma');}else{me.set_field(me.field.df.fieldname);}});if(me.fieldname){this.set_values(me.fieldname,me.condition,me.value);}else{me.set_field('name');}},set_values:function(fieldname,condition,value){this.set_field(fieldname);if(condition)this.$w.find('.condition').val(condition).change();if(value)this.field.set_input(value)},set_field:function(fieldname,fieldtype){var me=this;var cur=me.field?{fieldname:me.field.df.fieldname,fieldtype:me.field.df.fieldtype}:{}
-var df=me.fieldselect.fields_by_name[fieldname];this.set_fieldtype(df,fieldtype);if(me.field&&cur.fieldname==fieldname&&df.fieldtype==cur.fieldtype){return;}
-me.fieldselect.$select.val(fieldname);var field_area=me.$w.find('.filter_field').empty().get(0);f=make_field(df,null,field_area,null,0,1);f.df.single_select=1;f.not_in_form=1;f.with_label=0;f.refresh();me.field=f;this.set_default_condition(df,fieldtype);$(me.field.wrapper).find(':input').keydown(function(ev){if(ev.which==13){me.flist.listobj.run();}})},set_fieldtype:function(df,fieldtype){if(df.original_type)
+me.flist.update_filters();return false;});me.$w.find('.condition').change(function(){if($(this).val()=='in'){me.set_field(me.field.df.parent,me.field.df.fieldname,'Data');if(!me.field.desc_area)
+me.field.desc_area=$a(me.field.wrapper,'span','help',null,'values separated by comma');}else{me.set_field(me.field.df.parent,me.field.df.fieldname);}});if(me.fieldname){this.set_values(me.tablename,me.fieldname,me.condition,me.value);}else{me.set_field(me.doctype,'name');}},set_values:function(tablename,fieldname,condition,value){this.set_field(tablename,fieldname);if(condition)this.$w.find('.condition').val(condition).change();if(value)this.field.set_input(value)},set_field:function(tablename,fieldname,fieldtype){var me=this;var cur=me.field?{fieldname:me.field.df.fieldname,fieldtype:me.field.df.fieldtype,parent:me.field.df.parent,}:{}
+var df=me.fieldselect.fields_by_name[tablename][fieldname];this.set_fieldtype(df,fieldtype);if(me.field&&cur.fieldname==fieldname&&df.fieldtype==cur.fieldtype&&df.parent==cur.parent){return;}
+me.fieldselect.$select.val(tablename+"."+fieldname);var field_area=me.$w.find('.filter_field').empty().get(0);f=make_field(df,null,field_area,null,0,1);f.df.single_select=1;f.not_in_form=1;f.with_label=0;f.refresh();me.field=f;this.set_default_condition(df,fieldtype);$(me.field.wrapper).find(':input').keydown(function(ev){if(ev.which==13){me.flist.listobj.run();}})},set_fieldtype:function(df,fieldtype){if(df.original_type)
 df.fieldtype=df.original_type;else
 df.original_type=df.fieldtype;df.description='';df.reqd=0;if(fieldtype){df.fieldtype=fieldtype;return;}
 if(df.fieldtype=='Check'){df.fieldtype='Select';df.options='No\nYes';}else if(['Text','Text Editor','Code','Link'].indexOf(df.fieldtype)!=-1){df.fieldtype='Data';}},set_default_condition:function(df,fieldtype){if(!fieldtype){if(df.fieldtype=='Data'){this.$w.find('.condition').val('like');}else{this.$w.find('.condition').val('=');}}},get_value:function(){var me=this;var val=me.field.get_value();var cond=me.$w.find('.condition').val();if(me.field.df.original_type=='Check'){val=(val=='Yes'?1:0);}
-if(cond=='like'){val=val+'%';}
+if(cond=='like'){if((val.length===0)||(val.lastIndexOf("%")!==(val.length-1))){val=(val||"")+'%';}}
 return[me.fieldselect.$select.find('option:selected').attr('table'),me.field.df.fieldname,me.$w.find('.condition').val(),cstr(val)];}});wn.ui.FieldSelect=Class.extend({init:function(parent,doctype,filter_fields,with_blank){this.doctype=doctype;this.fields_by_name={};this.with_blank=with_blank;this.$select=$('<select>').appendTo(parent);if(filter_fields){for(var i in filter_fields)
 this.add_field_option(this.filter_fields[i])}else{this.build_options();}},build_options:function(){var me=this;me.table_fields=[];var std_filters=[{fieldname:'name',fieldtype:'Data',label:'ID',parent:me.doctype},{fieldname:'modified',fieldtype:'Date',label:'Last Modified',parent:me.doctype},{fieldname:'owner',fieldtype:'Data',label:'Created By',parent:me.doctype},{fieldname:'creation',fieldtype:'Date',label:'Created On',parent:me.doctype},{fieldname:'_user_tags',fieldtype:'Data',label:'Tags',parent:me.doctype},{fieldname:'docstatus',fieldtype:'Int',label:'Doc Status',parent:me.doctype},];var doctype_obj=locals['DocType'][me.doctype];if(doctype_obj&&cint(doctype_obj.istable)){std_filters=std_filters.concat([{fieldname:'parent',fieldtype:'Data',label:'Parent',parent:me.doctype}]);}
 if(this.with_blank){this.$select.append($('<option>',{value:''}).text(''));}
 $.each(std_filters.concat(wn.meta.docfield_list[me.doctype]),function(i,df){me.add_field_option(df);});$.each(me.table_fields,function(i,table_df){if(table_df.options){$.each(wn.meta.docfield_list[table_df.options],function(i,df){me.add_field_option(df);});}});},add_field_option:function(df){var me=this;if(me.doctype&&df.parent==me.doctype){var label=df.label;var table=me.doctype;if(df.fieldtype=='Table')me.table_fields.push(df);}else{var label=df.label+' ('+df.parent+')';var table=df.parent;}
-if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!(me.fields_by_name[df.fieldname]&&me.fields_by_name[df.fieldname]['parent']==df.parent)){this.$select.append($('<option>',{value:df.fieldname,table:table}).text(label));me.fields_by_name[df.fieldname]=df;}}})
+if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!(me.fields_by_name[df.parent]&&me.fields_by_name[df.parent][df.fieldname])){this.$select.append($('<option>',{value:table+"."+df.fieldname,fieldname:df.fieldname,table:df.parent}).text(label));if(!me.fields_by_name[df.parent])me.fields_by_name[df.parent]={};me.fields_by_name[df.parent][df.fieldname]=df;}}})
 /*
  *	lib/js/wn/views/container.js
  */
@@ -611,7 +612,7 @@
 wn.set_route('Report',dt,rep_name);else
 wn.set_route('Report',dt);}
 function loaddoc(doctype,name,onload){wn.model.with_doctype(doctype,function(){if(locals.DocType[doctype].in_dialog){_f.edit_record(doctype,name);}else{wn.set_route('Form',doctype,name);}})}
-var load_doc=loaddoc;function new_doc(doctype,onload,in_dialog,on_save_callback,cdt,cdn,cnic){doctype=get_label_doctype(doctype);wn.model.with_doctype(doctype,function(){if(locals.DocType[doctype].in_dialog){var new_name=LocalDB.create(doctype);_f.edit_record(doctype,new_name);}else{wn.views.formview.create(doctype);}})}
+var load_doc=loaddoc;function new_doc(doctype,in_form){doctype=get_label_doctype(doctype);wn.model.with_doctype(doctype,function(){if(!in_form&&locals.DocType[doctype].in_dialog){var new_name=LocalDB.create(doctype);_f.edit_record(doctype,new_name);}else{wn.views.formview.create(doctype);}})}
 var newdoc=new_doc;var pscript={};function loadpage(page_name,call_back,no_history){wn.set_route(page_name);}
 function loaddocbrowser(dt){wn.set_route('List',dt);}
 /*
diff --git a/public/js/fields.js b/public/js/fields.js
index 7325ea4..8fee106 100644
--- a/public/js/fields.js
+++ b/public/js/fields.js
@@ -105,7 +105,7 @@
 LinkField.prototype.setup_buttons=function(){var me=this;me.btn.onclick=function(){selector.set(me,me.df.options,me.df.label);selector.show(me.txt);}
 if(me.btn1)me.btn1.onclick=function(){if(me.txt.value&&me.df.options){loaddoc(me.df.options,me.txt.value);}}
 me.can_create=0;if((!me.not_in_form)&&in_list(profile.can_create,me.df.options)){me.can_create=1;me.btn2.onclick=function(){var on_save_callback=function(new_rec){if(new_rec){var d=_f.calling_doc_stack.pop();locals[d[0]][d[1]][me.df.fieldname]=new_rec;me.refresh();if(me.grid)me.grid.refresh();me.run_trigger();}}
-_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options,me.on_new,1,on_save_callback,me.doctype,me.docname,me.frm.not_in_container);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
+_f.calling_doc_stack.push([me.doctype,me.docname]);new_doc(me.df.options);}}else{$dh(me.btn2);$y($td(me.tab,0,2),{width:'0px'});}}
 LinkField.prototype.set_input_value=function(val){var me=this;me.set_input_value_executed=true;var from_selector=false;if(selector&&selector.display)from_selector=true;me.refresh_label_icon();if(me.not_in_form){$(this.txt).val(val);return;}
 if(cur_frm){if(val==locals[me.doctype][me.docname][me.df.fieldname]){me.run_trigger();return;}}
 me.set(val);if(_f.cur_grid_cell)
diff --git a/public/js/report-legacy.js b/public/js/report-legacy.js
index d2d67c5..efdb2a0 100644
--- a/public/js/report-legacy.js
+++ b/public/js/report-legacy.js
@@ -33,7 +33,7 @@
 _r.ReportBuilder.prototype.set_filter=function(dt,label,value){if(this.filter_fields_dict[dt+'\1'+label])
 this.filter_fields_dict[dt+'\1'+label].set_input(value);}
 _r.ReportBuilder.prototype.load_criteria=function(criteria_name){this.clear_criteria();if(!this.sc_dict[criteria_name]){alert(criteria_name+' could not be loaded. Please Refresh and try again');}
-this.sc=locals['Search Criteria'][this.sc_dict[criteria_name]];var report=this;if(this.sc&&this.sc.report_script)eval(this.sc.report_script);this.large_report=0;if(report.customize_filters){try{report.customize_filters(this);}catch(err){errprint('Error in "customize_filters":\n'+err);}}
+this.sc=locals['Search Criteria'][this.sc_dict[criteria_name]];var report=this;if(this.sc&&this.sc.report_script)eval(this.sc.report_script);this.large_report=0;if(report.customize_filters){try{report.customize_filters(this);}catch(err){console.log('Error in "customize_filters":\n'+err);}}
 this.report_filters.refresh();this.column_picker.clear();var cl=this.sc.columns?this.sc.columns.split(','):[];for(var c=0;c<cl.length;c++){var key=cl[c].split('\1');this.select_column(key[0],key[1],1);}
 eval('var fl='+this.sc.filters);for(var n in fl){if(fl[n]){var key=n.split('\1');if(key[1]=='docstatus'){}
 this.set_filter(key[0],key[1],fl[n]);}}