-webnotes +frappe :boom:
diff --git a/erpnext/utilities/__init__.py b/erpnext/utilities/__init__.py
index b047537..e3a1e7f 100644
--- a/erpnext/utilities/__init__.py
+++ b/erpnext/utilities/__init__.py
@@ -15,9 +15,9 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 from __future__ import unicode_literals
-import webnotes
-from webnotes import _, msgprint
-from webnotes.utils import cint, comma_or
+import frappe
+from frappe import _, msgprint
+from frappe.utils import cint, comma_or
 
 def validate_status(status, options):
 	if status not in options:
diff --git a/erpnext/utilities/cleanup_data.py b/erpnext/utilities/cleanup_data.py
index 630a54e..9b1988e 100644
--- a/erpnext/utilities/cleanup_data.py
+++ b/erpnext/utilities/cleanup_data.py
@@ -16,7 +16,7 @@
 sys.path.append(".")
 sys.path.append("erpnext")
 
-import webnotes
+import frappe
 
 #--------------------------------
 
@@ -34,9 +34,9 @@
 		"Job Applicant", "Web Page", "Website Slideshow", "Blog Post", "Blog Category", "Blogger", 
 		"Time Log", "Time Log Batch", "Workflow"]
 	for d in trans:
-		for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
-			webnotes.conn.sql("delete from `tab%s`" % (t))
-		webnotes.conn.sql("delete from `tab%s`" % (d))
+		for t in frappe.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
+			frappe.conn.sql("delete from `tab%s`" % (t))
+		frappe.conn.sql("delete from `tab%s`" % (d))
 		print "Deleted " + d
 	
 	
@@ -95,18 +95,18 @@
 		'BOM': ''
 	}
 	for d in masters.keys():
-		for t in webnotes.conn.sql("select options from tabDocField where parent='%s' \
+		for t in frappe.conn.sql("select options from tabDocField where parent='%s' \
 			and fieldtype='Table'" % d):
-			webnotes.conn.sql("delete from `tab%s`" % (t))
+			frappe.conn.sql("delete from `tab%s`" % (t))
 		lst = '"'+'","'.join(masters[d])+ '"'
-		webnotes.conn.sql("delete from `tab%s` where name not in (%s)" % (d, lst))
+		frappe.conn.sql("delete from `tab%s` where name not in (%s)" % (d, lst))
 		print "Deleted " + d
 
 
 
 def reset_all_series():
 	# Reset master series
-	webnotes.conn.sql("""update tabSeries set current = 0 where name not in 
+	frappe.conn.sql("""update tabSeries set current = 0 where name not in 
 		('Ann/', 'BSD', 'DEF', 'DF', 'EV', 'Event Updates/', 'FileData-', 
 		'FL', 'FMD/', 'GLM Detail', 'Login Page/', 'MDI', 'MDR', 'MI', 'MIR', 
 		'PERM', 'PR', 'SRCH/C/', 'TD', 'TIC/', 'TMD/', 'TW', 'UR', '_FEED', 
@@ -115,7 +115,7 @@
 	print "Series updated"
 		
 def reset_transaction_series():
-	webnotes.conn.sql("""update tabSeries set current = 0 where name in 
+	frappe.conn.sql("""update tabSeries set current = 0 where name in 
 		('JV', 'INV', 'BILL', 'SO', 'DN', 'PO', 'LEAD', 'ENQUIRY', 'ENQ', 'CI',
 		 'IN', 'PS', 'IDT', 'QAI', 'QTN', 'STE', 'SQTN', 'SUP', 'SR', 
 		'POS', 'LAP', 'LAL', 'EXP')""")
@@ -125,9 +125,9 @@
 def delete_main_masters():
 	main_masters = ['Fiscal Year', 'Company', 'DefaultValue']
 	for d in main_masters:
-		for t in webnotes.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
-			webnotes.conn.sql("delete from `tab%s`" % (t))
-		webnotes.conn.sql("delete from `tab%s`" % (d))
+		for t in frappe.conn.sql("select options from tabDocField where parent='%s' and fieldtype='Table'" % d):
+			frappe.conn.sql("delete from `tab%s`" % (t))
+		frappe.conn.sql("delete from `tab%s`" % (d))
 		print "Deleted " + d
 
 def reset_global_defaults():
@@ -152,18 +152,18 @@
 		'default_price_list_currency': None,
 	}
 
-	from webnotes.model.code import get_obj
+	from frappe.model.code import get_obj
 	gd = get_obj('Global Defaults', 'Global Defaults')
 	for d in flds:
 		gd.doc.fields[d] = flds[d]
 	gd.doc.save()
 	
-	webnotes.clear_cache()
+	frappe.clear_cache()
 
 
 def run():
-	webnotes.connect()
-	webnotes.conn.begin()
+	frappe.connect()
+	frappe.conn.begin()
 	
 	# Confirmation from user
 	confirm = ''
@@ -195,8 +195,8 @@
 		reset_global_defaults()
 
 	print "System cleaned up succesfully"
-	webnotes.conn.commit()
-	webnotes.conn.close()
+	frappe.conn.commit()
+	frappe.conn.close()
 
 
 if __name__ == '__main__':
diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py
index e450d84..988cbd2 100644
--- a/erpnext/utilities/doctype/address/address.py
+++ b/erpnext/utilities/doctype/address/address.py
@@ -2,10 +2,10 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import webnotes
+import frappe
 
-from webnotes import msgprint, throw, _
-from webnotes.utils import cstr, cint
+from frappe import msgprint, throw, _
+from frappe.utils import cstr, cint
 
 class DocType:
 	def __init__(self, doc, doclist=[]):
@@ -34,7 +34,7 @@
 		elif self.doc.is_shipping_address != 1:
 			for fieldname in ["customer", "supplier", "sales_partner", "lead"]:
 				if self.doc.fields.get(fieldname):
-					if not webnotes.conn.sql("""select name from `tabAddress` where is_primary_address=1
+					if not frappe.conn.sql("""select name from `tabAddress` where is_primary_address=1
 						and `%s`=%s and name!=%s""" % (fieldname, "%s", "%s"), 
 						(self.doc.fields[fieldname], self.doc.name)):
 							self.doc.is_primary_address = 1
@@ -48,16 +48,16 @@
 	def _unset_other(self, is_address_type):
 		for fieldname in ["customer", "supplier", "sales_partner", "lead"]:
 			if self.doc.fields.get(fieldname):
-				webnotes.conn.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" %
+				frappe.conn.sql("""update `tabAddress` set `%s`=0 where `%s`=%s and name!=%s""" %
 					(is_address_type, fieldname, "%s", "%s"), (self.doc.fields[fieldname], self.doc.name))
 				break
 
-@webnotes.whitelist()
+@frappe.whitelist()
 def get_address_display(address_dict):
 	if not isinstance(address_dict, dict):
-		address_dict = webnotes.conn.get_value("Address", address_dict, "*", as_dict=True) or {}
+		address_dict = frappe.conn.get_value("Address", address_dict, "*", as_dict=True) or {}
 	
-	meta = webnotes.get_doctype("Address")
+	meta = frappe.get_doctype("Address")
 	sequence = (("", "address_line1"), 
 		("\n", "address_line2"), 
 		("\n", "city"),
diff --git a/erpnext/utilities/doctype/contact/contact.js b/erpnext/utilities/doctype/contact/contact.js
index 3d3e556..eb7681f 100644
--- a/erpnext/utilities/doctype/contact/contact.js
+++ b/erpnext/utilities/doctype/contact/contact.js
@@ -4,8 +4,8 @@
 {% include 'controllers/js/contact_address_common.js' %};
 
 cur_frm.cscript.refresh = function(doc) {
-	cur_frm.communication_view = new wn.views.CommunicationList({
-		list: wn.model.get("Communication", {"parent": doc.name, "parenttype": "Contact"}),
+	cur_frm.communication_view = new frappe.views.CommunicationList({
+		list: frappe.model.get("Communication", {"parent": doc.name, "parenttype": "Contact"}),
 		parent: cur_frm.fields_dict.communication_html.wrapper,
 		doc: doc,
 		recipients: doc.email_id
diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py
index 2abd0dc..2b9c8ca 100644
--- a/erpnext/utilities/doctype/contact/contact.py
+++ b/erpnext/utilities/doctype/contact/contact.py
@@ -2,8 +2,8 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import webnotes
-from webnotes.utils import cstr, extract_email_id
+import frappe
+from frappe.utils import cstr, extract_email_id
 
 from erpnext.controllers.status_updater import StatusUpdater
 
@@ -30,29 +30,29 @@
 	def validate_primary_contact(self):
 		if self.doc.is_primary_contact == 1:
 			if self.doc.customer:
-				webnotes.conn.sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
+				frappe.conn.sql("update tabContact set is_primary_contact=0 where customer = '%s'" % (self.doc.customer))
 			elif self.doc.supplier:
-				webnotes.conn.sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))	
+				frappe.conn.sql("update tabContact set is_primary_contact=0 where supplier = '%s'" % (self.doc.supplier))	
 			elif self.doc.sales_partner:
-				webnotes.conn.sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
+				frappe.conn.sql("update tabContact set is_primary_contact=0 where sales_partner = '%s'" % (self.doc.sales_partner))
 		else:
 			if self.doc.customer:
-				if not webnotes.conn.sql("select name from tabContact where is_primary_contact=1 and customer = '%s'" % (self.doc.customer)):
+				if not frappe.conn.sql("select name from tabContact where is_primary_contact=1 and customer = '%s'" % (self.doc.customer)):
 					self.doc.is_primary_contact = 1
 			elif self.doc.supplier:
-				if not webnotes.conn.sql("select name from tabContact where is_primary_contact=1 and supplier = '%s'" % (self.doc.supplier)):
+				if not frappe.conn.sql("select name from tabContact where is_primary_contact=1 and supplier = '%s'" % (self.doc.supplier)):
 					self.doc.is_primary_contact = 1
 			elif self.doc.sales_partner:
-				if not webnotes.conn.sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
+				if not frappe.conn.sql("select name from tabContact where is_primary_contact=1 and sales_partner = '%s'" % (self.doc.sales_partner)):
 					self.doc.is_primary_contact = 1
 
 	def on_trash(self):
-		webnotes.conn.sql("""update `tabSupport Ticket` set contact='' where contact=%s""",
+		frappe.conn.sql("""update `tabSupport Ticket` set contact='' where contact=%s""",
 			self.doc.name)
 
-@webnotes.whitelist()
+@frappe.whitelist()
 def get_contact_details(contact):
-	contact = webnotes.doc("Contact", contact)
+	contact = frappe.doc("Contact", contact)
 	out = {
 		"contact_person": contact.get("name"),
 		"contact_display": " ".join(filter(None, 
diff --git a/erpnext/utilities/doctype/note/note.py b/erpnext/utilities/doctype/note/note.py
index 0ae23a2..50afa7e 100644
--- a/erpnext/utilities/doctype/note/note.py
+++ b/erpnext/utilities/doctype/note/note.py
@@ -4,7 +4,7 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import webnotes
+import frappe
 
 class DocType:
 	def __init__(self, d, dl):
@@ -16,13 +16,13 @@
 		self.doc.name = re.sub("[%'\"#*?`]", "", self.doc.title.strip())
 		
 	def onload(self):
-		if not self.doc.public and webnotes.session.user != self.doc.owner:
-			if webnotes.session.user not in [d.user for d in self.doclist if d.doctype=="Note User"]:
-				webnotes.msgprint("You are not authorized to read this record.", raise_exception=True)
+		if not self.doc.public and frappe.session.user != self.doc.owner:
+			if frappe.session.user not in [d.user for d in self.doclist if d.doctype=="Note User"]:
+				frappe.msgprint("You are not authorized to read this record.", raise_exception=True)
 	
 	def validate(self):
 		if not self.doc.fields.get("__islocal"):
-			if webnotes.session.user != self.doc.owner:
-				if webnotes.session.user not in webnotes.conn.sql_list("""select user from `tabNote User` 
+			if frappe.session.user != self.doc.owner:
+				if frappe.session.user not in frappe.conn.sql_list("""select user from `tabNote User` 
 					where parent=%s and permission='Edit'""", self.doc.name):
-					webnotes.msgprint("You are not authorized to edit this record.", raise_exception=True)
+					frappe.msgprint("You are not authorized to edit this record.", raise_exception=True)
diff --git a/erpnext/utilities/doctype/note_user/note_user.py b/erpnext/utilities/doctype/note_user/note_user.py
index e5468e5..968a25b 100644
--- a/erpnext/utilities/doctype/note_user/note_user.py
+++ b/erpnext/utilities/doctype/note_user/note_user.py
@@ -4,7 +4,7 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import webnotes
+import frappe
 
 class DocType:
 	def __init__(self, d, dl):
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.js b/erpnext/utilities/doctype/rename_tool/rename_tool.js
index 90cd1e1..1338c0e 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.js
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.js
@@ -2,7 +2,7 @@
 // License: GNU General Public License v3. See license.txt
 
 cur_frm.cscript.refresh = function(doc) {
-	return wn.call({
+	return frappe.call({
 		method: "erpnext.utilities.doctype.rename_tool.rename_tool.get_doctypes",
 		callback: function(r) {
 			cur_frm.set_df_property("select_doctype", "options", r.message);
@@ -19,12 +19,12 @@
 	var me = this;
 	var $wrapper = $(cur_frm.fields_dict.upload_html.wrapper).empty()
 		.html("<hr><div class='alert alert-warning'>" +
-			wn._("Upload a .csv file with two columns: the old name and the new name. Max 500 rows.")
+			frappe._("Upload a .csv file with two columns: the old name and the new name. Max 500 rows.")
 			+ "</div>");
 	var $log = $(cur_frm.fields_dict.rename_log.wrapper).empty();
 
 	// upload
-	wn.upload.make({
+	frappe.upload.make({
 		parent: $wrapper,
 		args: {
 			method: 'utilities.doctype.rename_tool.rename_tool.upload',
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.py b/erpnext/utilities/doctype/rename_tool/rename_tool.py
index f38b8d1..b642282 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.py
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py
@@ -4,38 +4,38 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-import webnotes
-from webnotes import _
+import frappe
+from frappe import _
 
 class DocType:
 	def __init__(self, d, dl):
 		self.doc, self.doclist = d, dl
 		
-@webnotes.whitelist()
+@frappe.whitelist()
 def get_doctypes():
-	return webnotes.conn.sql_list("""select name from tabDocType
+	return frappe.conn.sql_list("""select name from tabDocType
 		where ifnull(allow_rename,0)=1 and module!='Core' order by name""")
 		
-@webnotes.whitelist()
+@frappe.whitelist()
 def upload(select_doctype=None, rows=None):
-	from webnotes.utils.datautils import read_csv_content_from_uploaded_file
-	from webnotes.modules import scrub
-	from webnotes.model.rename_doc import rename_doc
+	from frappe.utils.datautils import read_csv_content_from_uploaded_file
+	from frappe.modules import scrub
+	from frappe.model.rename_doc import rename_doc
 
 	if not select_doctype:
-		select_doctype = webnotes.form_dict.select_doctype
+		select_doctype = frappe.form_dict.select_doctype
 		
-	if not webnotes.has_permission(select_doctype, "write"):
-		raise webnotes.PermissionError
+	if not frappe.has_permission(select_doctype, "write"):
+		raise frappe.PermissionError
 
 	if not rows:
 		rows = read_csv_content_from_uploaded_file()
 	if not rows:
-		webnotes.msgprint(_("Please select a valid csv file with data."))
+		frappe.msgprint(_("Please select a valid csv file with data."))
 		raise Exception
 		
 	if len(rows) > 500:
-		webnotes.msgprint(_("Max 500 rows only."))
+		frappe.msgprint(_("Max 500 rows only."))
 		raise Exception
 	
 	rename_log = []
@@ -45,7 +45,7 @@
 			try:
 				if rename_doc(select_doctype, row[0], row[1]):
 					rename_log.append(_("Successful: ") + row[0] + " -> " + row[1])
-					webnotes.conn.commit()
+					frappe.conn.commit()
 				else:
 					rename_log.append(_("Ignored: ") + row[0] + " -> " + row[1])
 			except Exception, e:
diff --git a/erpnext/utilities/doctype/sms_control/sms_control.js b/erpnext/utilities/doctype/sms_control/sms_control.js
index 42025bf..24d314e 100644
--- a/erpnext/utilities/doctype/sms_control/sms_control.js
+++ b/erpnext/utilities/doctype/sms_control/sms_control.js
@@ -36,7 +36,7 @@
 		me.dialog.show();
 	}
 	this.make_dialog = function() {
-		var d = new wn.ui.Dialog({
+		var d = new frappe.ui.Dialog({
 			title: 'Send SMS',
 			width: 400,
 			fields: [
diff --git a/erpnext/utilities/doctype/sms_control/sms_control.py b/erpnext/utilities/doctype/sms_control/sms_control.py
index 5c08a41..14ae989 100644
--- a/erpnext/utilities/doctype/sms_control/sms_control.py
+++ b/erpnext/utilities/doctype/sms_control/sms_control.py
@@ -2,13 +2,13 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import webnotes, json
+import frappe, json
 
-from webnotes.utils import nowdate, cstr
-from webnotes.model.code import get_obj
-from webnotes.model.doc import Document
-from webnotes import msgprint, throw, _
-from webnotes.model.bean import getlist
+from frappe.utils import nowdate, cstr
+from frappe.model.code import get_obj
+from frappe.model.doc import Document
+from frappe import msgprint, throw, _
+from frappe.model.bean import getlist
 
 class DocType:
 	def __init__(self, doc, doclist=[]):
@@ -33,10 +33,10 @@
 
 	def get_sender_name(self):
 		"returns name as SMS sender"
-		sender_name = webnotes.conn.get_value('Global Defaults', None, 'sms_sender_name') or \
+		sender_name = frappe.conn.get_value('Global Defaults', None, 'sms_sender_name') or \
 			'ERPNXT'
 		if len(sender_name) > 6 and \
-				webnotes.conn.get_value("Control Panel", None, "country") == "India":
+				frappe.conn.get_value("Control Panel", None, "country") == "India":
 			throw(_("""
 				As per TRAI rule, sender name must be exactly 6 characters.
 				Kindly change sender name in Setup --> Global Defaults.
@@ -48,7 +48,7 @@
 	def get_contact_number(self, arg):
 		"returns mobile number of the contact"
 		args = json.loads(arg)
-		number = webnotes.conn.sql("""select mobile_no, phone from tabContact where name=%s and %s=%s""" % 
+		number = frappe.conn.sql("""select mobile_no, phone from tabContact where name=%s and %s=%s""" % 
 			('%s', args['key'], '%s'), (args['contact_name'], args['value']))
 		return number and (number[0][0] or number[0][1]) or ''
 	
@@ -66,7 +66,7 @@
 			'sender_name'	: sender_name or self.get_sender_name()
 		}
 
-		if webnotes.conn.get_value('SMS Settings', None, 'sms_gateway_url'):
+		if frappe.conn.get_value('SMS Settings', None, 'sms_gateway_url'):
 			ret = self.send_via_gateway(arg)
 			msgprint(ret)
 
diff --git a/erpnext/utilities/doctype/sms_log/sms_log.py b/erpnext/utilities/doctype/sms_log/sms_log.py
index cb6190f..26c87f1 100644
--- a/erpnext/utilities/doctype/sms_log/sms_log.py
+++ b/erpnext/utilities/doctype/sms_log/sms_log.py
@@ -2,7 +2,7 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import webnotes
+import frappe
 
 class DocType:
 	def __init__(self, d, dl):
diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py
index caf8c8b..c31eb53 100644
--- a/erpnext/utilities/repost_stock.py
+++ b/erpnext/utilities/repost_stock.py
@@ -2,30 +2,30 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import webnotes
+import frappe
 
-from webnotes.utils import flt
+from frappe.utils import flt
 
 
 def repost(allow_negative_stock=False):
 	"""
 	Repost everything!
 	"""
-	webnotes.conn.auto_commit_on_many_writes = 1
+	frappe.conn.auto_commit_on_many_writes = 1
 	
 	if allow_negative_stock:
-		webnotes.conn.set_default("allow_negative_stock", 1)
+		frappe.conn.set_default("allow_negative_stock", 1)
 	
-	for d in webnotes.conn.sql("""select distinct item_code, warehouse from 
+	for d in frappe.conn.sql("""select distinct item_code, warehouse from 
 		(select item_code, warehouse from tabBin
 		union
 		select item_code, warehouse from `tabStock Ledger Entry`) a"""):
 			repost_stock(d[0], d[1], allow_negative_stock)
 			
 	if allow_negative_stock:
-		webnotes.conn.set_default("allow_negative_stock", 
-			webnotes.conn.get_value("Stock Settings", None, "allow_negative_stock"))
-	webnotes.conn.auto_commit_on_many_writes = 0
+		frappe.conn.set_default("allow_negative_stock", 
+			frappe.conn.get_value("Stock Settings", None, "allow_negative_stock"))
+	frappe.conn.auto_commit_on_many_writes = 0
 
 def repost_stock(item_code, warehouse):
 	repost_actual_qty(item_code, warehouse)
@@ -46,7 +46,7 @@
 		pass
 	
 def get_reserved_qty(item_code, warehouse):
-	reserved_qty = webnotes.conn.sql("""
+	reserved_qty = frappe.conn.sql("""
 		select 
 			sum((dnpi_qty / so_item_qty) * (so_item_qty - so_item_delivered_qty))
 		from 
@@ -88,7 +88,7 @@
 	return flt(reserved_qty[0][0]) if reserved_qty else 0
 	
 def get_indented_qty(item_code, warehouse):
-	indented_qty = webnotes.conn.sql("""select sum(pr_item.qty - ifnull(pr_item.ordered_qty, 0))
+	indented_qty = frappe.conn.sql("""select sum(pr_item.qty - ifnull(pr_item.ordered_qty, 0))
 		from `tabMaterial Request Item` pr_item, `tabMaterial Request` pr
 		where pr_item.item_code=%s and pr_item.warehouse=%s 
 		and pr_item.qty > ifnull(pr_item.ordered_qty, 0) and pr_item.parent=pr.name 
@@ -97,7 +97,7 @@
 	return flt(indented_qty[0][0]) if indented_qty else 0
 
 def get_ordered_qty(item_code, warehouse):
-	ordered_qty = webnotes.conn.sql("""
+	ordered_qty = frappe.conn.sql("""
 		select sum((po_item.qty - ifnull(po_item.received_qty, 0))*po_item.conversion_factor)
 		from `tabPurchase Order Item` po_item, `tabPurchase Order` po
 		where po_item.item_code=%s and po_item.warehouse=%s 
@@ -107,7 +107,7 @@
 	return flt(ordered_qty[0][0]) if ordered_qty else 0
 			
 def get_planned_qty(item_code, warehouse):
-	planned_qty = webnotes.conn.sql("""
+	planned_qty = frappe.conn.sql("""
 		select sum(ifnull(qty, 0) - ifnull(produced_qty, 0)) from `tabProduction Order` 
 		where production_item = %s and fg_warehouse = %s and status != "Stopped"
 		and docstatus=1 and ifnull(qty, 0) > ifnull(produced_qty, 0)""", (item_code, warehouse))
diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py
index b239fdc..079b9d1 100644
--- a/erpnext/utilities/transaction_base.py
+++ b/erpnext/utilities/transaction_base.py
@@ -2,9 +2,9 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import webnotes
-from webnotes import msgprint, _
-from webnotes.utils import cstr, flt, now_datetime, cint
+import frappe
+from frappe import msgprint, _
+from frappe.utils import cstr, flt, now_datetime, cint
 
 from erpnext.controllers.status_updater import StatusUpdater
 
@@ -35,7 +35,7 @@
 	def get_lead_defaults(self):
 		out = self.get_default_address_and_contact("lead")
 		
-		lead = webnotes.conn.get_value("Lead", self.doc.lead, 
+		lead = frappe.conn.get_value("Lead", self.doc.lead, 
 			["territory", "company_name", "lead_name"], as_dict=True) or {}
 
 		out["territory"] = lead.get("territory")
@@ -48,9 +48,9 @@
 
 	def load_notification_message(self):
 		dt = self.doc.doctype.lower().replace(" ", "_")
-		if int(webnotes.conn.get_value("Notification Control", None, dt) or 0):
+		if int(frappe.conn.get_value("Notification Control", None, dt) or 0):
 			self.doc.fields["__notification_message"] = \
-				webnotes.conn.get_value("Notification Control", None, dt + "_message")
+				frappe.conn.get_value("Notification Control", None, dt + "_message")
 							
 	def validate_posting_time(self):
 		if not self.doc.posting_time:
@@ -64,12 +64,12 @@
 			self._add_calendar_event(opts)
 			
 	def delete_events(self):
-		webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent` 
+		frappe.delete_doc("Event", frappe.conn.sql_list("""select name from `tabEvent` 
 			where ref_type=%s and ref_name=%s""", (self.doc.doctype, self.doc.name)), 
 			ignore_permissions=True)
 			
 	def _add_calendar_event(self, opts):
-		opts = webnotes._dict(opts)
+		opts = frappe._dict(opts)
 		
 		if self.doc.contact_date:
 			event_doclist = [{
@@ -83,14 +83,14 @@
 				"ref_name": self.doc.name
 			}]
 			
-			if webnotes.conn.exists("Profile", self.doc.contact_by):
+			if frappe.conn.exists("Profile", self.doc.contact_by):
 				event_doclist.append({
 					"doctype": "Event User",
 					"parentfield": "event_individuals",
 					"person": self.doc.contact_by
 				})
 			
-			webnotes.bean(event_doclist).insert()
+			frappe.bean(event_doclist).insert()
 			
 	def validate_uom_is_integer(self, uom_field, qty_fields):
 		validate_uom_is_integer(self.doclist, uom_field, qty_fields)
@@ -108,7 +108,7 @@
 						if ref_dn not in item_ref_dn:
 							item_ref_dn.append(ref_dn)
 						elif not val.get("allow_duplicate_prev_row_id"):
-							webnotes.msgprint(_("Row ") + cstr(d.idx + 1) + 
+							frappe.msgprint(_("Row ") + cstr(d.idx + 1) + 
 								_(": Duplicate row from same ") + key, raise_exception=1)
 					elif ref_dn:
 						ref_doc.setdefault(key, [])
@@ -120,7 +120,7 @@
 	def compare_values(self, ref_doc, fields, doc=None):
 		for ref_doctype, ref_dn_list in ref_doc.items():
 			for ref_docname in ref_dn_list:
-				prevdoc_values = webnotes.conn.get_value(ref_doctype, ref_docname, 
+				prevdoc_values = frappe.conn.get_value(ref_doctype, ref_docname, 
 					[d[0] for d in fields], as_dict=1)
 
 				for field, condition in fields:
@@ -128,7 +128,7 @@
 						self.validate_value(field, condition, prevdoc_values[field], doc)
 
 def get_default_contact(party_field, party_name):
-	contact = webnotes.conn.sql("""select name from `tabContact` where `%s`=%s
+	contact = frappe.conn.sql("""select name from `tabContact` where `%s`=%s
 		order by is_primary_contact desc, name asc limit 1""" % (party_field, "%s"), 
 		(party_name,))
 		
@@ -139,7 +139,7 @@
 	for fieldname in ["contact_display", "contact_email", "contact_mobile", "contact_phone"]:
 		out[fieldname] = None
 	
-	lead = webnotes.conn.sql("""select * from `tabLead` where name=%s""", party_name, as_dict=True)
+	lead = frappe.conn.sql("""select * from `tabLead` where name=%s""", party_name, as_dict=True)
 	if lead:
 		lead = lead[0]
 		out.update({
@@ -161,7 +161,7 @@
 		contact_name = get_default_contact(party_field, party_name)
 	
 	if contact_name:
-		contact = webnotes.conn.sql("""select * from `tabContact` where name=%s""", 
+		contact = frappe.conn.sql("""select * from `tabContact` where name=%s""", 
 			contact_name, as_dict=True)
 
 		if contact:
@@ -184,23 +184,23 @@
 	for fieldname in ("city", "state", "country"):
 		value = address_doc.fields.get(fieldname)
 		if value:
-			territory = webnotes.conn.get_value("Territory", value.strip())
+			territory = frappe.conn.get_value("Territory", value.strip())
 			if territory:
 				break
 	
 	return territory
 	
 def delete_events(ref_type, ref_name):
-	webnotes.delete_doc("Event", webnotes.conn.sql_list("""select name from `tabEvent` 
+	frappe.delete_doc("Event", frappe.conn.sql_list("""select name from `tabEvent` 
 		where ref_type=%s and ref_name=%s""", (ref_type, ref_name)), for_reload=True)
 
-class UOMMustBeIntegerError(webnotes.ValidationError): pass
+class UOMMustBeIntegerError(frappe.ValidationError): pass
 
 def validate_uom_is_integer(doclist, uom_field, qty_fields):
 	if isinstance(qty_fields, basestring):
 		qty_fields = [qty_fields]
 	
-	integer_uoms = filter(lambda uom: webnotes.conn.get_value("UOM", uom, 
+	integer_uoms = filter(lambda uom: frappe.conn.get_value("UOM", uom, 
 		"must_be_whole_number") or None, doclist.get_distinct_values(uom_field))
 		
 	if not integer_uoms:
@@ -211,7 +211,7 @@
 			for f in qty_fields:
 				if d.fields.get(f):
 					if cint(d.fields[f])!=d.fields[f]:
-						webnotes.msgprint(_("For UOM") + " '" + d.fields[uom_field] \
+						frappe.msgprint(_("For UOM") + " '" + d.fields[uom_field] \
 							+ "': " + _("Quantity cannot be a fraction.") \
 							+ " " + _("In Row") + ": " + str(d.idx),
 							raise_exception=UOMMustBeIntegerError)