merge
diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js
index 1a0f76e..8f6b598 100644
--- a/accounts/page/general_ledger/general_ledger.js
+++ b/accounts/page/general_ledger/general_ledger.js
@@ -243,13 +243,9 @@
 					out = this.group_data_by_ledger(grouped_ledgers);
 			}
 			
-			if(me.account_by_name[me.account].debit_or_credit == "Debit") {
-				opening.debit -= opening.credit; opening.credit = 0;
-				closing.debit -= closing.credit; closing.credit = 0;
-			} else {
-				opening.credit -= opening.debit; opening.debit = 0;
-				closing.credit -= closing.debit; closing.debit = 0;
-			}
+			opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening)
+			closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing)
+			
 			out = [opening].concat(out).concat([totals, closing]);
 		} else {
 			me.appframe.set_title("General Ledger");
@@ -260,6 +256,7 @@
 	},
 
 	group_data_by_ledger: function(grouped_ledgers) {
+		var me = this;
 		var out = []
 		$.each(Object.keys(grouped_ledgers).sort(), function(i, account) {
 			if(grouped_ledgers[account].entries.length) {
@@ -270,7 +267,14 @@
 				grouped_ledgers[account].closing.credit = 
 					grouped_ledgers[account].opening.credit
 					+ grouped_ledgers[account].totals.credit;
-
+			
+				grouped_ledgers[account].opening = 
+					me.get_balance(me.account_by_name[me.account].debit_or_credit,
+					grouped_ledgers[account].opening)
+				grouped_ledgers[account].closing = 
+					me.get_balance(me.account_by_name[me.account].debit_or_credit, 
+					grouped_ledgers[account].closing)
+				
 				out = out.concat([grouped_ledgers[account].opening])
 					.concat(grouped_ledgers[account].entries)
 					.concat([grouped_ledgers[account].totals, 
@@ -280,6 +284,15 @@
 		});
 		return [{id: "_blank_first", _no_format: true, debit: "", credit: ""}].concat(out);
 	},
+	
+	get_balance: function(debit_or_credit, balance) {
+		if(debit_or_credit == "Debit") {
+			balance.debit -= balance.credit; balance.credit = 0;
+		} else {
+			balance.credit -= balance.debit; balance.debit = 0;
+		}
+		return balance
+	},
 
 	make_summary_row: function(label, item_account) {
 		return {
diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js
index 304947e..99a4bf9 100644
--- a/home/page/latest_updates/latest_updates.js
+++ b/home/page/latest_updates/latest_updates.js
@@ -1,4 +1,11 @@
 erpnext.updates = [
+	["1st January 2013", [
+		"Trial Balance: Added an option to see the report <b>without period closing entry</b>\
+			You will find this checkbox at the bottom of the report.",
+		"General Ledger: Now, on filter of any account group, you will have an option to see \
+			the report <b>grouped by ledgers</b> under that group and with opening \
+			and closing balance for each of them."
+	]],
 	["28th December 2012", [
 		"Workflow: Added System for Multi-level approval before Submission. \
 			<br>See video at <a href='https://www.youtube.com/watch?v=zuGv59_wJKw' \
diff --git a/patches/january_2013/deprecate_stock_search_criteria.py b/patches/january_2013/deprecate_stock_search_criteria.py
new file mode 100644
index 0000000..d51aadb
--- /dev/null
+++ b/patches/january_2013/deprecate_stock_search_criteria.py
@@ -0,0 +1,9 @@
+import webnotes
+
+def execute():
+	for sc in ["itemwise_price_list", "itemwise_receipt_details",
+			"shortage_to_purchase_request", "stock_aging_report",
+			"stock_ledger", "stock_level", "stock_report",
+			"custom_test2", "custom_test3", "custom_test4",
+			"test_so2", "test_so3"]:
+		webnotes.delete_doc("Search Criteria", sc)
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 318ce25..93e5a76 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -578,4 +578,8 @@
 		'patch_module': 'patches.january_2013',
 		'patch_file': 'remove_bad_permissions',
 	},	
+	{
+		'patch_module': 'patches.january_2013',
+		'patch_file': 'deprecate_stock_search_criteria',
+	},
 ]
\ No newline at end of file
diff --git a/setup/page/setup/setup.html b/setup/page/setup/setup.html
index 6cdc02d..33dd460 100644
--- a/setup/page/setup/setup.html
+++ b/setup/page/setup/setup.html
@@ -53,10 +53,6 @@
 				<b><a href="#Trash">Recycle Bin</a></b><br>
 				<span class="help">Un-trash items</span>
 			</p>
-			<p>
-				<b>Rename Master</b><br>
-				<span class="help">Click on "Rename" on the sidebar of an item for renaming.</span>
-			</p>
 		</div>
 		<div class="setup-column">
 			<h3>Email and Notifications</h3>
diff --git a/stock/report/item_wise_price_list/__init__.py b/stock/report/item_wise_price_list/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/stock/report/item_wise_price_list/__init__.py
diff --git a/stock/report/item_wise_price_list/item_wise_price_list.txt b/stock/report/item_wise_price_list/item_wise_price_list.txt
new file mode 100644
index 0000000..4427a5b
--- /dev/null
+++ b/stock/report/item_wise_price_list/item_wise_price_list.txt
@@ -0,0 +1,20 @@
+[
+ {
+  "owner": "Administrator", 
+  "docstatus": 0, 
+  "creation": "2013-01-02 11:56:33", 
+  "modified_by": "Administrator", 
+  "modified": "2013-01-02 12:00:38"
+ }, 
+ {
+  "name": "__common__", 
+  "ref_doctype": "Item", 
+  "doctype": "Report", 
+  "is_standard": "Yes", 
+  "query": "select\n  item.name as \"ID:Link/Item:120\", \n  item.item_name as \"Item Name::120\", \n  item_price.price_list_name as \"Price List::80\",\n  item_price.ref_currency as \"Currency::40\", \n  item_price.ref_rate as \"Rate:Currency:80\",\n  item.description as \"Description::160\",\n  item.item_group as \"Item Group:Link/Item Group:100\",\n  item.brand as \"Brand::100\"\nfrom `tabItem` item, `tabItem Price` item_price\nwhere\n  item_price.parent = item.name"
+ }, 
+ {
+  "name": "Item-Wise Price List", 
+  "doctype": "Report"
+ }
+]
\ No newline at end of file
diff --git a/stock/search_criteria/__init__.py b/stock/search_criteria/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/itemwise_price_list/__init__.py b/stock/search_criteria/itemwise_price_list/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/itemwise_price_list/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/itemwise_price_list/itemwise_price_list.js b/stock/search_criteria/itemwise_price_list/itemwise_price_list.js
deleted file mode 100644
index b19db63..0000000
--- a/stock/search_criteria/itemwise_price_list/itemwise_price_list.js
+++ /dev/null
@@ -1,19 +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.filter_fields_dict['Item'+FILTER_SEP +'ID'].df.in_first_page = 1;
-}
\ No newline at end of file
diff --git a/stock/search_criteria/itemwise_price_list/itemwise_price_list.txt b/stock/search_criteria/itemwise_price_list/itemwise_price_list.txt
deleted file mode 100644
index 9522c83..0000000
--- a/stock/search_criteria/itemwise_price_list/itemwise_price_list.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
-  "owner": "harshada@webnotestech.com", 
-  "docstatus": 0, 
-  "creation": "2012-04-03 12:49:51", 
-  "modified_by": "Administrator", 
-  "modified": "2012-04-03 12:49:51"
- }, 
- {
-  "parent_doc_type": "Item", 
-  "module": "Stock", 
-  "standard": "Yes", 
-  "sort_order": "DESC", 
-  "filters": "{'Item\u0001Saved':1,'Item Price\u0001Price List Name':'','Item Price\u0001Currency':''}", 
-  "doc_type": "Item Price", 
-  "name": "__common__", 
-  "doctype": "Search Criteria", 
-  "sort_by": "`tabItem`.`item_name`", 
-  "page_len": 50, 
-  "criteria_name": "Itemwise Price List", 
-  "columns": "Item\u0001Item Name,Item\u0001Item Group,Item Price\u0001Price List Name,Item Price\u0001Ref Rate,Item Price\u0001Currency"
- }, 
- {
-  "name": "itemwise_price_list", 
-  "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/stock/search_criteria/itemwise_receipt_details/__init__.py b/stock/search_criteria/itemwise_receipt_details/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/itemwise_receipt_details/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/itemwise_receipt_details/itemwise_receipt_details.js b/stock/search_criteria/itemwise_receipt_details/itemwise_receipt_details.js
deleted file mode 100644
index 641c294..0000000
--- a/stock/search_criteria/itemwise_receipt_details/itemwise_receipt_details.js
+++ /dev/null
@@ -1,25 +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.filter_fields_dict['Purchase Receipt'+FILTER_SEP +'From Transaction Date'].df['report_default'] = sys_defaults.year_start_date;
-  this.filter_fields_dict['Purchase Receipt'+FILTER_SEP +'To Transaction Date'].df['report_default'] = dateutil.obj_to_str(new Date());
-  this.filter_fields_dict['Purchase Receipt'+FILTER_SEP +'From Posting Date'].df['report_default'] = sys_defaults.year_start_date;
-  this.filter_fields_dict['Purchase Receipt'+FILTER_SEP +'To Posting Date'].df['report_default'] = dateutil.obj_to_str(new Date());
-  this.filter_fields_dict['Purchase Receipt'+FILTER_SEP +'Company'].df['report_default'] = sys_defaults.company;
-  this.filter_fields_dict['Purchase Receipt'+FILTER_SEP +'Fiscal Year'].df['report_default'] = sys_defaults.fiscal_year;
-
-}
\ No newline at end of file
diff --git a/stock/search_criteria/itemwise_receipt_details/itemwise_receipt_details.txt b/stock/search_criteria/itemwise_receipt_details/itemwise_receipt_details.txt
deleted file mode 100644
index 7d25727..0000000
--- a/stock/search_criteria/itemwise_receipt_details/itemwise_receipt_details.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
-  "owner": "Administrator", 
-  "docstatus": 0, 
-  "creation": "2012-04-11 13:16:55", 
-  "modified_by": "Administrator", 
-  "modified": "2012-04-13 11:16:40"
- }, 
- {
-  "parent_doc_type": "Purchase Receipt", 
-  "module": "Stock", 
-  "standard": "Yes", 
-  "sort_order": "DESC", 
-  "filters": "{\"Purchase Receipt\\u0001Submitted\":1,\"Purchase Receipt\\u0001Status\":[\"\"],\"Purchase Receipt\\u0001Fiscal Year\":[\"\"]}", 
-  "doc_type": "Purchase Receipt Item", 
-  "name": "__common__", 
-  "doctype": "Search Criteria", 
-  "sort_by": "`tabPurchase Receipt`.`name`", 
-  "page_len": 50, 
-  "criteria_name": "Itemwise Receipt Details", 
-  "columns": "Purchase Receipt\u0001ID,Purchase Receipt\u0001Posting Date,Purchase Receipt Item\u0001Item Code,Purchase Receipt Item\u0001Item Name,Purchase Receipt Item\u0001Accepted Quantity,Purchase Receipt Item\u0001Rejected Quantity,Purchase Receipt Item\u0001UOM,Purchase Receipt Item\u0001Accepted Warehouse,Purchase Receipt Item\u0001Rejected Warehouse,Purchase Receipt Item\u0001Amount"
- }, 
- {
-  "name": "itemwise_receipt_details", 
-  "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/stock/search_criteria/shortage_to_purchase_request/__init__.py b/stock/search_criteria/shortage_to_purchase_request/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/shortage_to_purchase_request/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/shortage_to_purchase_request/shortage_to_purchase_request.txt b/stock/search_criteria/shortage_to_purchase_request/shortage_to_purchase_request.txt
deleted file mode 100644
index 81511b7..0000000
--- a/stock/search_criteria/shortage_to_purchase_request/shortage_to_purchase_request.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
-  "owner": "wasim@webnotestech.com", 
-  "docstatus": 0, 
-  "creation": "2012-03-30 14:50:44", 
-  "modified_by": "Administrator", 
-  "modified": "2012-03-30 14:50:44"
- }, 
- {
-  "module": "Stock", 
-  "standard": "Yes", 
-  "sort_order": "DESC", 
-  "filters": "{'Item\u0001Saved':1}", 
-  "doctype": "Search Criteria", 
-  "doc_type": "Item", 
-  "name": "__common__", 
-  "sort_by": "`tabItem`.`name`", 
-  "page_len": 50, 
-  "criteria_name": "Shortage To Purchase Request", 
-  "columns": "Item\u0001ID,Item\u0001Item Name,Item\u0001Description,Item\u0001Lead Time Days"
- }, 
- {
-  "name": "shortage_to_purchase_request", 
-  "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_aging_report/__init__.py b/stock/search_criteria/stock_aging_report/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/stock_aging_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/stock_aging_report/stock_aging_report.js b/stock/search_criteria/stock_aging_report/stock_aging_report.js
deleted file mode 100644
index 8cc73dd..0000000
--- a/stock/search_criteria/stock_aging_report/stock_aging_report.js
+++ /dev/null
@@ -1,28 +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.filter_fields_dict['Serial No'+FILTER_SEP +'Status'].df.filter_hide = 1;
-
-  this.filter_fields_dict['Serial No'+FILTER_SEP +'ID'].df.in_first_page = 1;
-  this.filter_fields_dict['Serial No'+FILTER_SEP +'From Purchase Date'].df.in_first_page = 1;
-  this.filter_fields_dict['Serial No'+FILTER_SEP +'To Purchase Date'].df.in_first_page = 1;
-}
-
-//this.mytabs.items['Select Columns'].hide();
-this.mytabs.items['More Filters'].hide();
\ No newline at end of file
diff --git a/stock/search_criteria/stock_aging_report/stock_aging_report.py b/stock/search_criteria/stock_aging_report/stock_aging_report.py
deleted file mode 100644
index 695ad02..0000000
--- a/stock/search_criteria/stock_aging_report/stock_aging_report.py
+++ /dev/null
@@ -1,32 +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/>.
-
-from __future__ import unicode_literals
-col = [['In Store Period (in days)', 'Data', '']]
-for c in col:
-  colnames.append(str(c[0]))
-  coltypes.append(str(c[1]))
-  colwidths.append('150px')
-  coloptions.append(str(c[2]))
-  col_idx[str(c)] = len(colnames) - 1
-
-import datetime
-for r in res:
-  if r[col_idx['Purchase Date']]:
-    dt = (datetime.date.today() - getdate(r[col_idx['Purchase Date']])).days
-  else:
-    dt = ''
-  r.append(dt)
\ No newline at end of file
diff --git a/stock/search_criteria/stock_aging_report/stock_aging_report.txt b/stock/search_criteria/stock_aging_report/stock_aging_report.txt
deleted file mode 100644
index 61287fa..0000000
--- a/stock/search_criteria/stock_aging_report/stock_aging_report.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-[
- {
-  "owner": "ashwini@webnotestech.com", 
-  "docstatus": 0, 
-  "creation": "2012-04-03 12:49:53", 
-  "modified_by": "Administrator", 
-  "modified": "2012-04-03 12:49:53"
- }, 
- {
-  "module": "Stock", 
-  "standard": "Yes", 
-  "sort_order": "DESC", 
-  "filters": "{'Serial No\u0001Saved':1,'Serial No\u0001Submitted':1,'Serial No\u0001Status':'In Store','Serial No\u0001Maintenance Status':''}", 
-  "doc_type": "Serial No", 
-  "name": "__common__", 
-  "add_cond": "`tabSerial No`.status = 'In Store'", 
-  "doctype": "Search Criteria", 
-  "sort_by": "`tabSerial No`.`name`", 
-  "page_len": 1000, 
-  "criteria_name": "Stock Aging Report", 
-  "columns": "Serial No\u0001ID,Serial No\u0001Item Code,Serial No\u0001Description,Serial No\u0001Item Group,Serial No\u0001Purchase Date"
- }, 
- {
-  "name": "stock_aging_report", 
-  "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_ledger/__init__.py b/stock/search_criteria/stock_ledger/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/stock_ledger/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/stock_ledger/stock_ledger.js b/stock/search_criteria/stock_ledger/stock_ledger.js
deleted file mode 100644
index a47806f..0000000
--- a/stock/search_criteria/stock_ledger/stock_ledger.js
+++ /dev/null
@@ -1,20 +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.add_filter({fieldname:'item_name', label:'Item Name', fieldtype:'Data', options:'', parent:'Item'});
-  this.add_filter({fieldname:'description', label:'Description', fieldtype:'Small Text', options: '', parent:'Item'});
-}
\ No newline at end of file
diff --git a/stock/search_criteria/stock_ledger/stock_ledger.txt b/stock/search_criteria/stock_ledger/stock_ledger.txt
deleted file mode 100644
index 1c9fd8e..0000000
--- a/stock/search_criteria/stock_ledger/stock_ledger.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-[
- {
-  "owner": "Administrator", 
-  "docstatus": 0, 
-  "creation": "2012-09-14 11:30:39", 
-  "modified_by": "Administrator", 
-  "modified": "2012-11-06 10:27:11"
- }, 
- {
-  "add_col": "`tabItem`.`item_name`\n`tabItem`.`description`", 
-  "module": "Stock", 
-  "standard": "Yes", 
-  "sort_order": "ASC", 
-  "add_tab": "`tabItem`", 
-  "doc_type": "Stock Ledger Entry", 
-  "name": "__common__", 
-  "filters": "{\"Stock Ledger Entry\\u0001Warehouse Type\":[],\"Stock Ledger Entry\\u0001Company\":[],\"Stock Ledger Entry\\u0001Is Cancelled\":[\"No\"],\"Stock Ledger Entry\\u0001Is Stock Entry\":[]}", 
-  "add_cond": "`tabItem`.`name` = `tabStock Ledger Entry`.`item_code`", 
-  "doctype": "Search Criteria", 
-  "sort_by": "`tabStock Ledger Entry`.`posting_date`, `tabStock Ledger Entry`.`posting_time`, `tabStock Ledger Entry`.`name`", 
-  "page_len": 50, 
-  "criteria_name": "Stock Ledger", 
-  "columns": "Stock Ledger Entry\u0001Item Code,Stock Ledger Entry\u0001Warehouse,Stock Ledger Entry\u0001Posting Date,Stock Ledger Entry\u0001Posting Time,Stock Ledger Entry\u0001Actual Quantity,Stock Ledger Entry\u0001Bin Actual Qty After Transaction,Stock Ledger Entry\u0001Voucher Type,Stock Ledger Entry\u0001Voucher No"
- }, 
- {
-  "name": "stock_ledger", 
-  "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_level/__init__.py b/stock/search_criteria/stock_level/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/stock_level/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/stock_level/stock_level.js b/stock/search_criteria/stock_level/stock_level.js
deleted file mode 100644
index 4fb744d..0000000
--- a/stock/search_criteria/stock_level/stock_level.js
+++ /dev/null
@@ -1,22 +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.add_filter({fieldname:'item_name', label:'Item Name', fieldtype:'Data', options:'', parent:'Item', in_first_page : 0});
-  this.add_filter({fieldname:'description', label:'Description', fieldtype:'Small Text', options: '', parent:'Item', in_first_page : 0});
-  this.add_filter({fieldname:'item_group', label:'Item Group', fieldtype:'link', options: 'Item Group', parent:'Item', in_first_page : 1});
-  this.add_filter({fieldname:'brand', label:'Brand', fieldtype:'link', options: 'Brand', parent:'Item', in_first_page : 1});
-}
\ No newline at end of file
diff --git a/stock/search_criteria/stock_level/stock_level.py b/stock/search_criteria/stock_level/stock_level.py
deleted file mode 100644
index d53ab5f..0000000
--- a/stock/search_criteria/stock_level/stock_level.py
+++ /dev/null
@@ -1,19 +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/>.
-
-from __future__ import unicode_literals
-colwidths[col_idx['Reserved Quantity']]= "120px" 
-colwidths[col_idx['Ordered Quantity']] = "120px"
\ No newline at end of file
diff --git a/stock/search_criteria/stock_level/stock_level.txt b/stock/search_criteria/stock_level/stock_level.txt
deleted file mode 100644
index b33540c..0000000
--- a/stock/search_criteria/stock_level/stock_level.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-[
- {
-  "owner": "Administrator", 
-  "docstatus": 0, 
-  "creation": "2012-04-03 12:49:53", 
-  "modified_by": "Administrator", 
-  "modified": "2012-04-03 12:49:53"
- }, 
- {
-  "add_col": "`tabItem`.`item_name`\n`tabItem`.`description`", 
-  "module": "Stock", 
-  "standard": "Yes", 
-  "sort_order": "DESC", 
-  "add_tab": "`tabItem`", 
-  "doc_type": "Bin", 
-  "name": "__common__", 
-  "filters": "{}", 
-  "add_cond": "`tabItem`.name = `tabBin`.item_code", 
-  "doctype": "Search Criteria", 
-  "sort_by": "`tabBin`.`warehouse`", 
-  "page_len": 50, 
-  "criteria_name": "Stock Level", 
-  "columns": "Bin\u0001Warehouse,Bin\u0001Item Code,Bin\u0001UOM,Bin\u0001Reserved Quantity,Bin\u0001Actual Quantity,Bin\u0001Ordered Quantity,Bin\u0001Planned Qty,Bin\u0001Projected Qty,Bin\u0001Quantity Requested for Purchase,Bin\u0001Valuation Rate,Bin\u0001Stock Value"
- }, 
- {
-  "name": "stock_level", 
-  "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/stock/search_criteria/stock_report/__init__.py b/stock/search_criteria/stock_report/__init__.py
deleted file mode 100644
index baffc48..0000000
--- a/stock/search_criteria/stock_report/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/stock/search_criteria/stock_report/stock_report.js b/stock/search_criteria/stock_report/stock_report.js
deleted file mode 100644
index d08d1e7..0000000
--- a/stock/search_criteria/stock_report/stock_report.js
+++ /dev/null
@@ -1,89 +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/>.
-
-//233
-report.customize_filters = function() {
-  this.mytabs.items['Select Columns'].hide()
-  this.mytabs.items['More Filters'].hide()
-  this.hide_all_filters();
-  this.add_filter({fieldname:'based_on', label:'Based On', fieldtype:'Select', options:'Warehouse'+NEWLINE+'Item Code',ignore : 1,parent:'Stock Ledger Entry'});
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'To Posting Date'].df.filter_hide = 0;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Item Code'].df.filter_hide = 0;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.filter_hide = 0;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse Type'].df.filter_hide = 0;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'From Posting Date'].df.filter_hide = 1;
-
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Item Code'].df.in_first_page = 1;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse'].df.in_first_page = 1;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Based On'].df.in_first_page = 1;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'Warehouse Type'].df.in_first_page = 1;
-  this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP +'To Posting Date'].df.in_first_page = 1;
-}
-
-
-report.get_query = function(){
-  based_on = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Based On'].get_value();
-  as_on = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'To Posting Date'].get_value();
-  warehouse = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Warehouse'].get_value();
-  warehouse_type = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Warehouse Type'].get_value();
-  item_code = this.filter_fields_dict['Stock Ledger Entry'+FILTER_SEP+'Item Code'].get_value();
-
-  cond = '';
-  date_cond = '';
-  tables = '';
-  cols = '';
-  group_by = '';
-  ware_type_cond = '';
-  war = '';
-  if(!as_on) as_on = get_today();
-
-  date_cond = repl(' AND `tabStock Ledger Entry`.posting_date <= "%(as_on)s" ', {as_on:as_on});
-
-  if(warehouse_type.length > 0 && warehouse_type != ''){
-    for(var i = 0; i<warehouse_type.length; i++) war += "'"+warehouse_type[i]+"',";
-    ware_type_cond = repl(' AND `tabWarehouse`.warehouse_type IN (%(war)s)', {war: war.substr(0,war.length-1)})
-  }
-  
-  if(based_on.length == 1 && based_on[0]){
-    if(based_on[0] == 'Item Code'){
-      cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM"';
-      cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes"';
-      if(item_code) cond += repl(' AND `tabItem`.name = %(item)s', {item:'"'+item_code+'"'});
-      cond += ' AND `tabStock Ledger Entry`.item_code = `tabItem`.name'
-      tables = '`tabItem`';
-      group_by = '`tabStock Ledger Entry`.item_code';
-    }
-    else if(based_on[0] == 'Warehouse'){
-      cols = '`tabWarehouse`.name AS "Warehouse", `tabWarehouse`.warehouse_type AS "Warehouse Type"';
-      cond = '`tabWarehouse`.docstatus < 2'
-      if(warehouse) cond += repl(' AND `tabWarehouse`.name = %(warehouse)s', {warehouse:'"'+warehouse+'"'});
-      cond += repl(' AND `tabStock Ledger Entry`.warehouse = `tabWarehouse`.name %(ware_type_cond)s', {ware_type_cond:ware_type_cond})
-      tables = '`tabWarehouse`';
-      group_by = '`tabStock Ledger Entry`.warehouse';
-    }
-  } else {
-    cols = '`tabItem`.name AS "Item Code", `tabItem`.item_name AS "Item Name", `tabItem`.description AS "Description", `tabItem`.stock_uom AS "Stock UOM", `tabWarehouse`.name AS "Warehouse",  `tabWarehouse`.warehouse_type AS "Warehouse Type"';
-    cond = '(IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` = "0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND `tabItem`.is_stock_item = "Yes" AND `tabWarehouse`.docstatus < 2';
-    if(item_code) cond += repl(" AND `tabItem`.name = %(item)s", {item:"'"+item_code+"'"});
-    if(warehouse) cond += repl(" AND `tabWarehouse`.name = %(warehouse)s", {warehouse:"'"+warehouse+"'"});
-    cond += repl(' AND `tabStock Ledger Entry`.item_code = `tabItem`.name AND `tabStock Ledger Entry`.warehouse = `tabWarehouse`.name %(ware_type_cond)s', {ware_type_cond:ware_type_cond})
-    tables = '`tabItem`, `tabWarehouse`';
-    group_by = '`tabStock Ledger Entry`.item_code, `tabStock Ledger Entry`.warehouse';
-  }
-
-  q = repl("SELECT %(cols)s FROM %(tables)s, `tabStock Ledger Entry` WHERE %(cond)s %(date_cond)s GROUP BY %(group_by)s", {cols:cols, tables:tables, cond:cond, date_cond:date_cond, group_by:group_by});
-  return q;
-}
diff --git a/stock/search_criteria/stock_report/stock_report.py b/stock/search_criteria/stock_report/stock_report.py
deleted file mode 100644
index 970141a..0000000
--- a/stock/search_criteria/stock_report/stock_report.py
+++ /dev/null
@@ -1,88 +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/>.
-
-from __future__ import unicode_literals
-cols, columns = [], []
-# Add columns
-# ------------
-based_on = filter_values.get('based_on').split(NEWLINE)
-if len(based_on) == 1 and based_on[0]:
-  if based_on[0] == 'Item Code':
-    cols = ["Item Code", "Item Name", "Description", "Stock UOM"]
-  elif based_on[0] == 'Warehouse':
-    cols = ["Warehouse", "Warehouse Type"]
-else:
-  cols = ["Item Code", "Item Name", "Description", "Stock UOM", "Warehouse",  "Warehouse Type"]
-
-for d in cols:
-  columns.append([d,'Data','150px',''])
-
-columns.append(['Closing Balance','Currency','200px',''])
-columns.append(['Stock Value','Currency','150px',''])
-
-posting_date = filter_values.get('posting_date1')
-if not posting_date: posting_date = nowdate()
-
-for c in columns:
-  colnames.append(c[0])
-  coltypes.append(c[1])
-  colwidths.append(c[2])
-  coloptions.append(c[3])
-  col_idx[c[0]] = len(colnames)-1
-  
-def get_values(msgprint, flt, posting_date, item_code = '', warehouse = ''):
-  cl_bal, stock_val = 0,0
-  if item_code and not warehouse:
-    war_list = sql("select distinct warehouse from `tabStock Ledger Entry` where item_code = %s", item_code)
-    for d in war_list:
-      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (item_code, d[0], posting_date, '23:55'))
-      cl_bal += act and flt(act[0][0]) or 0.00
-      stock_val += act and flt(act[0][1]) or 0.00
-  elif warehouse and not item_code:
-    item_list = sql("select distinct item_code from `tabStock Ledger Entry` where warehouse = %s", warehouse)
-    for d in item_list:
-      act = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (d[0], warehouse, posting_date, '23:55'))
-      cl_bal += act and flt(act[0][0]) or 0.00
-      stock_val += act and flt(act[0][1]) or 0.00
-  return cl_bal, stock_val
-
-out=[]
-cl_bal,tot_stock = 0,0
-  
-for r in res:
-  if len(based_on) == 1 and based_on[0]:
-    if based_on[0] == 'Item Code': closing_balance, stock_value = get_values(msgprint, flt, posting_date, item_code = r[col_idx['Item Code']])
-    elif based_on[0] == 'Warehouse': closing_balance, stock_value = get_values(msgprint, flt, posting_date, warehouse = r[col_idx['Warehouse']])
-    r.append(closing_balance)
-    r.append(stock_value)
-  else:
-    det = sql("select bin_aqat, stock_value from `tabStock Ledger Entry` where item_code = %s and warehouse = %s and ifnull(is_cancelled, 'No') = 'No' and timestamp(posting_date, posting_time) <= timestamp(%s, %s) Order by timestamp(posting_date, posting_time) DESC, name DESC LIMIT 1", (r[col_idx['Item Code']], r[col_idx['Warehouse']], posting_date, '23:55'))
-    
-    r.append(det and flt(det[0][0]) or 0.00)
-    r.append(det and flt(det[0][1]) or 0.00)
-  cl_bal += flt(r[col_idx['Closing Balance']])
-  tot_stock += flt(r[col_idx['Stock Value']])
-  out.append(r)
-
-# Add the totals row
-l_row = ['' for i in range(len(colnames))]
-if len(based_on) == 1 and based_on[0] == 'Warehouse':
-  l_row[col_idx['Warehouse Type']] = '<b>TOTALS</b>'
-else:
-  l_row[col_idx['Stock UOM']] = '<b>TOTALS</b>'
-l_row[col_idx['Closing Balance']] = cl_bal
-l_row[col_idx['Stock Value']] = tot_stock
-out.append(l_row)
diff --git a/stock/search_criteria/stock_report/stock_report.txt b/stock/search_criteria/stock_report/stock_report.txt
deleted file mode 100644
index bb64f54..0000000
--- a/stock/search_criteria/stock_report/stock_report.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-[
- {
-  "owner": "Administrator", 
-  "docstatus": 0, 
-  "creation": "2012-04-03 12:49:53", 
-  "modified_by": "Administrator", 
-  "modified": "2012-04-03 12:49:53"
- }, 
- {
-  "module": "Stock", 
-  "standard": "Yes", 
-  "sort_order": "DESC", 
-  "filters": "{'Stock Ledger Entry\u0001Is Cancelled':'','Stock Ledger Entry\u0001Is Stock Entry':''}", 
-  "doctype": "Search Criteria", 
-  "doc_type": "Stock Ledger Entry", 
-  "name": "__common__", 
-  "sort_by": "`tabStock Ledger Entry`.`name`", 
-  "page_len": 50, 
-  "criteria_name": "Stock Report", 
-  "columns": "Stock Ledger Entry\u0001ID"
- }, 
- {
-  "name": "stock_report", 
-  "doctype": "Search Criteria"
- }
-]
\ No newline at end of file
diff --git a/support/doctype/newsletter/newsletter.js b/support/doctype/newsletter/newsletter.js
index 1f75edc..69a55ef 100644
--- a/support/doctype/newsletter/newsletter.js
+++ b/support/doctype/newsletter/newsletter.js
@@ -16,11 +16,17 @@
 
 cur_frm.cscript.refresh = function(doc) {
 	erpnext.hide_naming_series();
-	if(!doc.__islocal && !cint(doc.email_sent) && !doc.__unsaved) {
+	if(!doc.__islocal && !cint(doc.email_sent) && !doc.__unsaved
+			&& inList(wn.boot.profile.can_write, doc.doctype)) {
 		cur_frm.add_custom_button('Send', function() {
 			$c_obj(make_doclist(doc.doctype, doc.name), 'send_emails', '', function(r) {
 				cur_frm.refresh();
 			});
 		})
 	}
+
+	if(doc.__islocal && !doc.send_from) {
+		cur_frm.set_value("send_from", 
+			repl("%(fullname)s <%(email)s>", wn.user_info(doc.owner)));
+	}
 }
\ No newline at end of file
diff --git a/support/doctype/newsletter/newsletter.py b/support/doctype/newsletter/newsletter.py
index 536b649..c4b622a 100644
--- a/support/doctype/newsletter/newsletter.py
+++ b/support/doctype/newsletter/newsletter.py
@@ -20,6 +20,7 @@
 import webnotes.utils
 from webnotes.utils import cstr
 from webnotes.model.doc import Document
+from webnotes import _
 
 class DocType():
 	def __init__(self, d, dl):
@@ -51,7 +52,7 @@
 		"""send emails to leads and customers"""
 		if self.doc.email_sent:
 			webnotes.msgprint("""Newsletter has already been sent""", raise_exception=1)
-		
+
 		self.all_recipients = []
 		self.send_count = {}
 		
@@ -82,8 +83,11 @@
 			", ".join(["%d %s(s)" % (self.send_count[s], s) for s in self.send_count]))
 			
 	def test_send(self, doctype="Lead"):
+		self.validate_send()
+
 		args = self.dt_map[doctype]
-		sender = webnotes.utils.get_email_id(self.doc.owner)
+
+		sender = self.doc.send_from or 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, 
@@ -98,12 +102,14 @@
 		return recipients
 		
 	def send(self, query_key, doctype):
+		self.validate_send()
+
 		webnotes.conn.auto_commit_on_many_writes = True
 		if isinstance(query_key, basestring) and self.query_map.has_key(query_key):
 			recipients = self.get_recipients(query_key)
 		else:
 			recipients = query_key
-		sender = webnotes.utils.get_email_id(self.doc.owner)
+		sender = self.doc.send_from or 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)
@@ -112,7 +118,17 @@
 		send(recipients = recipients, sender = sender, 
 			subject = self.doc.subject, message = self.doc.message,
 			doctype = doctype, email_field = args["email_field"])
-			
+
+	def validate_send(self):
+		if self.doc.fields.get("__islocal"):
+			webnotes.msgprint(_("""Please save the Newsletter before sending."""),
+				raise_exception=1)
+
+		import conf
+		if getattr(conf, "status", None) == "Trial":
+			webnotes.msgprint(_("""Sending newsletters is not allowed for Trial users, \
+				to prevent abuse of this feature."""), raise_exception=1)
+
 lead_naming_series = None
 def create_lead(email_id):
 	"""create a lead if it does not exist"""
diff --git a/support/doctype/newsletter/newsletter.txt b/support/doctype/newsletter/newsletter.txt
index 68fbabb..04701e8 100644
--- a/support/doctype/newsletter/newsletter.txt
+++ b/support/doctype/newsletter/newsletter.txt
@@ -2,9 +2,9 @@
  {
   "owner": "Administrator", 
   "docstatus": 0, 
-  "creation": "2012-12-07 15:15:31", 
+  "creation": "2013-01-01 13:46:34", 
   "modified_by": "Administrator", 
-  "modified": "2013-01-01 10:54:40"
+  "modified": "2013-01-02 13:47:36"
  }, 
  {
   "autoname": "naming_series:", 
@@ -108,6 +108,15 @@
   "permlevel": 0
  }, 
  {
+  "description": "If specified, send the newsletter using this email address", 
+  "no_copy": 1, 
+  "doctype": "DocField", 
+  "label": "Send From", 
+  "fieldname": "send_from", 
+  "fieldtype": "Data", 
+  "permlevel": 0
+ }, 
+ {
   "doctype": "DocField", 
   "label": "Subject", 
   "fieldname": "subject",