Merge branch 'master' of github.com:webnotes/erpnext into unicode

Conflicts:
	erpnext/patches/july_2012/repost_stock_due_to_wrong_packing_list.py
diff --git a/erpnext/buying/page/buying_home/buying_home.html b/erpnext/buying/page/buying_home/buying_home.html
index cd9312c..c2eead1 100644
--- a/erpnext/buying/page/buying_home/buying_home.html
+++ b/erpnext/buying/page/buying_home/buying_home.html
@@ -5,7 +5,7 @@
 			<h4><a href="#!List/Purchase Request">Purchase Request</a></h4>
 			<p class="help">Request for purchase</p>
 			<br>
-			<h4><a href="#!List/Supplier Quotation">Supplier Quotation</a></h4>
+			<h4><a href="#!List/Supplier Quotation">Supplier Quotation (beta)</a></h4>
 			<p class="help">Track Quotations received from Suppliers</p>
 			<br>
 			<h4><a href="#!List/Purchase Order">Purchase Order</a></h4>
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 ba818ec..51976d0 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
@@ -1,24 +1,48 @@
 from __future__ import unicode_literals
+import webnotes
+
+def execute():
+	# add index
+	webnotes.conn.commit()
+	try:
+		webnotes.conn.sql("""create index item_code_warehouse
+			on `tabDelivery Note Packing Item` (item_code, warehouse)""")
+	except:
+		pass
+	webnotes.conn.begin()
+
+	repost_reserved_qty()
+	cleanup_wrong_sle()
+
 def repost_reserved_qty():
-	import webnotes
 	from webnotes.utils import flt
 	bins = webnotes.conn.sql("select item_code, warehouse, name, reserved_qty from `tabBin`")
+	i = 0
 	for d in bins:
+		i += 1
+		print i
 		reserved_qty = webnotes.conn.sql("""
-			select sum((dnpi.qty/so_item.qty)*(so_item.qty - ifnull(so_item.delivered_qty, 0))) 
-			
-			from `tabDelivery Note Packing Item` dnpi, `tabSales Order Item` so_item, `tabSales Order` so
-			
-			where dnpi.item_code = %s
-			and dnpi.warehouse = %s
-			and dnpi.parent = so.name
-			and so_item.parent = so.name
-			and dnpi.parenttype = 'Sales Order'
-			and dnpi.parent_detail_docname = so_item.name
-			and dnpi.parent_item = so_item.item_code
-			and so.docstatus = 1
-			and so.status != 'Stopped'
-		""", (d[0], d[1]))
+			select sum((dnpi_qty / so_item_qty) * (so_item_qty - so_item_delivered_qty))
+			from (select
+			qty as dnpi_qty,
+			(
+				select qty from `tabSales Order Item`
+				where name = dnpi.parent_detail_docname
+			) as so_item_qty,
+			(
+				select ifnull(delivered_qty, 0) from `tabSales Order Item`
+				where name = dnpi.parent_detail_docname
+			) as so_item_delivered_qty
+			from 
+			(
+				select qty, parent_detail_docname
+				from `tabDelivery Note Packing Item` dnpi_in
+				where item_code = %s and warehouse = %s
+				and parenttype="Sales Order"
+				and exists (select * from `tabSales Order` so
+				where name = dnpi_in.parent and docstatus = 1 and status != 'Stopped')
+			) dnpi) tab""", (d[0], d[1]))
+
 		if flt(d[3]) != flt(reserved_qty[0][0]):
 			print d[3], reserved_qty[0][0]
 			webnotes.conn.sql("""
@@ -52,9 +76,6 @@
 def create_comment(dn):
 	from webnotes.model.doc import Document
 	cmt = Document('Comment')
-	for arg in ['comment', 'comment_by', 'comment_by_fullname', 'comment_doctype', \
-		'comment_docname']:
-		cmt.fields[arg] = args[arg]
 	cmt.comment = 'Cancelled by administrator due to wrong entry in packing list'
 	cmt.comment_by = 'Administrator'
 	cmt.comment_by_fullname = 'Administrator'
@@ -69,8 +90,3 @@
 		where item_code = %s and warehouse = %s", (item, wh))
 			
 	get_obj('Bin', bin[0][0]).update_entries_after(posting_date = '2012-07-01', posting_time = '12:05')
-	
-	
-def execute():
-	repost_reserved_qty()
-	cleanup_wrong_sle()
diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py
index 38b22e8..d06c2f5 100644
--- a/erpnext/patches/patch_list.py
+++ b/erpnext/patches/patch_list.py
@@ -533,4 +533,8 @@
 		'patch_module': 'patches.july_2012',
 		'patch_file': 'project_patch_repeat',
 	},
+	{
+		'patch_module': 'patches.july_2012',
+		'patch_file': 'repost_stock_due_to_wrong_packing_list',
+	},
 ]
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 6a3914f..85069ef 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -67,7 +67,7 @@
 
 			if cstr(d.uom) == cstr(self.doc.stock_uom):
 				if flt(d.conversion_factor) != 1:
-					msgprint("Conversion Fator of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
+					msgprint("Conversion Factor of UOM : %s should be equal to 1. As UOM : %s is Stock UOM of Item: %s." % ( cstr(d.uom), cstr(d.uom), cstr(self.doc.name)))
 					raise Exception
 				# else set uom_exist as true
 				uom_exist='true'
diff --git a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
index 89fbe27..41a60d7 100644
--- a/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
+++ b/erpnext/stock/doctype/stock_uom_replace_utility/stock_uom_replace_utility.py
@@ -45,10 +45,6 @@
     if not cstr(self.doc.item_code):
       msgprint("Please Enter an Item.")
       raise Exception
-
-    if not cstr(self.doc.current_stock_uom):
-      msgprint("There is no Current Stock UOM for Item Code" + cstr(self.doc.item_code))
-      raise Exception
     
     if not cstr(self.doc.new_stock_uom):
       msgprint("Please Enter New Stock UOM.")
@@ -119,4 +115,6 @@
     self.update_stock_ledger_entry()
     
     # update bin
-    self.update_bin()
\ No newline at end of file
+    self.update_bin()
+
+	get_obj("Item", self.doc.item_code).on_update()
diff --git a/erpnext/support/doctype/communication/communication.txt b/erpnext/support/doctype/communication/communication.txt
index bb69e6e..d504476 100644
--- a/erpnext/support/doctype/communication/communication.txt
+++ b/erpnext/support/doctype/communication/communication.txt
@@ -3,9 +3,9 @@
 
 	# These values are common in all dictionaries
 	{
-		'creation': '2012-06-07 11:02:55',
+		'creation': '2012-06-26 11:58:13',
 		'docstatus': 0,
-		'modified': '2012-06-07 11:24:20',
+		'modified': '2012-08-03 16:10:35',
 		'modified_by': u'Administrator',
 		'owner': u'Administrator'
 	},
@@ -15,6 +15,7 @@
 		'allow_attach': 1,
 		'description': u'Keep a track of all communications',
 		'doctype': 'DocType',
+		'document_type': u'Master',
 		'module': u'Support',
 		'name': '__common__',
 		'version': 1
@@ -86,7 +87,7 @@
 
 	# DocPerm
 	{
-		'cancel': 0,
+		'cancel': 1,
 		'create': 0,
 		'doctype': u'DocPerm',
 		'permlevel': 1,
@@ -99,16 +100,7 @@
 		'create': 1,
 		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': u'Administrator'
-	},
-
-	# DocPerm
-	{
-		'cancel': 0,
-		'create': 0,
-		'doctype': u'DocPerm',
-		'permlevel': 1,
-		'role': u'Administrator'
+		'role': u'Support Manager'
 	},
 
 	# DocField