frappe/frappe#478 erpnext install works
diff --git a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py
index 52cf529..d69ae73 100644
--- a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py
@@ -7,7 +7,7 @@
 from unidecode import unidecode
 from frappe.model.document import Document
 
-class ChartOfAccounts(Document):
+class ChartofAccounts(Document):
 	no_report_type = False
 		
 	def create_accounts(self, company):
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
index 02bca17..3af9a03 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
@@ -24,7 +24,7 @@
 			
 		self.clearance_date = None
 		
-		super(DocType, self).validate_date_with_fiscal_year()
+		super(JournalVoucher, self).validate_date_with_fiscal_year()
 		
 		self.validate_debit_credit()
 		self.validate_cheque_info()
@@ -268,7 +268,7 @@
 			master_type, master_name = frappe.db.get_value("Account", d.account, 
 				["master_type", "master_name"])
 			if master_type == "Customer" and master_name:
-				super(DocType, self).check_credit_limit(d.account)
+				super(JournalVoucher, self).check_credit_limit(d.account)
 
 	def get_balance(self):
 		if not self.get('entries'):
diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
index 36b4e95..cff24e1 100644
--- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
+++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py
@@ -10,7 +10,7 @@
 
 from frappe.model.document import Document
 
-class PaymentToInvoiceMatchingTool(Document):
+class PaymenttoInvoiceMatchingTool(Document):
 	def get_voucher_details(self):
 		total_amount = frappe.db.sql("""select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) 
 			from `tabGL Entry` 
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index b374796..88df6bd 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -33,7 +33,7 @@
 		if not self.is_opening:
 			self.is_opening = 'No'
 			
-		super(DocType, self).validate()
+		super(PurchaseInvoice, self).validate()
 		
 		self.po_required()
 		self.pr_required()
@@ -61,10 +61,10 @@
 			self.due_date = get_due_date(self.posting_date, self.supplier, "Supplier",
 				self.credit_to, self.company)
 		
-		super(DocType, self).set_missing_values(for_validate)
+		super(PurchaseInvoice, self).set_missing_values(for_validate)
 	
 	def get_advances(self):
-		super(DocType, self).get_advances(self.credit_to, 
+		super(PurchaseInvoice, self).get_advances(self.credit_to, 
 			"Purchase Invoice Advance", "advance_allocation_details", "debit")
 		
 	def check_active_purchase_items(self):
@@ -131,7 +131,7 @@
 					raise Exception
 		
 	def validate_with_previous_doc(self):
-		super(DocType, self).validate_with_previous_doc(self.tname, {
+		super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, {
 			"Purchase Order": {
 				"ref_dn_field": "purchase_order",
 				"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],
@@ -154,7 +154,7 @@
 		})
 		
 		if cint(frappe.defaults.get_global_default('maintain_same_rate')):
-			super(DocType, self).validate_with_previous_doc(self.tname, {
+			super(PurchaseInvoice, self).validate_with_previous_doc(self.tname, {
 				"Purchase Order Item": {
 					"ref_dn_field": "po_detail",
 					"compare_fields": [["rate", "="]],
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index b3e9a11..ef17f66 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -38,7 +38,7 @@
 	}]
 
 	def validate(self):
-		super(DocType, self).validate()
+		super(SalesInvoice, self).validate()
 		self.validate_posting_time()
 		self.so_dn_required()
 		self.validate_proj_cust()
@@ -150,17 +150,17 @@
 			self.due_date = get_due_date(self.posting_date, self.customer, "Customer",
 				self.debit_to, self.company)
 		
-		super(DocType, self).set_missing_values(for_validate)
+		super(SalesInvoice, self).set_missing_values(for_validate)
 					
 	def update_time_log_batch(self, sales_invoice):
-		for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
+		for d in self.get(self.fname):
 			if d.time_log_batch:
 				tlb = frappe.get_doc("Time Log Batch", d.time_log_batch)
 				tlb.sales_invoice = sales_invoice
 				tlb.update_after_submit()
 
 	def validate_time_logs_are_submitted(self):
-		for d in self.doclist.get({"doctype":"Sales Invoice Item"}):
+		for d in self.get(self.fname):
 			if d.time_log_batch:
 				status = frappe.db.get_value("Time Log Batch", d.time_log_batch, "status")
 				if status!="Submitted":
@@ -206,7 +206,7 @@
 				self.set_taxes("other_charges", "taxes_and_charges")
 	
 	def get_advances(self):
-		super(DocType, self).get_advances(self.debit_to, 
+		super(SalesInvoice, self).get_advances(self.debit_to, 
 			"Sales Invoice Advance", "advance_adjustment_details", "credit")
 		
 	def get_company_abbr(self):
@@ -269,7 +269,7 @@
 				msgprint("Please select income head with account type 'Fixed Asset' as Item %s is an asset item" % d.item_code, raise_exception=True)				
 		
 	def validate_with_previous_doc(self):
-		super(DocType, self).validate_with_previous_doc(self.tname, {
+		super(SalesInvoice, self).validate_with_previous_doc(self.tname, {
 			"Sales Order": {
 				"ref_dn_field": "sales_order",
 				"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
@@ -283,7 +283,7 @@
 		})
 		
 		if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
-			super(DocType, self).validate_with_previous_doc(self.tname, {
+			super(SalesInvoice, self).validate_with_previous_doc(self.tname, {
 				"Sales Order Item": {
 					"ref_dn_field": "so_detail",
 					"compare_fields": [["rate", "="]],
@@ -537,7 +537,7 @@
 		# expense account gl entries
 		if cint(frappe.defaults.get_global_default("auto_accounting_for_stock")) \
 				and cint(self.update_stock):
-			gl_entries += super(DocType, self).get_gl_entries()
+			gl_entries += super(SalesInvoice, self).get_gl_entries()
 				
 	def make_pos_gl_entries(self, gl_entries):
 		if cint(self.is_pos) and self.cash_bank_account and self.paid_amount:
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index 81c7dfb..9458ecc 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -26,7 +26,7 @@
 	}]
 		
 	def validate(self):
-		super(DocType, self).validate()
+		super(PurchaseOrder, self).validate()
 		
 		if not self.status:
 			self.status = "Draft"
@@ -47,7 +47,7 @@
 		self.update_raw_materials_supplied("po_raw_material_details")
 		
 	def validate_with_previous_doc(self):
-		super(DocType, self).validate_with_previous_doc(self.tname, {
+		super(PurchaseOrder, self).validate_with_previous_doc(self.tname, {
 			"Supplier Quotation": {
 				"ref_dn_field": "supplier_quotation",
 				"compare_fields": [["supplier", "="], ["company", "="], ["currency", "="]],
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
index dbca9b5..ff7e6df 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -10,7 +10,7 @@
 	fname = "quotation_items"
 	
 	def validate(self):
-		super(DocType, self).validate()
+		super(SupplierQuotation, self).validate()
 		
 		if not self.status:
 			self.status = "Draft"
@@ -33,7 +33,7 @@
 		pass
 			
 	def validate_with_previous_doc(self):
-		super(DocType, self).validate_with_previous_doc(self.tname, {
+		super(SupplierQuotation, self).validate_with_previous_doc(self.tname, {
 			"Material Request": {
 				"ref_dn_field": "prevdoc_docname",
 				"compare_fields": [["company", "="]],
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index b3155fd..083f0a6 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -378,8 +378,8 @@
 		return gl_dict
 				
 	def clear_unallocated_advances(self, childtype, parentfield):
-		self.doclist.remove_items({"parentfield": parentfield, "allocated_amount": ["in", [0, None, ""]]})
-			
+		self.set(parentfield, self.get(parentfield, {"allocated_amount": ["not in", [0, None, ""]]}))
+
 		frappe.db.sql("""delete from `tab%s` where parentfield=%s and parent = %s 
 			and ifnull(allocated_amount, 0) = 0""" % (childtype, '%s', '%s'), (parentfield, self.name))
 		
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index b37213c..24dce4b 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -40,7 +40,7 @@
 
 	def set_supplier_from_item_default(self):
 		if self.meta.get_field("supplier") and not self.supplier:
-			for d in self.doclist.get({"doctype": self.tname}):
+			for d in self.get(self.fname):
 				supplier = frappe.db.get_value("Item", d.item_code, "default_supplier")
 				if supplier:
 					self.supplier = supplier
@@ -50,7 +50,7 @@
 		from erpnext.stock.utils import validate_warehouse_company
 		
 		warehouses = list(set([d.warehouse for d in 
-			self.doclist.get({"doctype": self.tname}) if d.warehouse]))
+			self.get(self.fname) if d.warehouse]))
 				
 		for w in warehouses:
 			validate_warehouse_company(w, self.company)
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index ba8118e..7228100 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -94,13 +94,13 @@
 	
 	def communication_received(self):
 		if getattr(self, "communication_set", False):
-			last_comm = self.doclist.get({"doctype":"Communication"})
+			last_comm = self.get("communications")
 			if last_comm:
 				return last_comm[-1].sent_or_received == "Received"
 
 	def communication_sent(self):
 		if getattr(self, "communication_set", False):
-			last_comm = self.doclist.get({"doctype":"Communication"})
+			last_comm = self.get("communications")
 			if last_comm:
 				return last_comm[-1].sent_or_received == "Sent"
 			
@@ -113,7 +113,7 @@
 		
 		for args in self.status_updater:
 			# get unique transactions to update
-			for d in self.doclist:
+			for d in self.get_all_children():
 				if d.doctype == args['source_dt'] and d.get(args["join_field"]):
 					args['name'] = d.get(args['join_field'])
 
@@ -191,7 +191,7 @@
 				args['modified_cond'] = ', modified = now()'
 		
 			# update quantities in child table
-			for d in self.doclist:
+			for d in self.get_all_children():
 				if d.doctype == args['source_dt']:
 					# updates qty in the child table
 					args['detail_id'] = d.get(args['join_field'])
@@ -212,8 +212,7 @@
 							where name='%(detail_id)s'""" % args)
 		
 			# get unique transactions to update
-			for name in set([d.get(args['percent_join_field']) for d in self.doclist 
-					if d.doctype == args['source_dt']]):
+			for name in set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])]):
 				if name:
 					args['name'] = name
 				
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 33b7fdb..e00449d 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -90,7 +90,7 @@
 			warehouse_account = get_warehouse_account()
 		
 		if hasattr(self, "fname"):
-			item_doclist = self.doclist.get({"parentfield": self.fname})
+			item_doclist = self.get(self.fname)
 		elif self.doctype == "Stock Reconciliation":
 			import json
 			item_doclist = []
diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.py b/erpnext/hr/doctype/holiday_list/holiday_list.py
index 92cc9f0..ec15604 100644
--- a/erpnext/hr/doctype/holiday_list/holiday_list.py
+++ b/erpnext/hr/doctype/holiday_list/holiday_list.py
@@ -22,8 +22,7 @@
 		self.validate_values()
 		yr_start_date, yr_end_date = self.get_fy_start_end_dates()
 		date_list = self.get_weekly_off_date_list(yr_start_date, yr_end_date)
-		last_idx = max([cint(d.idx) for d in self.doclist.get(
-			{"parentfield": "holiday_list_details"})] or [0,])
+		last_idx = max([cint(d.idx) for d in self.get("holiday_list_details")] or [0,])
 		for i, d in enumerate(date_list):
 			ch = self.append('holiday_list_details', {})
 			ch.description = self.weekly_off
diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.py b/erpnext/hr/doctype/hr_settings/hr_settings.py
index 861408d..5cafbda 100644
--- a/erpnext/hr/doctype/hr_settings/hr_settings.py
+++ b/erpnext/hr/doctype/hr_settings/hr_settings.py
@@ -10,7 +10,7 @@
 
 from frappe.model.document import Document
 
-class HrSettings(Document):
+class HRSettings(Document):
 		
 	def validate(self):
 		self.update_birthday_reminders()
diff --git a/erpnext/hr/doctype/leave_block_list/leave_block_list.py b/erpnext/hr/doctype/leave_block_list/leave_block_list.py
index 868b990..e9bc6ab 100644
--- a/erpnext/hr/doctype/leave_block_list/leave_block_list.py
+++ b/erpnext/hr/doctype/leave_block_list/leave_block_list.py
@@ -14,7 +14,7 @@
 		
 	def validate(self):
 		dates = []
-		for d in self.doclist.get({"doctype":"Leave Block List Date"}):
+		for d in self.get("leave_block_list_dates"):
 			# validate fiscal year
 			validate_fiscal_year(d.block_date, self.year, _("Block Date"))
 			
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 981935f..8c34037 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -34,7 +34,7 @@
 
 	def pull_sal_struct(self, struct):
 		from erpnext.hr.doctype.salary_structure.salary_structure import get_mapped_doc
-		self.doclist = get_mapped_doc(struct, self.doclist)
+		self.update(get_mapped_doc(struct, self))
 		
 	def pull_emp_details(self):
 		emp = frappe.db.get_value("Employee", self.employee, 
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 05e3268..2bbc99b 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -82,7 +82,7 @@
 		sal_slip.run_method("get_leave_details")
 		sal_slip.run_method("calculate_net_pay")
 
-	doclist = get_mapped_doc("Salary Structure", source_name, {
+	doc = get_mapped_doc("Salary Structure", source_name, {
 		"Salary Structure": {
 			"doctype": "Salary Slip", 
 			"field_map": {
@@ -109,4 +109,4 @@
 		}
 	}, target_doc, postprocess)
 
-	return doclist
+	return doc
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 6fdf641..b507226 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -11,7 +11,7 @@
 
 from frappe.model.document import Document
 
-class Bom(Document):
+class BOM(Document):
 
 	def autoname(self):
 		last_name = frappe.db.sql("""select max(name) from `tabBOM` 
@@ -28,7 +28,7 @@
 		self.validate_main_item()
 
 		from erpnext.utilities.transaction_base import validate_uom_is_integer
-		validate_uom_is_integer(self.doclist, "stock_uom", "qty")
+		validate_uom_is_integer(self, "stock_uom", "qty")
 
 		self.validate_operations()
 		self.validate_materials()
@@ -133,11 +133,11 @@
 			})["rate"]
 		
 		if self.docstatus == 0:
-			frappe.get_doc(self.doclist).save()
+			self.save()
 		elif self.docstatus == 1:
 			self.calculate_cost()
 			self.update_exploded_items()
-			frappe.get_doc(self.doclist).update_after_submit()
+			self.update_after_submit()
 
 	def get_bom_unitcost(self, bom_no):
 		bom = frappe.db.sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.py b/erpnext/manufacturing/doctype/bom_item/bom_item.py
index f2bef2c..ff3a06f 100644
--- a/erpnext/manufacturing/doctype/bom_item/bom_item.py
+++ b/erpnext/manufacturing/doctype/bom_item/bom_item.py
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class BomItem(Document):
+class BOMItem(Document):
 	pass
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.py b/erpnext/manufacturing/doctype/bom_operation/bom_operation.py
index df55159..8c03faf 100644
--- a/erpnext/manufacturing/doctype/bom_operation/bom_operation.py
+++ b/erpnext/manufacturing/doctype/bom_operation/bom_operation.py
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class BomOperation(Document):
+class BOMOperation(Document):
 	pass
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
index 34f45bd..b772fcb 100644
--- a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
+++ b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
@@ -8,7 +8,7 @@
 	
 from frappe.model.document import Document
 
-class BomReplaceTool(Document):
+class BOMReplaceTool(Document):
 	def replace_bom(self):
 		self.validate_bom()
 		self.update_new_bom()
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index efdf2c4..75f40fa 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -26,7 +26,7 @@
 		self.validate_warehouse()
 		
 		from erpnext.utilities.transaction_base import validate_uom_is_integer
-		validate_uom_is_integer(self.doclist, "stock_uom", ["qty", "produced_qty"])
+		validate_uom_is_integer(self, "stock_uom", ["qty", "produced_qty"])
 		
 	def validate_bom_no(self):
 		if self.bom_no:
diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
index cec6471..c94a72c 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -173,7 +173,7 @@
 		self.validate_data()
 
 		from erpnext.utilities.transaction_base import validate_uom_is_integer
-		validate_uom_is_integer(self.doclist, "stock_uom", "planned_qty")
+		validate_uom_is_integer(self, "stock_uom", "planned_qty")
 
 		items = self.get_distinct_items_and_boms()[1]
 		pro = self.create_production_order(items)
diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.py b/erpnext/projects/doctype/time_log_batch/time_log_batch.py
index 9405e46..4ad8130 100644
--- a/erpnext/projects/doctype/time_log_batch/time_log_batch.py
+++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.py
@@ -14,7 +14,7 @@
 	def validate(self):
 		self.set_status()
 		self.total_hours = 0.0
-		for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
+		for d in self.get("time_log_batch_details"):
 			tl = frappe.get_doc("Time Log", d.time_log)
 			self.update_time_log_values(d, tl)
 			self.validate_time_log_is_submitted(tl)
@@ -53,7 +53,7 @@
 
 	def update_status(self, time_log_batch):
 		self.set_status()
-		for d in self.doclist.get({"doctype":"Time Log Batch Detail"}):
+		for d in self.get("time_log_batch_details"):
 			tl = frappe.get_doc("Time Log", d.time_log)
 			tl.time_log_batch = time_log_batch
 			tl.sales_invoice = self.sales_invoice
diff --git a/erpnext/selling/doctype/lead/lead.py b/erpnext/selling/doctype/lead/lead.py
index 743dc04..df57cf5 100644
--- a/erpnext/selling/doctype/lead/lead.py
+++ b/erpnext/selling/doctype/lead/lead.py
@@ -38,7 +38,7 @@
 		self.add_calendar_event()
 		
 	def add_calendar_event(self, opts=None, force=False):
-		super(DocType, self).add_calendar_event({
+		super(Lead, self).add_calendar_event({
 			"owner": self.lead_owner,
 			"subject": ('Contact ' + cstr(self.lead_name)),
 			"description": ('Contact ' + cstr(self.lead_name)) + \
diff --git a/erpnext/selling/doctype/opportunity/opportunity.py b/erpnext/selling/doctype/opportunity/opportunity.py
index 0ded247..a2358a3 100644
--- a/erpnext/selling/doctype/opportunity/opportunity.py
+++ b/erpnext/selling/doctype/opportunity/opportunity.py
@@ -78,7 +78,7 @@
 		if self.to_discuss:
 			opts.description += ' To Discuss : ' + cstr(self.to_discuss)
 		
-		super(DocType, self).add_calendar_event(opts, force)
+		super(Opportunity, self).add_calendar_event(opts, force)
 
 	def validate_item_details(self):
 		if not self.get('enquiry_details'):
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 0f64880..45a9d0b 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -10,8 +10,8 @@
 from erpnext.controllers.selling_controller import SellingController
 
 class Quotation(SellingController):
-		self.tname = 'Quotation Item'
-		self.fname = 'quotation_details'
+	tname = 'Quotation Item'
+	fname = 'quotation_details'
 
 	def has_sales_order(self):
 		return frappe.db.get_value("Sales Order Item", {"prevdoc_docname": self.name, "docstatus": 1})
@@ -26,7 +26,7 @@
 				chk_dupl_itm.append([cstr(d.item_code),cstr(d.description)])
 
 	def validate_order_type(self):
-		super(DocType, self).validate_order_type()
+		super(Quotation, self).validate_order_type()
 		
 		if self.order_type in ['Maintenance', 'Service']:
 			for d in self.get('quotation_details'):
@@ -46,15 +46,16 @@
 					raise Exception
 	
 	def validate(self):
-		super(DocType, self).validate()
+		super(Quotation, self).validate()
 		self.set_status()
 		self.validate_order_type()
 		self.validate_for_items()
 		self.validate_uom_is_integer("stock_uom", "qty")
 
 	def update_opportunity(self):
-		for opportunity in self.doclist.get_distinct_values("prevdoc_docname"):
-			frappe.get_doc("Opportunity", opportunity).set_status(update=True)
+		for opportunity in list(set([d.prevdoc_docname for d in self.get("quotation_details")])):
+			if opportunity:
+				frappe.get_doc("Opportunity", opportunity).set_status(update=True)
 	
 	def declare_order_lost(self, arg):
 		if not self.has_sales_order():
diff --git a/erpnext/selling/doctype/sales_bom/sales_bom.py b/erpnext/selling/doctype/sales_bom/sales_bom.py
index 207bdcb..5601d7f 100644
--- a/erpnext/selling/doctype/sales_bom/sales_bom.py
+++ b/erpnext/selling/doctype/sales_bom/sales_bom.py
@@ -6,7 +6,7 @@
 
 from frappe.model.document import Document
 
-class SalesBom(Document):
+class SalesBOM(Document):
 
 
 	def autoname(self):
@@ -16,7 +16,7 @@
 		self.validate_main_item()
 
 		from erpnext.utilities.transaction_base import validate_uom_is_integer
-		validate_uom_is_integer(self.doclist, "uom", "qty")
+		validate_uom_is_integer(self, "uom", "qty")
 
 	def validate_main_item(self):
 		"""main item must have Is Stock Item as No and Is Sales Item as Yes"""
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index 6db638b..42b3596 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -78,7 +78,7 @@
 						and current Sales Order""" % (self.order_type, d.prevdoc_docname))
 
 	def validate_order_type(self):
-		super(DocType, self).validate_order_type()
+		super(SalesOrder, self).validate_order_type()
 		
 	def validate_delivery_date(self):
 		if self.order_type == 'Sales' and not self.delivery_date:
@@ -97,7 +97,7 @@
 				raise Exception
 	
 	def validate(self):
-		super(DocType, self).validate()
+		super(SalesOrder, self).validate()
 		
 		self.validate_order_type()
 		self.validate_delivery_date()
@@ -110,7 +110,7 @@
 
 		from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
 
-		self.doclist = make_packing_list(self,'sales_order_details')
+		make_packing_list(self,'sales_order_details')
 		
 		self.validate_with_previous_doc()
 		
@@ -128,13 +128,13 @@
 		from erpnext.stock.utils import validate_warehouse_company
 		
 		warehouses = list(set([d.warehouse for d in 
-			self.doclist.get({"doctype": self.tname}) if d.warehouse]))
+			self.get(self.fname) if d.warehouse]))
 				
 		for w in warehouses:
 			validate_warehouse_company(w, self.company)
 		
 	def validate_with_previous_doc(self):
-		super(DocType, self).validate_with_previous_doc(self.tname, {
+		super(SalesOrder, self).validate_with_previous_doc(self.tname, {
 			"Quotation": {
 				"ref_dn_field": "prevdoc_docname",
 				"compare_fields": [["company", "="], ["currency", "="]]
@@ -148,12 +148,13 @@
 			frappe.db.sql("update `tabOpportunity` set status = %s where name=%s",(flag,enq[0][0]))
 
 	def update_prevdoc_status(self, flag):				
-		for quotation in self.doclist.get_distinct_values("prevdoc_docname"):
-			bean = frappe.get_doc("Quotation", quotation)
-			if bean.docstatus==2:
-				frappe.throw(quotation + ": " + frappe._("Quotation is cancelled."))
+		for quotation in list(set([d.prevdoc_docname for d in self.get(self.fname)])):
+			if quotation:
+				doc = frappe.get_doc("Quotation", quotation)
+				if doc.docstatus==2:
+					frappe.throw(quotation + ": " + frappe._("Quotation is cancelled."))
 				
-			bean.set_status(update=True)
+				doc.set_status(update=True)
 
 	def on_submit(self):
 		self.update_stock_ledger(update_stock = 1)
diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py
index 487df38..209d1b4 100644
--- a/erpnext/selling/doctype/sms_center/sms_center.py
+++ b/erpnext/selling/doctype/sms_center/sms_center.py
@@ -9,7 +9,7 @@
 
 from frappe.model.document import Document
 
-class SmsCenter(Document):
+class SMSCenter(Document):
 
 	def create_receiver_list(self):
 		rec, where_clause = '', ''
diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.py b/erpnext/setup/doctype/backup_manager/backup_manager.py
index 8f7e891..ff4e115 100644
--- a/erpnext/setup/doctype/backup_manager/backup_manager.py
+++ b/erpnext/setup/doctype/backup_manager/backup_manager.py
@@ -10,6 +10,7 @@
 from frappe.model.document import Document
 
 class BackupManager(Document):
+	pass
 
 def take_backups_daily():
 	take_backups_if("Daily")
diff --git a/erpnext/setup/doctype/currency/currency.py b/erpnext/setup/doctype/currency/currency.py
index 5541065..9dc6e3b 100644
--- a/erpnext/setup/doctype/currency/currency.py
+++ b/erpnext/setup/doctype/currency/currency.py
@@ -8,7 +8,8 @@
 from frappe.model.document import Document
 
 class Currency(Document):
-		
+	pass
+
 def validate_conversion_rate(currency, conversion_rate, conversion_rate_label, company):
 	"""common validation for currency and price list currency"""
 
diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py
index 425741b..4443567 100644
--- a/erpnext/setup/doctype/customer_group/customer_group.py
+++ b/erpnext/setup/doctype/customer_group/customer_group.py
@@ -8,7 +8,7 @@
 	
 from frappe.utils.nestedset import DocTypeNestedSet
 class CustomerGroup(DocTypeNestedSet):
-		self.nsm_parent_field = 'parent_customer_group';
+	nsm_parent_field = 'parent_customer_group';
 
 	def validate(self): 
 		if frappe.db.sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", 
@@ -19,7 +19,7 @@
 
 	def on_update(self):
 		self.validate_name_with_customer()
-		super(DocType, self).on_update()
+		super(CustomerGroup, self).on_update()
 		self.validate_one_root()
 		
 	def validate_name_with_customer(self):
@@ -44,4 +44,4 @@
 				You can not trash/cancel/delete this customer group.", raise_exception=1)
 
 		# rebuild tree
-		super(DocType, self).on_trash()
+		super(CustomerGroup, self).on_trash()
diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index e077c95..a619555 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -471,7 +471,6 @@
 		self.get_next_sending()
 	
 def send():
-		from frappe.utils import getdate
 	now_date = now_datetime().date()
 	
 	for ed in frappe.db.sql("""select name from `tabEmail Digest`
diff --git a/erpnext/setup/doctype/features_setup/features_setup.py b/erpnext/setup/doctype/features_setup/features_setup.py
index 1009b27..3d3367a 100644
--- a/erpnext/setup/doctype/features_setup/features_setup.py
+++ b/erpnext/setup/doctype/features_setup/features_setup.py
@@ -12,6 +12,6 @@
 		"""
 		from frappe.model import default_fields 
 		from frappe.utils import set_default
-		for key in self.fields:
+		for key in self.meta.get_valid_columns():
 			if key not in default_fields:
 				set_default(key, self.get(key))
diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py
index 8fc596e..cf2c29f 100644
--- a/erpnext/setup/doctype/naming_series/naming_series.py
+++ b/erpnext/setup/doctype/naming_series/naming_series.py
@@ -55,7 +55,7 @@
 			default = options[0]
 
 		# update in property setter
-				prop_dict = {'options': "\n".join(options), 'default': default}
+		prop_dict = {'options': "\n".join(options), 'default': default}
 		for prop in prop_dict:
 			ps_exists = frappe.db.sql("""SELECT name FROM `tabProperty Setter`
 					WHERE doc_type = %s AND field_name = 'naming_series'
diff --git a/erpnext/setup/doctype/sales_person/sales_person.py b/erpnext/setup/doctype/sales_person/sales_person.py
index db2057d..7f87210 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.py
+++ b/erpnext/setup/doctype/sales_person/sales_person.py
@@ -8,7 +8,7 @@
 from frappe.utils.nestedset import DocTypeNestedSet
 
 class SalesPerson(DocTypeNestedSet):
-		self.nsm_parent_field = 'parent_sales_person';
+	nsm_parent_field = 'parent_sales_person';
 
 	def validate(self): 
 		for d in self.get('target_details'):
@@ -16,7 +16,7 @@
 				frappe.throw(_("Either target qty or target amount is mandatory."))
 	
 	def on_update(self):
-		super(DocType, self).on_update()
+		super(SalesPerson, self).on_update()
 		self.validate_one_root()
 	
 	def get_email_id(self):
diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.py b/erpnext/setup/doctype/sms_parameter/sms_parameter.py
index 4c54a4f..a62da69 100644
--- a/erpnext/setup/doctype/sms_parameter/sms_parameter.py
+++ b/erpnext/setup/doctype/sms_parameter/sms_parameter.py
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class SmsParameter(Document):
+class SMSParameter(Document):
 	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sms_settings/sms_settings.py b/erpnext/setup/doctype/sms_settings/sms_settings.py
index 9361d3b..281ae76 100644
--- a/erpnext/setup/doctype/sms_settings/sms_settings.py
+++ b/erpnext/setup/doctype/sms_settings/sms_settings.py
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class SmsSettings(Document):
+class SMSSettings(Document):
 	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/territory/territory.py b/erpnext/setup/doctype/territory/territory.py
index ed2d5f1..a015644 100644
--- a/erpnext/setup/doctype/territory/territory.py
+++ b/erpnext/setup/doctype/territory/territory.py
@@ -19,5 +19,5 @@
 				raise Exception
 
 	def on_update(self):
-		super(DocType, self).on_update()
+		super(Territory, self).on_update()
 		self.validate_one_root()
diff --git a/erpnext/setup/doctype/uom/uom.py b/erpnext/setup/doctype/uom/uom.py
index 2d076f6..8822263 100644
--- a/erpnext/setup/doctype/uom/uom.py
+++ b/erpnext/setup/doctype/uom/uom.py
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class Uom(Document):
+class UOM(Document):
 	pass
\ No newline at end of file
diff --git a/erpnext/setup/install.py b/erpnext/setup/install.py
index c7955d9..a7e91d1 100644
--- a/erpnext/setup/install.py
+++ b/erpnext/setup/install.py
@@ -111,19 +111,19 @@
 	
 	from frappe.modules import scrub
 	for r in records:
-		bean = frappe.get_doc(r)
+		doc = frappe.get_doc(r)
 		
 		# ignore mandatory for root
-		parent_link_field = ("parent_" + scrub(bean.doctype))
-		if parent_link_field in bean.fields and not bean.get(parent_link_field):
-			bean.ignore_mandatory = True
+		parent_link_field = ("parent_" + scrub(doc.doctype))
+		if doc.meta.get_field(parent_link_field) and not doc.get(parent_link_field):
+			doc.ignore_mandatory = True
 		
-		bean.insert()
+		doc.insert()
 		
 def feature_setup():
 	"""save global defaults and features setup"""
-	bean = frappe.get_doc("Features Setup", "Features Setup")
-	bean.ignore_permissions = True
+	doc = frappe.get_doc("Features Setup", "Features Setup")
+	doc.ignore_permissions = True
 
 	# store value as 1 for all these fields
 	flds = ['fs_item_serial_nos', 'fs_item_batch_nos', 'fs_brands', 'fs_item_barcode',
@@ -133,8 +133,8 @@
 		'fs_recurring_invoice', 'fs_pos', 'fs_manufacturing', 'fs_quality',
 		'fs_page_break', 'fs_more_info', 'fs_pos_view'
 	]
-	bean.update(dict(zip(flds, [1]*len(flds))))
-	bean.save()
+	doc.update(dict(zip(flds, [1]*len(flds))))
+	doc.save()
 
 def set_single_defaults():
 	for dt in frappe.db.sql_list("""select name from `tabDocType` where issingle=1"""):
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index 1489590..12ecb09 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -13,21 +13,21 @@
 from erpnext.controllers.selling_controller import SellingController
 
 class DeliveryNote(SellingController):
-		self.tname = 'Delivery Note Item'
-		self.fname = 'delivery_note_details'
-		self.status_updater = [{
-			'source_dt': 'Delivery Note Item',
-			'target_dt': 'Sales Order Item',
-			'join_field': 'prevdoc_detail_docname',
-			'target_field': 'delivered_qty',
-			'target_parent_dt': 'Sales Order',
-			'target_parent_field': 'per_delivered',
-			'target_ref_field': 'qty',
-			'source_field': 'qty',
-			'percent_join_field': 'against_sales_order',
-			'status_field': 'delivery_status',
-			'keyword': 'Delivered'
-		}]
+	tname = 'Delivery Note Item'
+	fname = 'delivery_note_details'
+	status_updater = [{
+		'source_dt': 'Delivery Note Item',
+		'target_dt': 'Sales Order Item',
+		'join_field': 'prevdoc_detail_docname',
+		'target_field': 'delivered_qty',
+		'target_parent_dt': 'Sales Order',
+		'target_parent_field': 'per_delivered',
+		'target_ref_field': 'qty',
+		'source_field': 'qty',
+		'percent_join_field': 'against_sales_order',
+		'status_field': 'delivery_status',
+		'keyword': 'Delivered'
+	}]
 		
 	def onload(self):
 		billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item`
@@ -56,7 +56,7 @@
 
 
 	def validate(self):
-		super(DocType, self).validate()
+		super(DeliveryNote, self).validate()
 		
 		from erpnext.utilities import validate_status
 		validate_status(self.status, ["Draft", "Submitted", "Cancelled"])
@@ -71,7 +71,7 @@
 		self.validate_with_previous_doc()
 		
 		from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
-		self.doclist = make_packing_list(self, 'delivery_note_details')
+		make_packing_list(self, 'delivery_note_details')
 		
 		self.status = 'Draft'
 		if not self.installation_status: self.installation_status = 'Not Installed'	
@@ -80,8 +80,8 @@
 		items = self.get("delivery_note_details")
 		
 		for fn in (("Sales Order", "against_sales_order"), ("Sales Invoice", "against_sales_invoice")):
-			if items.get_distinct_values(fn[1]):
-				super(DocType, self).validate_with_previous_doc(self.tname, {
+			if filter(None, [(d[fn[1]] or None) for d in self.get(self.fname)]):
+				super(DeliveryNote, self).validate_with_previous_doc(self.tname, {
 					fn[0]: {
 						"ref_dn_field": fn[1],
 						"compare_fields": [["customer", "="], ["company", "="], ["project_name", "="],
@@ -90,7 +90,7 @@
 				})
 
 				if cint(frappe.defaults.get_global_default('maintain_same_sales_rate')):
-					super(DocType, self).validate_with_previous_doc(self.tname, {
+					super(DeliveryNote, self).validate_with_previous_doc(self.tname, {
 						fn[0] + " Item": {
 							"ref_dn_field": "prevdoc_detail_docname",
 							"compare_fields": [["rate", "="]],
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 4741bde..f10b338 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -179,8 +179,7 @@
 						frappe.throw(_("As there are existing stock transactions for this item, you can not change the values of 'Has Serial No', 'Is Stock Item' and 'Valuation Method'"))
 							
 	def validate_item_type_for_reorder(self):
-		if self.re_order_level or len(self.doclist.get({"parentfield": "item_reorder", 
-				"material_request_type": "Purchase"})):
+		if self.re_order_level or len(self.get("item_reorder", {"material_request_type": "Purchase"})):
 			if not self.is_purchase_item:
 				frappe.msgprint(_("""To set reorder level, item must be Purchase Item"""), 
 					raise_exception=1)
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index f9ba9b5..312a5a3 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -12,8 +12,8 @@
 
 from erpnext.controllers.buying_controller import BuyingController
 class MaterialRequest(BuyingController):
-		self.tname = 'Material Request Item'
-		self.fname = 'indent_details'
+	tname = 'Material Request Item'
+	fname = 'indent_details'
 
 	def check_if_already_pulled(self):
 		pass#if self.[d.sales_order_no for d in self.get('indent_details')]
@@ -55,7 +55,7 @@
 	# Validate
 	# ---------------------
 	def validate(self):
-		super(DocType, self).validate()
+		super(MaterialRequest, self).validate()
 		
 		self.validate_schedule_date()
 		self.validate_uom_is_integer("uom", "qty")
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index 755c110..5a09121 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -11,6 +11,7 @@
 from frappe.model.document import Document
 
 class PackedItem(Document):
+	pass
 		
 def get_sales_bom_items(item_code):
 	return frappe.db.sql("""select t1.item_code, t1.qty, t1.uom 
@@ -62,7 +63,7 @@
 	"""make packing list for sales bom item"""
 	packing_list_idx = 0
 	parent_items = []
-	for d in obj.doclist.get({"parentfield": item_table_fieldname}):
+	for d in obj.get(item_table_fieldname):
 		warehouse = (item_table_fieldname == "sales_order_details") \
 			and d.warehouse or d.warehouse
 		if frappe.db.get_value("Sales BOM", {"new_item_code": d.item_code}):
@@ -73,23 +74,22 @@
 			if [d.item_code, d.name] not in parent_items:
 				parent_items.append([d.item_code, d.name])
 			
-	obj.doclist = cleanup_packing_list(obj, parent_items)
-	
-	return obj.doclist
-	
+	cleanup_packing_list(obj, parent_items)
+		
 def cleanup_packing_list(obj, parent_items):
 	"""Remove all those child items which are no longer present in main item table"""
 	delete_list = []
 	for d in obj.get("packing_details"):
 		if [d.parent_item, d.parent_detail_docname] not in parent_items:
 			# mark for deletion from doclist
-			delete_list.append([d.parent_item, d.parent_detail_docname])
+			delete_list.append(d)
 
 	if not delete_list:
-		return obj.doclist
+		return obj
 	
-	# delete from doclist
-	obj.doclist = frappe.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname] 
-		not in delete_list, obj.doclist))
-		
-	return obj.doclist
\ No newline at end of file
+	packing_details = obj.get("packing_details")
+	obj.set("packing_details", [])
+	for d in packing_details:
+		if d not in delete_list:
+			obj.append("packing_details", d)
+	
\ No newline at end of file
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 9d363d3..8dde16b 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -12,20 +12,20 @@
 
 from erpnext.controllers.buying_controller import BuyingController
 class PurchaseReceipt(BuyingController):
-		self.tname = 'Purchase Receipt Item'
-		self.fname = 'purchase_receipt_details'
-		self.count = 0
-		self.status_updater = [{
-			'source_dt': 'Purchase Receipt Item',
-			'target_dt': 'Purchase Order Item',
-			'join_field': 'prevdoc_detail_docname',
-			'target_field': 'received_qty',
-			'target_parent_dt': 'Purchase Order',
-			'target_parent_field': 'per_received',
-			'target_ref_field': 'qty',
-			'source_field': 'qty',
-			'percent_join_field': 'prevdoc_docname',
-		}]
+	tname = 'Purchase Receipt Item'
+	fname = 'purchase_receipt_details'
+	count = 0
+	status_updater = [{
+		'source_dt': 'Purchase Receipt Item',
+		'target_dt': 'Purchase Order Item',
+		'join_field': 'prevdoc_detail_docname',
+		'target_field': 'received_qty',
+		'target_parent_dt': 'Purchase Order',
+		'target_parent_field': 'per_received',
+		'target_ref_field': 'qty',
+		'source_field': 'qty',
+		'percent_join_field': 'prevdoc_docname',
+	}]
 		
 	def onload(self):
 		billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item`
@@ -35,7 +35,7 @@
 			self.set("__billing_complete", billed_qty[0][0] == total_qty)
 
 	def validate(self):
-		super(DocType, self).validate()
+		super(PurchaseReceipt, self).validate()
 		
 		self.po_required()
 
@@ -101,7 +101,7 @@
 			Please enter a valid Challan No.", raise_exception=1)
 			
 	def validate_with_previous_doc(self):
-		super(DocType, self).validate_with_previous_doc(self.tname, {
+		super(PurchaseReceipt, self).validate_with_previous_doc(self.tname, {
 			"Purchase Order": {
 				"ref_dn_field": "prevdoc_docname",
 				"compare_fields": [["supplier", "="], ["company", "="],	["currency", "="]],
@@ -114,7 +114,7 @@
 		})
 		
 		if cint(frappe.defaults.get_global_default('maintain_same_rate')):
-			super(DocType, self).validate_with_previous_doc(self.tname, {
+			super(PurchaseReceipt, self).validate_with_previous_doc(self.tname, {
 				"Purchase Order Item": {
 					"ref_dn_field": "prevdoc_detail_docname",
 					"compare_fields": [["rate", "="]],
@@ -289,7 +289,7 @@
 	def get_gl_entries(self, warehouse_account=None):
 		against_stock_account = self.get_company_default("stock_received_but_not_billed")
 		
-		gl_entries = super(DocType, self).get_gl_entries(warehouse_account, against_stock_account)
+		gl_entries = super(PurchaseReceipt, self).get_gl_entries(warehouse_account, against_stock_account)
 		return gl_entries
 		
 	
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 6191811..0999da0 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -23,7 +23,7 @@
 from erpnext.controllers.stock_controller import StockController
 
 class StockEntry(StockController):
-		self.fname = 'mtn_details' 
+	fname = 'mtn_details' 
 		
 	def validate(self):
 		self.validate_posting_time()
@@ -83,8 +83,7 @@
 		source_mandatory = ["Material Issue", "Material Transfer", "Purchase Return"]
 		target_mandatory = ["Material Receipt", "Material Transfer", "Sales Return"]
 		
-		validate_for_manufacture_repack = any([d.bom_no for d in self.doclist.get(
-			{"parentfield": "mtn_details"})])
+		validate_for_manufacture_repack = any([d.bom_no for d in self.get("mtn_details")])
 
 		if self.purpose in source_mandatory and self.purpose not in target_mandatory:
 			self.to_warehouse = None
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 2ddf831..1cc9c17 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -279,10 +279,9 @@
 		if not self.cost_center:
 			msgprint(_("Please enter Cost Center"), raise_exception=1)
 			
-		return super(DocType, self).get_gl_entries(warehouse_account, 		
+		return super(StockReconciliation, self).get_gl_entries(warehouse_account, 		
 			self.expense_account, self.cost_center)
 		
-			
 	def validate_expense_account(self):
 		if not cint(frappe.defaults.get_global_default("auto_accounting_for_stock")):
 			return
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 48f5a3d..770c6df 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
@@ -9,7 +9,7 @@
 
 from frappe.model.document import Document
 
-class StockUomReplaceUtility(Document):
+class StockUOMReplaceUtility(Document):
 	def validate_mandatory(self):
 		if not cstr(self.item_code):
 			msgprint("Please Enter an Item.")
diff --git a/erpnext/support/doctype/newsletter/newsletter.py b/erpnext/support/doctype/newsletter/newsletter.py
index 8518a37..2dce58a 100644
--- a/erpnext/support/doctype/newsletter/newsletter.py
+++ b/erpnext/support/doctype/newsletter/newsletter.py
@@ -10,12 +10,11 @@
 from frappe.model.document import Document
 
 class Newsletter(Document):
-		
 	def onload(self):
 		if self.email_sent:
-			self.set("__status_count", dict(frappe.db.sql("""select status, count(*))
+			self.set("__status_count", dict(frappe.db.sql("""select status, count(*)
 				from `tabBulk Email` where ref_doctype=%s and ref_docname=%s
-				group by status""", (self.doctype, self.name))) or None
+				group by status""", (self.doctype, self.name))) or None)
 
 	def test_send(self, doctype="Lead"):
 		self.recipients = self.test_email_id.split(",")
diff --git a/erpnext/support/doctype/support_email_settings/support_email_settings.py b/erpnext/support/doctype/support_email_settings/support_email_settings.py
index e4e33f8..1efa628 100644
--- a/erpnext/support/doctype/support_email_settings/support_email_settings.py
+++ b/erpnext/support/doctype/support_email_settings/support_email_settings.py
@@ -7,6 +7,8 @@
 import frappe
 
 from frappe.model.document import Document
+from frappe.utils.email_lib.receive import POP3Mailbox
+import _socket, poplib
 
 class SupportEmailSettings(Document):
 		
@@ -14,10 +16,7 @@
 		"""
 			Checks support ticket email settings
 		"""
-		if self.sync_support_mails and self.mail_server:
-			from frappe.utils.email_lib.receive import POP3Mailbox
-						import _socket, poplib
-			
+		if self.sync_support_mails and self.mail_server:			
 			inc_email = frappe.get_doc('Incoming Email Settings')
 			# inc_email.encode()
 			inc_email.host = self.mail_server
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.py b/erpnext/utilities/doctype/rename_tool/rename_tool.py
index 7ee46df..42c69f6 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.py
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py
@@ -10,6 +10,7 @@
 from frappe.model.document import Document
 
 class RenameTool(Document):
+	pass
 		
 @frappe.whitelist()
 def get_doctypes():
diff --git a/erpnext/utilities/doctype/sms_control/sms_control.py b/erpnext/utilities/doctype/sms_control/sms_control.py
index 6b8c684..4408212 100644
--- a/erpnext/utilities/doctype/sms_control/sms_control.py
+++ b/erpnext/utilities/doctype/sms_control/sms_control.py
@@ -10,7 +10,7 @@
 
 from frappe.model.document import Document
 
-class SmsControl(Document):
+class SMSControl(Document):
 
 	def validate_receiver_nos(self,receiver_list):
 		validated_receiver_list = []
diff --git a/erpnext/utilities/doctype/sms_log/sms_log.py b/erpnext/utilities/doctype/sms_log/sms_log.py
index 573054e..771cb69 100644
--- a/erpnext/utilities/doctype/sms_log/sms_log.py
+++ b/erpnext/utilities/doctype/sms_log/sms_log.py
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class SmsLog(Document):
+class SMSLog(Document):
 	pass
diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py
index 4be3d6f..aa30b68 100644
--- a/erpnext/utilities/transaction_base.py
+++ b/erpnext/utilities/transaction_base.py
@@ -63,7 +63,7 @@
 			is_child = val.get("is_child_table")
 			ref_doc = {}
 			item_ref_dn = []
-			for d in self.doclist.get({"doctype": source_dt}):
+			for d in self.get_all_children(source_dt):
 				ref_dn = d.get(val["ref_dn_field"])
 				if ref_dn:
 					if is_child:
@@ -96,17 +96,18 @@
 
 class UOMMustBeIntegerError(frappe.ValidationError): pass
 
-def validate_uom_is_integer(doclist, uom_field, qty_fields):
+def validate_uom_is_integer(doc, uom_field, qty_fields):
 	if isinstance(qty_fields, basestring):
 		qty_fields = [qty_fields]
 	
+	distinct_uoms = list(set([d.get(uom_field) for d in doc.get_all_children()]))
 	integer_uoms = filter(lambda uom: frappe.db.get_value("UOM", uom, 
-		"must_be_whole_number") or None, doclist.get_distinct_values(uom_field))
+		"must_be_whole_number") or None, distinct_uoms)
 		
 	if not integer_uoms:
 		return
 
-	for d in doclist:
+	for d in doc.get_all_children():
 		if d.get(uom_field) in integer_uoms:
 			for f in qty_fields:
 				if d.get(f):