frappe/frappe#478
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 4c3e4d1..0c88aeb 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -9,10 +9,10 @@
 
 get_value = frappe.db.get_value
 
-class DocType:
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d,dl
-		self.nsm_parent_field = 'parent_account'
+from frappe.model.document import Document
+
+class Account(Document):
+	nsm_parent_field = 'parent_account'
 
 	def autoname(self):
 		self.doc.name = self.doc.account_name.strip() + ' - ' + \
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
index 3e01eea..ab7e8ab 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
@@ -8,9 +8,9 @@
 from frappe import _
 from frappe.utils import cint
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class AccountsSettings(Document):
 
 	def on_update(self):
 		frappe.db.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
diff --git a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
index 859c9d0..5ad447c 100644
--- a/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
+++ b/erpnext/accounts/doctype/bank_reconciliation/bank_reconciliation.py
@@ -5,17 +5,11 @@
 import frappe
 
 from frappe.utils import cstr, flt, getdate, now, nowdate
-from frappe.model import db_exists
-from frappe.model.doc import addchild
-from frappe.model.bean import getlist, copy_doclist
 from frappe import msgprint
 
-	
+from frappe.model.document import Document
 
-
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+class BankReconciliation(Document):
 
 	def get_details(self):
 		if not (self.doc.bank_account and self.doc.from_date and self.doc.to_date):
@@ -24,11 +18,11 @@
 	
 		dl = frappe.db.sql("select t1.name, t1.cheque_no, t1.cheque_date, t2.debit, t2.credit, t1.posting_date, t2.against_account from `tabJournal Voucher` t1, `tabJournal Voucher Detail` t2 where t2.parent = t1.name and t2.account = %s and (clearance_date is null or clearance_date = '0000-00-00' or clearance_date = '') and t1.posting_date >= %s and t1.posting_date <= %s and t1.docstatus=1", (self.doc.bank_account, self.doc.from_date, self.doc.to_date))
 		
-		self.doclist = self.doc.clear_table(self.doclist, 'entries')
+		self.set('entries', [])
 		self.doc.total_amount = 0.0
 
 		for d in dl:
-			nl = addchild(self.doc, 'entries', 'Bank Reconciliation Detail', self.doclist)
+			nl = self.doc.append('entries', {})
 			nl.posting_date = cstr(d[5])
 			nl.voucher_id = cstr(d[0])
 			nl.cheque_number = cstr(d[1])
@@ -40,7 +34,7 @@
 
 	def update_details(self):
 		vouchers = []
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if d.clearance_date:
 				if d.cheque_date and getdate(d.clearance_date) < getdate(d.cheque_date):
 					msgprint("Clearance Date can not be before Cheque Date (Row #%s)" % 
diff --git a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py
index 26c87f1..93dca1d 100644
--- a/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py
+++ b/erpnext/accounts/doctype/bank_reconciliation_detail/bank_reconciliation_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class BankReconciliationDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/budget_detail/budget_detail.py b/erpnext/accounts/doctype/budget_detail/budget_detail.py
index 26c87f1..58106a0 100644
--- a/erpnext/accounts/doctype/budget_detail/budget_detail.py
+++ b/erpnext/accounts/doctype/budget_detail/budget_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class BudgetDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py
index 5173097..069c4d3 100644
--- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.py
+++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.py
@@ -5,21 +5,18 @@
 import frappe
 
 from frappe.utils import flt
-from frappe.model.doc import addchild
 from frappe.model.bean import getlist
 from frappe import msgprint, _
 
-class DocType:
-	def __init__(self,doc,doclist=[]):
-		self.doc,self.doclist = doc,doclist
-		
+from frappe.model.document import Document
+
+class BudgetDistribution(Document):
 	def get_months(self):
 		month_list = ['January','February','March','April','May','June','July','August','September',
 		'October','November','December']
 		idx =1
 		for m in month_list:
-			mnth = addchild(self.doc, 'budget_distribution_details',
-				'Budget Distribution Detail', self.doclist)
+			mnth = self.append('budget_distribution_details')
 			mnth.month = m or ''
 			mnth.idx = idx
 			idx += 1
diff --git a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py
index 26c87f1..84d8060 100644
--- a/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py
+++ b/erpnext/accounts/doctype/budget_distribution_detail/budget_distribution_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class BudgetDistributionDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py
index fdf8b30..b832554 100644
--- a/erpnext/accounts/doctype/c_form/c_form.py
+++ b/erpnext/accounts/doctype/c_form/c_form.py
@@ -6,15 +6,16 @@
 from frappe.utils import flt, getdate
 from frappe.model.bean import getlist
 
-class DocType:
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d,dl
+from frappe.model.document import Document
+
+class CForm(Document):
+
 
 	def validate(self):
 		"""Validate invoice that c-form is applicable 
 			and no other c-form is received for that"""
 
-		for d in getlist(self.doclist, 'invoice_details'):
+		for d in self.get('invoice_details'):
 			if d.invoice_no:
 				inv = frappe.db.sql("""select c_form_applicable, c_form_no from
 					`tabSales Invoice` where name = %s and docstatus = 1""", d.invoice_no)
@@ -46,7 +47,7 @@
 			where c_form_no=%s""", self.doc.name)
 		
 	def set_cform_in_sales_invoices(self):
-		inv = [d.invoice_no for d in getlist(self.doclist, 'invoice_details')]
+		inv = [d.invoice_no for d in self.get('invoice_details')]
 		if inv:
 			frappe.db.sql("""update `tabSales Invoice` set c_form_no=%s, modified=%s 
 				where name in (%s)""" % ('%s', '%s', ', '.join(['%s'] * len(inv))), 
@@ -60,7 +61,7 @@
 			frappe.msgprint("Please enter atleast 1 invoice in the table", raise_exception=1)
 
 	def set_total_invoiced_amount(self):
-		total = sum([flt(d.grand_total) for d in getlist(self.doclist, 'invoice_details')])
+		total = sum([flt(d.grand_total) for d in self.get('invoice_details')])
 		frappe.db.set(self.doc, 'total_invoiced_amount', total)
 
 	def get_invoice_details(self, invoice_no):
diff --git a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py
index 26c87f1..8e3bc29 100644
--- a/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py
+++ b/erpnext/accounts/doctype/c_form_invoice_detail/c_form_invoice_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class CFormInvoiceDetail(Document):
+	pass
\ No newline at end of file
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 16c6acf..3b377fc 100644
--- a/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py
+++ b/erpnext/accounts/doctype/chart_of_accounts/chart_of_accounts.py
@@ -7,9 +7,9 @@
 from unidecode import unidecode
 
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class ChartOfAccounts(Document):
 		self.no_report_type = False
 		
 	def create_accounts(self, company):
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py
index e02496f..720b0ba 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.py
+++ b/erpnext/accounts/doctype/cost_center/cost_center.py
@@ -8,9 +8,8 @@
 
 from frappe.utils.nestedset import DocTypeNestedSet
 
-class DocType(DocTypeNestedSet):
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d,dl
+class CostCenter(DocTypeNestedSet):
+
 		self.nsm_parent_field = 'parent_cost_center'
 				
 	def autoname(self):
@@ -54,7 +53,7 @@
 
 	def validate_budget_details(self):
 		check_acc_list = []
-		for d in getlist(self.doclist, 'budget_details'):
+		for d in self.get('budget_details'):
 			if self.doc.group_or_ledger=="Group":
 				msgprint("Budget cannot be set for Group Cost Centers", raise_exception=1)
 				
diff --git a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
index 3918751..34110d3 100644
--- a/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/erpnext/accounts/doctype/fiscal_year/fiscal_year.py
@@ -6,9 +6,9 @@
 from frappe import msgprint, _
 from frappe.utils import getdate
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class FiscalYear(Document):
 		
 	def set_as_default(self):
 		frappe.db.set_value("Global Defaults", None, "current_fiscal_year", self.doc.name)
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index 9e1dbb7..b6a5295 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -7,9 +7,9 @@
 from frappe.utils import flt, fmt_money, getdate
 from frappe import _
 	
-class DocType:
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class GlEntry(Document):
 
 	def validate(self):
 		self.check_mandatory()
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
index 57c14b0..9884b57 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
@@ -5,16 +5,13 @@
 import frappe
 
 from frappe.utils import cint, cstr, flt, fmt_money, formatdate, getdate
-from frappe.model.doc import addchild
-from frappe.model.bean import getlist
 from frappe import msgprint, _
 from erpnext.setup.utils import get_company_currency
 
 from erpnext.controllers.accounts_controller import AccountsController
 
-class DocType(AccountsController):
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d,dl
+class JournalVoucher(AccountsController):
+
 		self.master_type = {}
 		self.credit_days_for = {}
 		self.credit_days_global = -1
@@ -57,7 +54,7 @@
 		#	frappe.delete_doc("Journal Voucher", self.doc.amended_from)
 
 	def validate_debit_credit(self):
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if d.debit and d.credit:
 				msgprint("You cannot credit and debit same account at the same time.", 
 				 	raise_exception=1)
@@ -72,7 +69,7 @@
 			msgprint("Reference No is mandatory if you entered Reference Date", raise_exception=1)
 
 	def validate_entries_for_advance(self):
-		for d in getlist(self.doclist,'entries'):
+		for d in self.get('entries'):
 			if not d.is_advance and not d.against_voucher and \
 					not d.against_invoice and not d.against_jv:
 				master_type = frappe.db.get_value("Account", d.account, "master_type")
@@ -82,7 +79,7 @@
 						Account %s if this is an advance entry." % d.account)
 
 	def validate_against_jv(self):
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if d.against_jv:
 				if d.against_jv == self.doc.name:
 					msgprint("You can not enter current voucher in 'Against JV' column",
@@ -96,7 +93,7 @@
 		# Debit = Credit
 		debit, credit = 0.0, 0.0
 		debit_list, credit_list = [], []
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			debit += flt(d.debit, 2)
 			credit += flt(d.credit, 2)
 			if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account)
@@ -110,7 +107,7 @@
 			 	(self.doc.total_debit-self.doc.total_credit), raise_exception=1)
 		
 		# update against account
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if flt(d.debit) > 0: d.against_account = ', '.join(credit_list)
 			if flt(d.credit) > 0: d.against_account = ', '.join(debit_list)
 
@@ -123,7 +120,7 @@
 			else :
 				msgprint("Please enter Reference date", raise_exception=1)
 		
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if d.against_invoice and d.credit:
 				currency = frappe.db.get_value("Sales Invoice", d.against_invoice, "currency")
 				r.append('%s %s against Invoice: %s' % 
@@ -152,7 +149,7 @@
 		else:
 			# check account type whether supplier or customer
 			exists = False
-			for d in getlist(self.doclist, 'entries'):
+			for d in self.get('entries'):
 				account_type = frappe.db.get_value("Account", d.account, "account_type")
 				if account_type in ["Supplier", "Customer"]:
 					exists = True
@@ -165,7 +162,7 @@
 				self.doc.aging_date = self.doc.posting_date
 
 	def set_print_format_fields(self):
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			account_type, master_type = frappe.db.get_value("Account", d.account, 
 				["account_type", "master_type"])
 				
@@ -191,7 +188,7 @@
 		
 		# Get List of Customer Account
 		acc_list = filter(lambda d: frappe.db.get_value("Account", d.account, 
-		 	"master_type")=='Customer', getlist(self.doclist,'entries'))
+		 	"master_type")=='Customer', self.get('entries'))
 		
 		for d in acc_list:
 			credit_days = self.get_credit_days_for(d.account)
@@ -228,7 +225,7 @@
 		return self.is_approving_authority
 
 	def check_account_against_entries(self):
-		for d in self.doclist.get({"parentfield": "entries"}):
+		for d in self.get("entries"):
 			if d.against_invoice and frappe.db.get_value("Sales Invoice", 
 					d.against_invoice, "debit_to") != d.account:
 				frappe.throw(_("Row #") + cstr(d.idx) +  ": " +
@@ -246,7 +243,7 @@
 			self.check_account_against_entries()
 		
 		gl_map = []
-		for d in self.doclist.get({"parentfield": "entries"}):
+		for d in self.get("entries"):
 			if d.debit or d.credit:
 				gl_map.append(
 					self.get_gl_dict({
@@ -266,21 +263,21 @@
 			make_gl_entries(gl_map, cancel=cancel, adv_adj=adv_adj)
 			
 	def check_credit_limit(self):
-		for d in self.doclist.get({"parentfield": "entries"}):
+		for d in self.get("entries"):
 			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)
 
 	def get_balance(self):
-		if not getlist(self.doclist,'entries'):
+		if not self.get('entries'):
 			msgprint("Please enter atleast 1 entry in 'GL Entries' table")
 		else:
 			flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
 			diff = flt(self.doc.difference, 2)
 			
 			# If any row without amount, set the diff on that row
-			for d in getlist(self.doclist,'entries'):
+			for d in self.get('entries'):
 				if not d.credit and not d.debit and diff != 0:
 					if diff>0:
 						d.credit = diff
@@ -290,25 +287,25 @@
 					
 			# Set the diff in a new row
 			if flag == 0 and diff != 0:
-				jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
+				jd = self.doc.append('entries', {})
 				if diff>0:
 					jd.credit = abs(diff)
 				elif diff<0:
 					jd.debit = abs(diff)
 					
 			# Set the total debit, total credit and difference
-			for d in getlist(self.doclist,'entries'):
+			for d in self.get('entries'):
 				self.doc.total_debit += flt(d.debit, 2)
 				self.doc.total_credit += flt(d.credit, 2)
 
 			self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
 
 	def get_outstanding_invoices(self):
-		self.doclist = self.doc.clear_table(self.doclist, 'entries')
+		self.set('entries', [])
 		total = 0
 		for d in self.get_values():
 			total += flt(d[2])
-			jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
+			jd = self.doc.append('entries', {})
 			jd.account = cstr(d[1])
 			if self.doc.write_off_based_on == 'Accounts Receivable':
 				jd.credit = flt(d[2])
@@ -317,7 +314,7 @@
 				jd.debit = flt(d[2])
 				jd.against_voucher = cstr(d[0])
 			jd.save(1)
-		jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
+		jd = self.doc.append('entries', {})
 		if self.doc.write_off_based_on == 'Accounts Receivable':
 			jd.debit = total
 		elif self.doc.write_off_based_on == 'Accounts Payable':
diff --git a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py
index 26c87f1..36700d2 100644
--- a/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py
+++ b/erpnext/accounts/doctype/journal_voucher_detail/journal_voucher_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class JournalVoucherDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py
index 26c87f1..ddabf89 100644
--- a/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py
+++ b/erpnext/accounts/doctype/mode_of_payment/mode_of_payment.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ModeOfPayment(Document):
+	pass
\ No newline at end of file
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 e0bd61d..8260dea 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
@@ -5,14 +5,12 @@
 import frappe
 
 from frappe.utils import flt
-from frappe.model.doc import addchild
 from frappe.model.bean import getlist
 from frappe import msgprint
 
-class DocType:
-	def __init__(self, doc, doclist):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class PaymentToInvoiceMatchingTool(Document):
 	
 	def set_account_type(self):
 		self.doc.account_type = ""
@@ -49,7 +47,7 @@
 			Payment entry will be decided based on account type (Dr/Cr)
 		"""
 
-		self.doclist = self.doc.clear_table(self.doclist, 'ir_payment_details')		
+		self.set('ir_payment_details', [])		
 		gle = self.get_gl_entries()
 		self.create_payment_table(gle)
 
@@ -79,8 +77,7 @@
 
 	def create_payment_table(self, gle):
 		for d in gle:
-			ch = addchild(self.doc, 'ir_payment_details', 
-				'Payment to Invoice Matching Tool Detail', self.doclist)
+			ch = self.doc.append('ir_payment_details', {})
 			ch.voucher_no = d.get('voucher_no')
 			ch.posting_date = d.get('posting_date')
 			ch.amt_due =  self.doc.account_type == 'debit' and flt(d.get('amt_due')) \
@@ -106,7 +103,7 @@
 			msgprint("Please select valid Voucher No to proceed", raise_exception=1)
 		
 		lst = []
-		for d in getlist(self.doclist, 'ir_payment_details'):
+		for d in self.get('ir_payment_details'):
 			if flt(d.amt_to_be_reconciled) > 0:
 				args = {
 					'voucher_no' : d.voucher_no,
diff --git a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py
index 26c87f1..a7bf686 100644
--- a/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py
+++ b/erpnext/accounts/doctype/payment_to_invoice_matching_tool_detail/payment_to_invoice_matching_tool_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PaymentToInvoiceMatchingToolDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py
index 100bd95..cdc20e8 100644
--- a/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py
+++ b/erpnext/accounts/doctype/period_closing_voucher/period_closing_voucher.py
@@ -7,9 +7,7 @@
 from frappe import _
 from erpnext.controllers.accounts_controller import AccountsController
 
-class DocType(AccountsController):
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d, dl
+class PeriodClosingVoucher(AccountsController):
 		self.year_start_date = ''
 
 	def validate(self):
diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.py b/erpnext/accounts/doctype/pos_setting/pos_setting.py
index 29ae298..61d405b 100755
--- a/erpnext/accounts/doctype/pos_setting/pos_setting.py
+++ b/erpnext/accounts/doctype/pos_setting/pos_setting.py
@@ -6,10 +6,9 @@
 from frappe import msgprint, _
 from frappe.utils import cint
 
-class DocType:
-	def __init__(self,doc,doclist):
-		self.doc, self.doclist = doc,doclist
+from frappe.model.document import Document
 
+class PosSetting(Document):
 	def get_series(self):
 		import frappe.model.doctype
 		docfield = frappe.model.doctype.get('Sales Invoice')
diff --git a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
index 5073718..831efac 100644
--- a/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
+++ b/erpnext/accounts/doctype/pricing_rule/pricing_rule.py
@@ -8,9 +8,7 @@
 from frappe import throw, _
 from frappe.model.controller import DocListController
 
-class DocType(DocListController):
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+class PricingRule(DocListController):
 		
 	def validate(self):
 		self.validate_mandatory()
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index c059d2d..c07b2c8 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -15,22 +15,20 @@
 from erpnext.controllers.buying_controller import BuyingController
 from erpnext.accounts.party import get_party_account, get_due_date
 
-class DocType(BuyingController):
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d, dl 
-		self.tname = 'Purchase Invoice Item'
-		self.fname = 'entries'
-		self.status_updater = [{
-			'source_dt': 'Purchase Invoice Item',
-			'target_dt': 'Purchase Order Item',
-			'join_field': 'po_detail',
-			'target_field': 'billed_amt',
-			'target_parent_dt': 'Purchase Order',
-			'target_parent_field': 'per_billed',
-			'target_ref_field': 'amount',
-			'source_field': 'amount',
-			'percent_join_field': 'purchase_order',
-		}]
+class PurchaseInvoice(BuyingController):
+	tname = 'Purchase Invoice Item'
+	fname = 'entries'
+	status_updater = [{
+		'source_dt': 'Purchase Invoice Item',
+		'target_dt': 'Purchase Order Item',
+		'join_field': 'po_detail',
+		'target_field': 'billed_amt',
+		'target_parent_dt': 'Purchase Order',
+		'target_parent_field': 'per_billed',
+		'target_ref_field': 'amount',
+		'source_field': 'amount',
+		'percent_join_field': 'purchase_order',
+	}]
 		
 	def validate(self):
 		if not self.doc.is_opening:
@@ -71,7 +69,7 @@
 			"Purchase Invoice Advance", "advance_allocation_details", "debit")
 		
 	def check_active_purchase_items(self):
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if d.item_code:		# extra condn coz item_code is not mandatory in PV
 				valid_item = frappe.db.sql("select docstatus,is_purchase_item from tabItem where name = %s",d.item_code)
 				if valid_item[0][0] == 2:
@@ -125,7 +123,7 @@
 	# ---------------------
 	def check_for_stopped_status(self):
 		check_list = []
-		for d in getlist(self.doclist,'entries'):
+		for d in self.get('entries'):
 			if d.purchase_order and not d.purchase_order in check_list and not d.purchase_receipt:
 				check_list.append(d.purhcase_order)
 				stopped = frappe.db.sql("select name from `tabPurchase Order` where status = 'Stopped' and name = %s", d.purchase_order)
@@ -187,7 +185,7 @@
 		
 		against_accounts = []
 		stock_items = self.get_stock_items()
-		for item in self.doclist.get({"parentfield": "entries"}):
+		for item in self.get("entries"):
 			if auto_accounting_for_stock and item.item_code in stock_items \
 					and self.doc.is_opening == 'No':
 				# in case of auto inventory accounting, against expense account is always
@@ -210,14 +208,14 @@
 
 	def po_required(self):
 		if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
-			 for d in getlist(self.doclist,'entries'):
+			 for d in self.get('entries'):
 				 if not d.purchase_order:
 					 msgprint("Purchse Order No. required against item %s"%d.item_code)
 					 raise Exception
 
 	def pr_required(self):
 		if frappe.db.get_value("Buying Settings", None, "pr_required") == 'Yes':
-			 for d in getlist(self.doclist,'entries'):
+			 for d in self.get('entries'):
 				 if not d.purchase_receipt:
 					 msgprint("Purchase Receipt No. required against item %s"%d.item_code)
 					 raise Exception
@@ -227,7 +225,7 @@
 			msgprint("Please enter Write Off Account", raise_exception=1)
 
 	def check_prev_docstatus(self):
-		for d in getlist(self.doclist,'entries'):
+		for d in self.get('entries'):
 			if d.purchase_order:
 				submitted = frappe.db.sql("select name from `tabPurchase Order` where docstatus = 1 and name = %s", d.purchase_order)
 				if not submitted:
@@ -247,7 +245,7 @@
 		"""
 		
 		lst = []
-		for d in getlist(self.doclist, 'advance_allocation_details'):
+		for d in self.get('advance_allocation_details'):
 			if flt(d.allocated_amount) > 0:
 				args = {
 					'voucher_no' : d.journal_voucher, 
@@ -299,7 +297,7 @@
 	
 		# tax table gl entries
 		valuation_tax = {}
-		for tax in self.doclist.get({"parentfield": "other_charges"}):
+		for tax in self.get("other_charges"):
 			if tax.category in ("Total", "Valuation and Total") and flt(tax.tax_amount):
 				gl_entries.append(
 					self.get_gl_dict({
@@ -325,7 +323,7 @@
 		# item gl entries
 		stock_item_and_auto_accounting_for_stock = False
 		stock_items = self.get_stock_items()
-		for item in self.doclist.get({"parentfield": "entries"}):
+		for item in self.get("entries"):
 			if auto_accounting_for_stock and item.item_code in stock_items:
 				if flt(item.valuation_rate):
 					# if auto inventory accounting enabled and stock item, 
@@ -404,7 +402,7 @@
 		
 	def update_raw_material_cost(self):
 		if self.sub_contracted_items:
-			for d in self.doclist.get({"parentfield": "entries"}):
+			for d in self.get("entries"):
 				rm_cost = frappe.db.sql("""select raw_material_cost / quantity 
 					from `tabBOM` where item = %s and is_default = 1 and docstatus = 1 
 					and is_active = 1 """, (d.item_code,))
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index b5942e3..28bd2d1 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -107,7 +107,7 @@
 			["_Test Item Home Desktop 100", 90, 59],
 			["_Test Item Home Desktop 200", 135, 177]
 		]
-		for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
+		for i, item in enumerate(wrapper.get("entries")):
 			self.assertEqual(item.item_code, expected_values[i][0])
 			self.assertEqual(item.item_tax_amount, expected_values[i][1])
 			self.assertEqual(item.valuation_rate, expected_values[i][2])
@@ -126,7 +126,7 @@
 			["_Test Account Discount - _TC", 168.03, 1512.30],
 		]
 		
-		for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})):
+		for i, tax in enumerate(wrapper.get("other_charges")):
 			self.assertEqual(tax.account_head, expected_values[i][0])
 			self.assertEqual(tax.tax_amount, expected_values[i][1])
 			self.assertEqual(tax.total, expected_values[i][2])
@@ -141,7 +141,7 @@
 			["_Test FG Item", 90, 7059],
 			["_Test Item Home Desktop 200", 135, 177]
 		]
-		for i, item in enumerate(wrapper.doclist.get({"parentfield": "entries"})):
+		for i, item in enumerate(wrapper.get("entries")):
 			self.assertEqual(item.item_code, expected_values[i][0])
 			self.assertEqual(item.item_tax_amount, expected_values[i][1])
 			self.assertEqual(item.valuation_rate, expected_values[i][2])
@@ -160,7 +160,7 @@
 			["_Test Account Discount - _TC", 168.03, 1512.30],
 		]
 
-		for i, tax in enumerate(wrapper.doclist.get({"parentfield": "other_charges"})):
+		for i, tax in enumerate(wrapper.get("other_charges")):
 			self.assertEqual(tax.account_head, expected_values[i][0])
 			self.assertEqual(tax.tax_amount, expected_values[i][1])
 			self.assertEqual(tax.total, expected_values[i][2])
diff --git a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py
index 26c87f1..9dc3b16 100644
--- a/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py
+++ b/erpnext/accounts/doctype/purchase_invoice_advance/purchase_invoice_advance.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PurchaseInvoiceAdvance(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py
index 26c87f1..580d989 100644
--- a/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py
+++ b/erpnext/accounts/doctype/purchase_invoice_item/purchase_invoice_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PurchaseInvoiceItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py
index 26c87f1..910e380 100644
--- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py
+++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PurchaseTaxesAndCharges(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
index eee6e9a..fb9a0ab 100644
--- a/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
+++ b/erpnext/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.py
@@ -3,15 +3,7 @@
 
 from __future__ import unicode_literals
 import frappe
+from frappe.model.document import Document
 
-from frappe.model import db_exists
-from frappe.model.bean import copy_doclist
-from frappe.model.code import get_obj
-
-	
-
-
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
\ No newline at end of file
+class PurchaseTaxesAndChargesMaster(Document):
+	pass
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index a3302c7..068d82c 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -20,27 +20,23 @@
 
 from erpnext.controllers.selling_controller import SellingController
 
-class DocType(SellingController):
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d, dl
-		self.log = []
-		self.tname = 'Sales Invoice Item'
-		self.fname = 'entries'
-		self.status_updater = [{
-			'source_dt': 'Sales Invoice Item',
-			'target_field': 'billed_amt',
-			'target_ref_field': 'amount',
-			'target_dt': 'Sales Order Item',
-			'join_field': 'so_detail',
-			'target_parent_dt': 'Sales Order',
-			'target_parent_field': 'per_billed',
-			'source_field': 'amount',
-			'join_field': 'so_detail',
-			'percent_join_field': 'sales_order',
-			'status_field': 'billing_status',
-			'keyword': 'Billed'
-		}]
-		
+class SalesInvoice(SellingController):
+	tname = 'Sales Invoice Item'
+	fname = 'entries'
+	status_updater = [{
+		'source_dt': 'Sales Invoice Item',
+		'target_field': 'billed_amt',
+		'target_ref_field': 'amount',
+		'target_dt': 'Sales Order Item',
+		'join_field': 'so_detail',
+		'target_parent_dt': 'Sales Order',
+		'target_parent_field': 'per_billed',
+		'source_field': 'amount',
+		'join_field': 'so_detail',
+		'percent_join_field': 'sales_order',
+		'status_field': 'billing_status',
+		'keyword': 'Billed'
+	}]
 
 	def validate(self):
 		super(DocType, self).validate()
@@ -194,7 +190,7 @@
 				self.doc.update_stock = cint(pos.get("update_stock"))
 
 			# set pos values in items
-			for item in self.doclist.get({"parentfield": "entries"}):
+			for item in self.get("entries"):
 				if item.fields.get('item_code'):
 					for fname, val in get_pos_settings_item_details(pos, 
 						frappe._dict(item.fields), pos).items():
@@ -207,7 +203,7 @@
 				self.doc.terms = frappe.db.get_value("Terms and Conditions", self.doc.tc_name, "terms")
 			
 			# fetch charges
-			if self.doc.charge and not len(self.doclist.get({"parentfield": "other_charges"})):
+			if self.doc.charge and not len(self.get("other_charges")):
 				self.set_taxes("other_charges", "taxes_and_charges")
 	
 	def get_advances(self):
@@ -226,7 +222,7 @@
 		"""
 		
 		lst = []
-		for d in getlist(self.doclist, 'advance_adjustment_details'):
+		for d in self.get('advance_adjustment_details'):
 			if flt(d.allocated_amount) > 0:
 				args = {
 					'voucher_no' : d.journal_voucher, 
@@ -262,7 +258,7 @@
 			
 	def validate_fixed_asset_account(self):
 		"""Validate Fixed Asset and whether Income Account Entered Exists"""
-		for d in getlist(self.doclist,'entries'):
+		for d in self.get('entries'):
 			item = frappe.db.sql("""select name,is_asset_item,is_sales_item from `tabItem` 
 				where name = %s and (ifnull(end_of_life,'')='' or end_of_life = '0000-00-00' 
 					or end_of_life > now())""", d.item_code)
@@ -314,7 +310,7 @@
 	def set_against_income_account(self):
 		"""Set against account for debit to account"""
 		against_acc = []
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if d.income_account not in against_acc:
 				against_acc.append(d.income_account)
 		self.doc.against_income_account = ','.join(against_acc)
@@ -329,7 +325,7 @@
 		dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
 		for i in dic:
 			if frappe.db.get_value('Selling Settings', None, dic[i]) == 'Yes':
-				for d in getlist(self.doclist,'entries'):
+				for d in self.get('entries'):
 					if frappe.db.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
 						and not d.fields[i.lower().replace(' ','_')]:
 						msgprint("%s is mandatory for stock item which is not mentioed against item: %s"%(i,d.item_code), raise_exception=1)
@@ -356,13 +352,13 @@
 
 
 	def validate_item_code(self):
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if not d.item_code:
 				msgprint("Please enter Item Code at line no : %s to update stock or remove check from Update Stock in Basic Info Tab." % (d.idx),
 				raise_exception=True)
 				
 	def validate_delivery_note(self):
-		for d in self.doclist.get({"parentfield": "entries"}):
+		for d in self.get("entries"):
 			if d.delivery_note:
 				msgprint("""Stock update can not be made against Delivery Note""", raise_exception=1)
 
@@ -381,12 +377,12 @@
 			frappe.db.set(self.doc, 'c_form_no', '')
 			
 	def update_current_stock(self):
-		for d in getlist(self.doclist, 'entries'):
+		for d in self.get('entries'):
 			if d.item_code and d.warehouse:
 				bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
 				d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
 
-		for d in getlist(self.doclist, 'packing_details'):
+		for d in self.get('packing_details'):
 			bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code =	%s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
 			d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
 			d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
@@ -414,14 +410,14 @@
 			if cint(self.doc.is_pos) == 1:
 				w = self.get_warehouse()
 				if w:
-					for d in getlist(self.doclist, 'entries'):
+					for d in self.get('entries'):
 						if not d.warehouse:
 							d.warehouse = cstr(w)
 
 			from erpnext.stock.doctype.packed_item.packed_item import make_packing_list
 			make_packing_list(self, 'entries')
 		else:
-			self.doclist = self.doc.clear_table(self.doclist, 'packing_details')
+			self.set('packing_details', [])
 			
 		if cint(self.doc.is_pos) == 1:
 			if flt(self.doc.paid_amount) == 0:
@@ -436,7 +432,7 @@
 			frappe.db.set(self.doc,'paid_amount',0)
 		
 	def check_prev_docstatus(self):
-		for d in getlist(self.doclist,'entries'):
+		for d in self.get('entries'):
 			if d.sales_order:
 				submitted = frappe.db.sql("""select name from `tabSales Order` 
 					where docstatus = 1 and name = %s""", d.sales_order)
@@ -510,7 +506,7 @@
 			)
 				
 	def make_tax_gl_entries(self, gl_entries):
-		for tax in self.doclist.get({"parentfield": "other_charges"}):
+		for tax in self.get("other_charges"):
 			if flt(tax.tax_amount_after_discount_amount):
 				gl_entries.append(
 					self.get_gl_dict({
@@ -524,7 +520,7 @@
 				
 	def make_item_gl_entries(self, gl_entries):			
 		# income account gl entries	
-		for item in self.doclist.get({"parentfield": "entries"}):
+		for item in self.get("entries"):
 			if flt(item.base_amount):
 				gl_entries.append(
 					self.get_gl_dict({
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 81d5572..a4a1f7b 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -54,11 +54,11 @@
 		}
 		
 		# check if children are saved
-		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+		self.assertEquals(len(si.get("entries")),
 			len(expected_values)-1)
 		
 		# check if item values are calculated
-		for d in si.doclist.get({"parentfield": "entries"}):
+		for d in si.get("entries"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
 		
@@ -79,7 +79,7 @@
 			"_Test Account Discount - _TC": [-180.78, 1627.05]
 		}
 		
-		for d in si.doclist.get({"parentfield": "other_charges"}):
+		for d in si.get("other_charges"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
 				
@@ -104,11 +104,11 @@
 		}
 		
 		# check if children are saved
-		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+		self.assertEquals(len(si.get("entries")),
 			len(expected_values)-1)
 		
 		# check if item values are calculated
-		for d in si.doclist.get({"parentfield": "entries"}):
+		for d in si.get("entries"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
 		
@@ -129,7 +129,7 @@
 			"_Test Account Discount - _TC": [-180.78, 1627.05]
 		}
 		
-		for d in si.doclist.get({"parentfield": "other_charges"}):
+		for d in si.get("other_charges"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
 				
@@ -160,11 +160,11 @@
 		}
 		
 		# check if children are saved
-		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+		self.assertEquals(len(si.get("entries")),
 			len(expected_values)-1)
 		
 		# check if item values are calculated
-		for d in si.doclist.get({"parentfield": "entries"}):
+		for d in si.get("entries"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
 		
@@ -186,7 +186,7 @@
 			"_Test Account Service Tax - _TC": [-18.03, -16.88, 1500]
 		}
 		
-		for d in si.doclist.get({"parentfield": "other_charges"}):
+		for d in si.get("other_charges"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
 				
@@ -245,7 +245,7 @@
 
 	def test_inclusive_rate_validations(self):
 		si = frappe.bean(copy=test_records[2])
-		for i, tax in enumerate(si.doclist.get({"parentfield": "other_charges"})):
+		for i, tax in enumerate(si.get("other_charges")):
 			tax.idx = i+1
 		
 		si.doclist[1].price_list_rate = 62.5
@@ -273,11 +273,11 @@
 		}
 		
 		# check if children are saved
-		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+		self.assertEquals(len(si.get("entries")),
 			len(expected_values)-1)
 		
 		# check if item values are calculated
-		for d in si.doclist.get({"parentfield": "entries"}):
+		for d in si.get("entries"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
 		
@@ -298,7 +298,7 @@
 			"_Test Account Discount - _TC": [-180.33, 1622.98]
 		}
 		
-		for d in si.doclist.get({"parentfield": "other_charges"}):
+		for d in si.get("other_charges"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
 		
@@ -326,11 +326,11 @@
 		}
 		
 		# check if children are saved
-		self.assertEquals(len(si.doclist.get({"parentfield": "entries"})),
+		self.assertEquals(len(si.get("entries")),
 			len(expected_values)-1)
 		
 		# check if item values are calculated
-		for d in si.doclist.get({"parentfield": "entries"}):
+		for d in si.get("entries"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.item_code][i])
 		
@@ -351,7 +351,7 @@
 			"_Test Account Discount - _TC": [-7245.01, 65205.16]
 		}
 		
-		for d in si.doclist.get({"parentfield": "other_charges"}):
+		for d in si.get("other_charges"):
 			for i, k in enumerate(expected_values["keys"]):
 				self.assertEquals(d.fields.get(k), expected_values[d.account_head][i])
 		
diff --git a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py
index 26c87f1..683ca8a 100644
--- a/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py
+++ b/erpnext/accounts/doctype/sales_invoice_advance/sales_invoice_advance.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalesInvoiceAdvance(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py
index 26c87f1..3fa0f2e 100644
--- a/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py
+++ b/erpnext/accounts/doctype/sales_invoice_item/sales_invoice_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalesInvoiceItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py
index 26c87f1..8f621de 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalesTaxesAndCharges(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py
index 047bbd4..0546ce7 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges_master/sales_taxes_and_charges_master.py
@@ -6,7 +6,7 @@
 from frappe.utils import cint
 from frappe.model.controller import DocListController
 
-class DocType(DocListController):		
+class SalesTaxesAndChargesMaster(DocListController):		
 	def validate(self):
 		if self.doc.is_default == 1:
 			frappe.db.sql("""update `tabSales Taxes and Charges Master` set is_default = 0 
diff --git a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
index fe5d7f9..e450e70 100644
--- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
+++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
@@ -14,13 +14,11 @@
 class FromGreaterThanToError(frappe.ValidationError): pass
 class ManyBlankToValuesError(frappe.ValidationError): pass
 
-class DocType(DocListController):
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+class ShippingRule(DocListController):
 		
 	def validate(self):
 		self.validate_value("calculate_based_on", "in", ["Net Total", "Net Weight"])
-		self.shipping_rule_conditions = self.doclist.get({"parentfield": "shipping_rule_conditions"})
+		self.shipping_rule_conditions = self.get("shipping_rule_conditions")
 		self.validate_from_to_values()
 		self.sort_shipping_rule_conditions()
 		self.validate_overlapping_shipping_rule_conditions()
diff --git a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py
index 968a25b..76d0a57 100644
--- a/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py
+++ b/erpnext/accounts/doctype/shipping_rule_condition/shipping_rule_condition.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ShippingRuleCondition(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 1b00efc..3805ec3 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -5,7 +5,6 @@
 
 import frappe
 from frappe.utils import nowdate, cstr, flt, now, getdate, add_months
-from frappe.model.doc import addchild
 from frappe import msgprint, throw, _
 from frappe.utils import formatdate
 from erpnext.utilities import build_filter_conditions
@@ -182,7 +181,7 @@
 		jvd = frappe.db.sql("""select cost_center, balance, against_account, is_advance 
 			from `tabJournal Voucher Detail` where name = %s""", d['voucher_detail_no'])
 		# new entry with balance amount
-		ch = addchild(jv_obj.doc, 'entries', 'Journal Voucher Detail')
+		ch = jv_obj.append("entries")
 		ch.account = d['account']
 		ch.cost_center = cstr(jvd[0][0])
 		ch.balance = cstr(jvd[0][1])
diff --git a/erpnext/buying/doctype/buying_settings/buying_settings.py b/erpnext/buying/doctype/buying_settings/buying_settings.py
index 9776fda..1f63798 100644
--- a/erpnext/buying/doctype/buying_settings/buying_settings.py
+++ b/erpnext/buying/doctype/buying_settings/buying_settings.py
@@ -6,9 +6,9 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class BuyingSettings(Document):
 		
 	def validate(self):
 		for key in ["supplier_type", "supp_master_name", "maintain_same_rate", "buying_price_list"]:
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.py b/erpnext/buying/doctype/purchase_common/purchase_common.py
index 3fefeba..8ae3649 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.py
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.py
@@ -11,10 +11,7 @@
 from erpnext.stock.doctype.item.item import get_last_purchase_details
 from erpnext.controllers.buying_controller import BuyingController
 
-class DocType(BuyingController):
-	def __init__(self, doc, doclist=None):
-		self.doc = doc
-		self.doclist = doclist
+class PurchaseCommon(BuyingController):
 	
 	def update_last_purchase_rate(self, obj, is_submit):
 		"""updates last_purchase_rate in item table for each item"""
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index fca61e3..587256e 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -11,10 +11,7 @@
 
 	
 from erpnext.controllers.buying_controller import BuyingController
-class DocType(BuyingController):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class PurchaseOrder(BuyingController):
 		self.tname = 'Purchase Order Item'
 		self.fname = 'po_details'
 		self.status_updater = [{
@@ -65,7 +62,7 @@
 		})
 
 	def get_schedule_dates(self):
-		for d in getlist(self.doclist, 'po_details'):
+		for d in self.get('po_details'):
 			if d.prevdoc_detail_docname and not d.schedule_date:
 				d.schedule_date = frappe.db.get_value("Material Request Item",
 						d.prevdoc_detail_docname, "schedule_date")
@@ -76,7 +73,7 @@
 	# Check for Stopped status 
 	def check_for_stopped_status(self, pc_obj):
 		check_list =[]
-		for d in getlist(self.doclist, 'po_details'):
+		for d in self.get('po_details'):
 			if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
 				check_list.append(d.prevdoc_docname)
 				pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
@@ -85,7 +82,7 @@
 	def update_bin(self, is_submit, is_stopped = 0):
 		from erpnext.stock.utils import update_bin
 		pc_obj = get_obj('Purchase Common')
-		for d in getlist(self.doclist, 'po_details'):
+		for d in self.get('po_details'):
 			#1. Check if is_stock_item == 'Yes'
 			if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes":
 				# this happens when item is changed from non-stock to stock item
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index d58ce17..d0df0df 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -95,7 +95,7 @@
 	def test_subcontracting(self):
 		po = frappe.bean(copy=test_records[0])
 		po.insert()
-		self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2)
+		self.assertEquals(len(po.get("po_raw_material_details")), 2)
 
 	def test_warehouse_company_validation(self):
 		from erpnext.stock.utils import InvalidWarehouseCompany
diff --git a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py
index 26c87f1..8c7c0a8 100644
--- a/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py
+++ b/erpnext/buying/doctype/purchase_order_item/purchase_order_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PurchaseOrderItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py
index 26c87f1..d1542fc 100644
--- a/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py
+++ b/erpnext/buying/doctype/purchase_order_item_supplied/purchase_order_item_supplied.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PurchaseOrderItemSupplied(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py
index 26c87f1..1270cf0 100644
--- a/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py
+++ b/erpnext/buying/doctype/purchase_receipt_item_supplied/purchase_receipt_item_supplied.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PurchaseReceiptItemSupplied(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/buying/doctype/quality_inspection/quality_inspection.py b/erpnext/buying/doctype/quality_inspection/quality_inspection.py
index 4222d68..4e289dc 100644
--- a/erpnext/buying/doctype/quality_inspection/quality_inspection.py
+++ b/erpnext/buying/doctype/quality_inspection/quality_inspection.py
@@ -4,19 +4,17 @@
 from __future__ import unicode_literals
 import frappe
 
-from frappe.model.doc import addchild
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class QualityInspection(Document):
 
 	def get_item_specification_details(self):
-		self.doclist = self.doc.clear_table(self.doclist, 'qa_specification_details')
+		self.set('qa_specification_details', [])
 		specification = frappe.db.sql("select specification, value from `tabItem Quality Inspection Parameter` \
 			where parent = '%s' order by idx" % (self.doc.item_code))
 		for d in specification:
-			child = addchild(self.doc, 'qa_specification_details', 'Quality Inspection Reading', self.doclist)
+			child = self.doc.append('qa_specification_details', {})
 			child.specification = d[0]
 			child.value = d[1]
 			child.status = 'Accepted'
diff --git a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py
index 26c87f1..1e36103 100644
--- a/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py
+++ b/erpnext/buying/doctype/quality_inspection_reading/quality_inspection_reading.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class QualityInspectionReading(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index f937958..44dcd5f 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -12,10 +12,7 @@
 
 from erpnext.utilities.transaction_base import TransactionBase
 
-class DocType(TransactionBase):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class Supplier(TransactionBase):
 
 	def autoname(self):
 		supp_master_name = frappe.defaults.get_global_default('supp_master_name')
diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
index f6a3ffc..edebfb3 100644
--- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
+++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py
@@ -6,7 +6,7 @@
 from frappe.model.code import get_obj
 
 from erpnext.controllers.buying_controller import BuyingController
-class DocType(BuyingController):
+class SupplierQuotation(BuyingController):
 	def __init__(self, doc, doclist=None):
 		self.doc, self.doclist = doc, doclist or []
 		self.tname, self.fname = "Supplier Quotation Item", "quotation_items"
diff --git a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py
index 26c87f1..16e6e12 100644
--- a/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py
+++ b/erpnext/buying/doctype/supplier_quotation_item/supplier_quotation_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SupplierQuotationItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 7ad5d86..35234ce 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -87,7 +87,7 @@
 	def set_missing_item_details(self):
 		"""set missing item values"""
 		from erpnext.stock.get_item_details import get_item_details
-		for item in self.doclist.get({"parentfield": self.fname}):
+		for item in self.get(self.fname):
 			if item.fields.get("item_code"):
 				args = item.fields.copy()
 				args.update(self.doc.fields)
@@ -103,7 +103,7 @@
 			
 		tax_master_doctype = self.meta.get_field(tax_master_field).options
 			
-		if not self.doclist.get({"parentfield": tax_parentfield}):
+		if not self.get(tax_parentfield):
 			if not self.doc.fields.get(tax_master_field):
 				# get the default tax master
 				self.doc.fields[tax_master_field] = \
@@ -134,7 +134,7 @@
 				self.doclist.append(tax)
 
 	def get_other_charges(self):
-		self.doclist = self.doc.clear_table(self.doclist, "other_charges")
+		self.set("other_charges", [])
 		self.set_taxes("other_charges", "taxes_and_charges")
 					
 	def calculate_taxes_and_totals(self):
@@ -156,8 +156,8 @@
 				self.meta.get_label("conversion_rate"), self.doc.company)
 
 		self.doc.conversion_rate = flt(self.doc.conversion_rate)
-		self.item_doclist = self.doclist.get({"parentfield": self.fname})
-		self.tax_doclist = self.doclist.get({"parentfield": self.other_fname})
+		self.item_doclist = self.get(self.fname)
+		self.tax_doclist = self.get(self.other_fname)
 		
 		self.calculate_item_values()
 		self.initialize_taxes()
@@ -368,7 +368,7 @@
 	def calculate_total_advance(self, parenttype, advance_parentfield):
 		if self.doc.doctype == parenttype and self.doc.docstatus < 2:
 			sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv)) 
-				for adv in self.doclist.get({"parentfield": advance_parentfield})])
+				for adv in self.get(advance_parentfield)])
 
 			self.doc.total_advance = flt(sum_of_allocated_amount, self.precision("total_advance"))
 			
@@ -408,7 +408,7 @@
 			and t1.docstatus = 1 order by t1.posting_date""" % 
 			(dr_or_cr, '%s'), account_head, as_dict=1)
 			
-		self.doclist = self.doc.clear_table(self.doclist, parentfield)
+		self.set(parentfield, [])
 		for d in res:
 			self.doclist.append({
 				"doctype": child_doctype,
@@ -425,7 +425,7 @@
 		item_tolerance = {}
 		global_tolerance = None
 		
-		for item in self.doclist.get({"parentfield": "entries"}):
+		for item in self.get("entries"):
 			if item.fields.get(item_ref_dn):
 				ref_amt = flt(frappe.db.get_value(ref_dt + " Item", 
 					item.fields[item_ref_dn], based_on), self.precision(based_on, item))
@@ -467,7 +467,7 @@
 	def get_stock_items(self):
 		stock_items = []
 		item_codes = list(set(item.item_code for item in 
-			self.doclist.get({"parentfield": self.fname})))
+			self.get(self.fname)))
 		if item_codes:
 			stock_items = [r[0] for r in frappe.db.sql("""select name
 				from `tabItem` where name in (%s) and is_stock_item='Yes'""" % \
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 4ca6c19..655b101 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -58,7 +58,7 @@
 	def validate_stock_or_nonstock_items(self):
 		if not self.get_stock_items():
 			tax_for_valuation = [d.account_head for d in 
-				self.doclist.get({"parentfield": "other_charges"}) 
+				self.get("other_charges") 
 				if d.category in ["Valuation", "Valuation and Total"]]
 			if tax_for_valuation:
 				frappe.msgprint(_("""Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items"""), raise_exception=1)
@@ -171,19 +171,19 @@
 		
 		stock_items_qty, stock_items_amount = 0, 0
 		last_stock_item_idx = 1
-		for d in self.doclist.get({"parentfield": parentfield}):
+		for d in self.get(parentfield):
 			if d.item_code and d.item_code in stock_items:
 				stock_items_qty += flt(d.qty)
 				stock_items_amount += flt(d.base_amount)
 				last_stock_item_idx = d.idx
 			
 		total_valuation_amount = sum([flt(d.tax_amount) for d in 
-			self.doclist.get({"parentfield": "other_charges"}) 
+			self.get("other_charges") 
 			if d.category in ["Valuation", "Valuation and Total"]])
 			
 		
 		valuation_amount_adjustment = total_valuation_amount
-		for i, item in enumerate(self.doclist.get({"parentfield": parentfield})):
+		for i, item in enumerate(self.get(parentfield)):
 			if item.item_code and item.qty and item.item_code in stock_items:
 				item_proportion = flt(item.base_amount) / stock_items_amount if stock_items_amount \
 					else flt(item.qty) / stock_items_qty
@@ -218,9 +218,9 @@
 					raise_exception=1)
 										
 	def update_raw_materials_supplied(self, raw_material_table):
-		self.doclist = self.doc.clear_table(self.doclist, raw_material_table)
+		self.set(raw_material_table, [])
 		if self.doc.is_subcontracted=="Yes":
-			for item in self.doclist.get({"parentfield": self.fname}):
+			for item in self.get(self.fname):
 				if item.item_code in self.sub_contracted_items:
 					self.add_bom_items(item, raw_material_table)
 
@@ -271,7 +271,7 @@
 		if not hasattr(self, "_sub_contracted_items"):
 			self._sub_contracted_items = []
 			item_codes = list(set(item.item_code for item in 
-				self.doclist.get({"parentfield": self.fname})))
+				self.get(self.fname)))
 			if item_codes:
 				self._sub_contracted_items = [r[0] for r in frappe.db.sql("""select name
 					from `tabItem` where name in (%s) and is_sub_contracted_item='Yes'""" % \
@@ -284,7 +284,7 @@
 		if not hasattr(self, "_purchase_items"):
 			self._purchase_items = []
 			item_codes = list(set(item.item_code for item in 
-				self.doclist.get({"parentfield": self.fname})))
+				self.get(self.fname)))
 			if item_codes:
 				self._purchase_items = [r[0] for r in frappe.db.sql("""select name
 					from `tabItem` where name in (%s) and is_purchase_item='Yes'""" % \
@@ -294,5 +294,5 @@
 
 
 	def is_item_table_empty(self):
-		if not len(self.doclist.get({"parentfield": self.fname})):
+		if not len(self.get(self.fname)):
 			frappe.throw(_("Item table can not be blank"))
\ No newline at end of file
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index f583668..5e0ea65 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -54,7 +54,7 @@
 			# shipping rule calculation based on item's net weight
 			
 			shipping_amount = 0.0
-			for condition in shipping_rule.doclist.get({"parentfield": "shipping_rule_conditions"}):
+			for condition in shipping_rule.get("shipping_rule_conditions"):
 				if not condition.to_value or (flt(condition.from_value) <= value <= flt(condition.to_value)):
 					shipping_amount = condition.shipping_amount
 					break
@@ -242,7 +242,7 @@
 
 	def calculate_contribution(self):
 		total = 0.0
-		sales_team = self.doclist.get({"parentfield": "sales_team"})
+		sales_team = self.get("sales_team")
 		for sales_person in sales_team:
 			self.round_floats_in(sales_person)
 
@@ -279,7 +279,7 @@
 				outstanding_including_current)
 				
 	def validate_max_discount(self):
-		for d in self.doclist.get({"parentfield": self.fname}):
+		for d in self.get(self.fname):
 			discount = flt(frappe.db.get_value("Item", d.item_code, "max_discount"))
 			
 			if discount and flt(d.discount_percentage) > discount:
@@ -288,7 +288,7 @@
 					
 	def get_item_list(self):
 		il = []
-		for d in self.doclist.get({"parentfield": self.fname}):
+		for d in self.get(self.fname):
 			reserved_warehouse = ""
 			reserved_qty_for_main_item = 0
 			
@@ -315,7 +315,7 @@
 					reserved_qty_for_main_item = -flt(d.qty)
 
 			if self.has_sales_bom(d.item_code):
-				for p in self.doclist.get({"parentfield": "packing_details"}):
+				for p in self.get("packing_details"):
 					if p.parent_detail_docname == d.name and p.parent_item == d.item_code:
 						# the packing details table's qty is already multiplied with parent's qty
 						il.append(frappe._dict({
@@ -362,7 +362,7 @@
 		return so_qty, so_warehouse
 		
 	def check_stop_sales_order(self, ref_fieldname):
-		for d in self.doclist.get({"parentfield": self.fname}):
+		for d in self.get(self.fname):
 			if d.fields.get(ref_fieldname):
 				status = frappe.db.get_value("Sales Order", d.fields[ref_fieldname], "status")
 				if status == "Stopped":
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 7411d09..30bc02e 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -240,7 +240,7 @@
 		all_zero_amount_refdoc = frappe.db.sql_list("""select name from `tab%s` 
 			where docstatus=1 and net_total = 0""" % ref_dt)
 	
-		for item in self.doclist.get({"parentfield": "entries"}):
+		for item in self.get("entries"):
 			if item.fields.get(ref_fieldname) \
 				and item.fields.get(ref_fieldname) in all_zero_amount_refdoc \
 				and item.fields.get(ref_fieldname) not in zero_amount_refdoc:
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 2481868..d87a88c 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -70,7 +70,7 @@
 			
 	def get_voucher_details(self, stock_ledger, default_expense_account, default_cost_center):
 		if not default_expense_account:
-			details = self.doclist.get({"parentfield": self.fname})
+			details = self.get(self.fname)
 			for d in details:
 				self.check_expense_account(d)
 		else:
@@ -129,7 +129,7 @@
 		future_stock_vouchers = []
 		
 		if hasattr(self, "fname"):
-			item_list = [d.item_code for d in self.doclist.get({"parentfield": self.fname})]
+			item_list = [d.item_code for d in self.get(self.fname)]
 			condition = ''.join(['and item_code in (\'', '\', \''.join(item_list) ,'\')'])
 		else:
 			condition = ""
@@ -256,8 +256,8 @@
 	def get_distinct_item_warehouse(self):
 		item_list = []
 		warehouse_list = []
-		for item in self.doclist.get({"parentfield": self.fname}) \
-				+ self.doclist.get({"parentfield": "packing_details"}):
+		for item in self.get(self.fname) \
+				+ self.get("packing_details"):
 			item_list.append(item.item_code)
 			warehouse_list.append(item.warehouse)
 			
diff --git a/erpnext/home/doctype/feed/feed.py b/erpnext/home/doctype/feed/feed.py
index 0a12d26..45d8ea1 100644
--- a/erpnext/home/doctype/feed/feed.py
+++ b/erpnext/home/doctype/feed/feed.py
@@ -4,15 +4,10 @@
 from __future__ import unicode_literals
 import frappe
 
-from frappe.model import db_exists
-from frappe.model.bean import copy_doclist
+from frappe.model.document import Document
 
-	
-
-
-class DocType:
-  def __init__(self,d,dl):
-    self.doc, self.doclist = d, dl
+class Feed(Document):
+	pass
 	
 def on_doctype_update():
 	if not frappe.db.sql("""show index from `tabFeed` 
diff --git a/erpnext/hr/doctype/appraisal/appraisal.py b/erpnext/hr/doctype/appraisal/appraisal.py
index 8abeab8..761e385 100644
--- a/erpnext/hr/doctype/appraisal/appraisal.py
+++ b/erpnext/hr/doctype/appraisal/appraisal.py
@@ -8,10 +8,9 @@
 from frappe.model.bean import getlist
 from frappe import msgprint
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class Appraisal(Document):
 
 	def validate(self):
 		if not self.doc.status:
@@ -45,7 +44,7 @@
 	
 	def calculate_total(self):
 		total, total_w  = 0, 0
-		for d in getlist(self.doclist, 'appraisal_details'):
+		for d in self.get('appraisal_details'):
 			if d.score:
 				d.score_earned = flt(d.score) * flt(d.per_weightage) / 100
 				total = total + d.score_earned
diff --git a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py
index 26c87f1..c13c42b 100644
--- a/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py
+++ b/erpnext/hr/doctype/appraisal_goal/appraisal_goal.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class AppraisalGoal(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/appraisal_template/appraisal_template.py b/erpnext/hr/doctype/appraisal_template/appraisal_template.py
index 0f78a4a..e4fba2c 100644
--- a/erpnext/hr/doctype/appraisal_template/appraisal_template.py
+++ b/erpnext/hr/doctype/appraisal_template/appraisal_template.py
@@ -5,9 +5,9 @@
 import frappe
 from frappe import _
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class AppraisalTemplate(Document):
 		
 	def validate(self):
 		self.doc.total_points = 0
diff --git a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py
index 26c87f1..0cdd921 100644
--- a/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py
+++ b/erpnext/hr/doctype/appraisal_template_goal/appraisal_template_goal.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class AppraisalTemplateGoal(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/attendance/attendance.py b/erpnext/hr/doctype/attendance/attendance.py
index 9abef76..42cb7b0 100644
--- a/erpnext/hr/doctype/attendance/attendance.py
+++ b/erpnext/hr/doctype/attendance/attendance.py
@@ -8,10 +8,9 @@
 from frappe import msgprint, _
 
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class Attendance(Document):
 	
 	def validate_duplicate_record(self):	 
 		res = frappe.db.sql("""select name from `tabAttendance` where employee = %s and att_date = %s 
diff --git a/erpnext/hr/doctype/branch/branch.py b/erpnext/hr/doctype/branch/branch.py
index 58ecbe8..f5dbe18 100644
--- a/erpnext/hr/doctype/branch/branch.py
+++ b/erpnext/hr/doctype/branch/branch.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
+from frappe.model.document import Document
+
+class Branch(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/deduction_type/deduction_type.py b/erpnext/hr/doctype/deduction_type/deduction_type.py
index 26c87f1..c18f569 100644
--- a/erpnext/hr/doctype/deduction_type/deduction_type.py
+++ b/erpnext/hr/doctype/deduction_type/deduction_type.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class DeductionType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/department/department.py b/erpnext/hr/doctype/department/department.py
index 5015bed..bf15491 100644
--- a/erpnext/hr/doctype/department/department.py
+++ b/erpnext/hr/doctype/department/department.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
\ No newline at end of file
+from frappe.model.document import Document
+
+class Department(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/designation/designation.py b/erpnext/hr/doctype/designation/designation.py
index 58ecbe8..fb53047 100644
--- a/erpnext/hr/doctype/designation/designation.py
+++ b/erpnext/hr/doctype/designation/designation.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
+from frappe.model.document import Document
+
+class Designation(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/earning_type/earning_type.py b/erpnext/hr/doctype/earning_type/earning_type.py
index 26c87f1..8f7450e 100644
--- a/erpnext/hr/doctype/earning_type/earning_type.py
+++ b/erpnext/hr/doctype/earning_type/earning_type.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class EarningType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee/employee.py b/erpnext/hr/doctype/employee/employee.py
index 3ec44e6..aacb2aa 100644
--- a/erpnext/hr/doctype/employee/employee.py
+++ b/erpnext/hr/doctype/employee/employee.py
@@ -11,7 +11,7 @@
 from frappe.defaults import get_restrictions
 from frappe.model.controller import DocListController
 
-class DocType(DocListController):
+class Employee(DocListController):
 	def autoname(self):
 		naming_method = frappe.db.get_value("HR Settings", None, "emp_created_by")
 		if not naming_method:
@@ -57,7 +57,7 @@
 	
 	def restrict_leave_approver(self):
 		"""restrict to this employee for leave approver"""
-		employee_leave_approvers = [d.leave_approver for d in self.doclist.get({"parentfield": "employee_leave_approvers"})]
+		employee_leave_approvers = [d.leave_approver for d in self.get("employee_leave_approvers")]
 		if self.doc.reports_to and self.doc.reports_to not in employee_leave_approvers:
 			employee_leave_approvers.append(frappe.db.get_value("Employee", self.doc.reports_to, "user_id"))
 			
@@ -167,7 +167,7 @@
 		from frappe.utils.user import User
 		from erpnext.hr.doctype.leave_application.leave_application import InvalidLeaveApproverError
 		
-		for l in self.doclist.get({"parentfield": "employee_leave_approvers"}):
+		for l in self.get("employee_leave_approvers"):
 			if "Leave Approver" not in User(l.leave_approver).get_roles():
 				throw(_("Invalid Leave Approver") + ": \"" + l.leave_approver + "\"",
 					exc=InvalidLeaveApproverError)
diff --git a/erpnext/hr/doctype/employee_education/employee_education.py b/erpnext/hr/doctype/employee_education/employee_education.py
index 26c87f1..2cc0f26 100644
--- a/erpnext/hr/doctype/employee_education/employee_education.py
+++ b/erpnext/hr/doctype/employee_education/employee_education.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class EmployeeEducation(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py
index 26c87f1..a99e4de 100644
--- a/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py
+++ b/erpnext/hr/doctype/employee_external_work_history/employee_external_work_history.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class EmployeeExternalWorkHistory(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py
index 26c87f1..65dfa44 100644
--- a/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py
+++ b/erpnext/hr/doctype/employee_internal_work_history/employee_internal_work_history.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class EmployeeInternalWorkHistory(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py
index 968a25b..8736c4f 100644
--- a/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py
+++ b/erpnext/hr/doctype/employee_leave_approver/employee_leave_approver.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class EmployeeLeaveApprover(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/employment_type/employment_type.py b/erpnext/hr/doctype/employment_type/employment_type.py
index 5015bed..87a8634 100644
--- a/erpnext/hr/doctype/employment_type/employment_type.py
+++ b/erpnext/hr/doctype/employment_type/employment_type.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
\ No newline at end of file
+from frappe.model.document import Document
+
+class EmploymentType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.py b/erpnext/hr/doctype/expense_claim/expense_claim.py
index 0fbfde5..1d02e87 100644
--- a/erpnext/hr/doctype/expense_claim/expense_claim.py
+++ b/erpnext/hr/doctype/expense_claim/expense_claim.py
@@ -7,10 +7,9 @@
 from frappe.model.bean import getlist
 from frappe import msgprint
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class ExpenseClaim(Document):
 
 	def validate(self):
 		self.validate_fiscal_year()
@@ -26,6 +25,6 @@
 		validate_fiscal_year(self.doc.posting_date, self.doc.fiscal_year, "Posting Date")
 			
 	def validate_exp_details(self):
-		if not getlist(self.doclist, 'expense_voucher_details'):
+		if not self.get('expense_voucher_details'):
 			msgprint("Please add expense voucher details")
 			raise Exception
diff --git a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py
index 26c87f1..fe6cb1e 100644
--- a/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py
+++ b/erpnext/hr/doctype/expense_claim_detail/expense_claim_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ExpenseClaimDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py
index 26c87f1..bc0db7f 100644
--- a/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py
+++ b/erpnext/hr/doctype/expense_claim_type/expense_claim_type.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ExpenseClaimType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/grade/grade.py b/erpnext/hr/doctype/grade/grade.py
index 58ecbe8..04e3e97 100644
--- a/erpnext/hr/doctype/grade/grade.py
+++ b/erpnext/hr/doctype/grade/grade.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
+from frappe.model.document import Document
+
+class Grade(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/holiday/holiday.py b/erpnext/hr/doctype/holiday/holiday.py
index 26c87f1..2e64a10 100644
--- a/erpnext/hr/doctype/holiday/holiday.py
+++ b/erpnext/hr/doctype/holiday/holiday.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class Holiday(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/holiday_list/holiday_list.py b/erpnext/hr/doctype/holiday_list/holiday_list.py
index 8fdfccc..c0f1b1b 100644
--- a/erpnext/hr/doctype/holiday_list/holiday_list.py
+++ b/erpnext/hr/doctype/holiday_list/holiday_list.py
@@ -5,17 +5,13 @@
 import frappe
 
 from frappe.utils import add_days, add_years, cint, getdate
-from frappe.model import db_exists
-from frappe.model.doc import addchild, make_autoname
-from frappe.model.bean import copy_doclist
+from frappe.model.doc import make_autoname
 from frappe import msgprint, throw, _
 import datetime
 
-class DocType:
-	def __init__(self,doc,doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
 
+class HolidayList(Document):
 	def autoname(self):
 		self.doc.name = make_autoname(self.doc.fiscal_year + "/" + self.doc.holiday_list_name + "/.###")
 		
@@ -29,7 +25,7 @@
 		last_idx = max([cint(d.idx) for d in self.doclist.get(
 			{"parentfield": "holiday_list_details"})] or [0,])
 		for i, d in enumerate(date_list):
-			ch = addchild(self.doc, 'holiday_list_details', 'Holiday', self.doclist)
+			ch = self.doc.append('holiday_list_details', {})
 			ch.description = self.doc.weekly_off
 			ch.holiday_date = d
 			ch.idx = last_idx + i + 1
@@ -63,7 +59,7 @@
 		return date_list
 	
 	def clear_table(self):
-		self.doclist = self.doc.clear_table(self.doclist, 'holiday_list_details')
+		self.set('holiday_list_details', [])
 
 	def update_default_holiday_list(self):
 		frappe.db.sql("""update `tabHoliday List` set is_default = 0 
diff --git a/erpnext/hr/doctype/hr_settings/hr_settings.py b/erpnext/hr/doctype/hr_settings/hr_settings.py
index e9e44d4..6d5f8e0 100644
--- a/erpnext/hr/doctype/hr_settings/hr_settings.py
+++ b/erpnext/hr/doctype/hr_settings/hr_settings.py
@@ -8,9 +8,9 @@
 
 from frappe.utils import cint
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class HrSettings(Document):
 		
 	def validate(self):
 		self.update_birthday_reminders()
diff --git a/erpnext/hr/doctype/job_applicant/job_applicant.py b/erpnext/hr/doctype/job_applicant/job_applicant.py
index 41fc5f3..3640304 100644
--- a/erpnext/hr/doctype/job_applicant/job_applicant.py
+++ b/erpnext/hr/doctype/job_applicant/job_applicant.py
@@ -8,9 +8,7 @@
 from erpnext.utilities.transaction_base import TransactionBase
 from frappe.utils import extract_email_id
 
-class DocType(TransactionBase):
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+class JobApplicant(TransactionBase):
 	
 	def get_sender(self, comm):
 		return frappe.db.get_value('Jobs Email Settings',None,'email_id')	
diff --git a/erpnext/hr/doctype/job_opening/job_opening.py b/erpnext/hr/doctype/job_opening/job_opening.py
index 968a25b..4224207 100644
--- a/erpnext/hr/doctype/job_opening/job_opening.py
+++ b/erpnext/hr/doctype/job_opening/job_opening.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class JobOpening(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_allocation/leave_allocation.py b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
index 7648ba5..a78dc1a 100755
--- a/erpnext/hr/doctype/leave_allocation/leave_allocation.py
+++ b/erpnext/hr/doctype/leave_allocation/leave_allocation.py
@@ -6,7 +6,9 @@
 from frappe.utils import cint, flt
 from frappe import msgprint
 	
-class DocType:
+from frappe.model.document import Document
+
+class LeaveAllocation(Document):
 	def __init__(self, doc, doclist):
 		self.doc, self.doclist = doc, doclist
 		
diff --git a/erpnext/hr/doctype/leave_application/leave_application.py b/erpnext/hr/doctype/leave_application/leave_application.py
index 1630e14..03045a4 100755
--- a/erpnext/hr/doctype/leave_application/leave_application.py
+++ b/erpnext/hr/doctype/leave_application/leave_application.py
@@ -15,7 +15,7 @@
 class LeaveApproverIdentityError(frappe.ValidationError): pass
 	
 from frappe.model.controller import DocListController
-class DocType(DocListController):
+class LeaveApplication(DocListController):
 	def setup(self):
 		if frappe.db.exists(self.doc.doctype, self.doc.name):
 			self.previous_doc = frappe.doc(self.doc.doctype, self.doc.name)
@@ -149,7 +149,7 @@
 	def validate_leave_approver(self):
 		employee = frappe.bean("Employee", self.doc.employee)
 		leave_approvers = [l.leave_approver for l in 
-			employee.doclist.get({"parentfield": "employee_leave_approvers"})]
+			employee.get("employee_leave_approvers")]
 			
 		if len(leave_approvers) and self.doc.leave_approver not in leave_approvers:
 			msgprint(("[" + _("For Employee") + ' "' + self.doc.employee + '"] ' 
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 cdbb2d0..e1cbf1b 100644
--- a/erpnext/hr/doctype/leave_block_list/leave_block_list.py
+++ b/erpnext/hr/doctype/leave_block_list/leave_block_list.py
@@ -8,9 +8,9 @@
 from erpnext.accounts.utils import validate_fiscal_year
 from frappe import _
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class LeaveBlockList(Document):
 		
 	def validate(self):
 		dates = []
diff --git a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py
index 968a25b..684e178 100644
--- a/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py
+++ b/erpnext/hr/doctype/leave_block_list_allow/leave_block_list_allow.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class LeaveBlockListAllow(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py
index 968a25b..3db4798 100644
--- a/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py
+++ b/erpnext/hr/doctype/leave_block_list_date/leave_block_list_date.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class LeaveBlockListDate(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py
index 001d0d5..f3aace2 100644
--- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py
+++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.py
@@ -12,7 +12,9 @@
 	
 
 
-class DocType:
+from frappe.model.document import Document
+
+class LeaveControlPanel(Document):
 	def __init__(self, doc, doclist):
 		self.doc = doc
 		self.doclist = doclist	 
diff --git a/erpnext/hr/doctype/leave_type/leave_type.py b/erpnext/hr/doctype/leave_type/leave_type.py
index 5015bed..426bc73 100644
--- a/erpnext/hr/doctype/leave_type/leave_type.py
+++ b/erpnext/hr/doctype/leave_type/leave_type.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
\ No newline at end of file
+from frappe.model.document import Document
+
+class LeaveType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.py b/erpnext/hr/doctype/salary_manager/salary_manager.py
index 0420f77..d0af7be 100644
--- a/erpnext/hr/doctype/salary_manager/salary_manager.py
+++ b/erpnext/hr/doctype/salary_manager/salary_manager.py
@@ -7,10 +7,9 @@
 from frappe.model.code import get_obj
 from frappe import msgprint
 
-class DocType:
-	def __init__(self, doc, doclist):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class SalaryManager(Document):
 		
 	def get_emp_list(self):
 		"""
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index a264c1c..a7c4f8d 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -14,11 +14,7 @@
 	
 from erpnext.utilities.transaction_base import TransactionBase
 
-class DocType(TransactionBase):
-	def __init__(self,doc,doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
-		
+class SalarySlip(TransactionBase):
 	def autoname(self):
 		self.doc.name = make_autoname('Sal Slip/' +self.doc.employee + '/.#####') 
 
@@ -146,8 +142,8 @@
 		from frappe.utils import money_in_words
 		self.check_existing()
 		
-		if not (len(self.doclist.get({"parentfield": "earning_details"})) or 
-			len(self.doclist.get({"parentfield": "deduction_details"}))):
+		if not (len(self.get("earning_details")) or 
+			len(self.get("deduction_details"))):
 				self.get_emp_and_leave_details()
 		else:
 			self.get_leave_details(self.doc.leave_without_pay)
@@ -160,7 +156,7 @@
 
 	def calculate_earning_total(self):
 		self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount)
-		for d in self.doclist.get({"parentfield": "earning_details"}):
+		for d in self.get("earning_details"):
 			if cint(d.e_depends_on_lwp) == 1:
 				d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days)
 					/ cint(self.doc.total_days_in_month), 2)
@@ -172,7 +168,7 @@
 	
 	def calculate_ded_total(self):
 		self.doc.total_deduction = 0
-		for d in getlist(self.doclist, 'deduction_details'):
+		for d in self.get('deduction_details'):
 			if cint(d.d_depends_on_lwp) == 1:
 				d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days) 
 					/ cint(self.doc.total_days_in_month), 2)
diff --git a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py
index 26c87f1..422ee28 100644
--- a/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py
+++ b/erpnext/hr/doctype/salary_slip_deduction/salary_slip_deduction.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalarySlipDeduction(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py
index 26c87f1..c4a7b4e 100644
--- a/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py
+++ b/erpnext/hr/doctype/salary_slip_earning/salary_slip_earning.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalarySlipEarning(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 8d59f2b..ae10394 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -5,15 +5,13 @@
 import frappe
 
 from frappe.utils import cstr, flt
-from frappe.model.doc import addchild, make_autoname
+from frappe.model.doc import make_autoname
 from frappe import msgprint, _
 
 
-class DocType:
-	def __init__(self,doc,doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
 
+class SalaryStructure(Document):
 	def autoname(self):
 		self.doc.name = make_autoname(self.doc.employee + '/.SST' + '/.#####')
 
@@ -44,7 +42,7 @@
 	def make_table(self, doct_name, tab_fname, tab_name):
 		list1 = frappe.db.sql("select name from `tab%s` where docstatus != 2" % doct_name)
 		for li in list1:
-			child = addchild(self.doc, tab_fname, tab_name, self.doclist)
+			child = self.doc.append(tab_fname, {})
 			if(tab_fname == 'earning_details'):
 				child.e_type = cstr(li[0])
 				child.modified_value = 0
diff --git a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py
index 26c87f1..95300e1 100644
--- a/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py
+++ b/erpnext/hr/doctype/salary_structure_deduction/salary_structure_deduction.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalaryStructureDeduction(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py
index 26c87f1..79f7972 100644
--- a/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py
+++ b/erpnext/hr/doctype/salary_structure_earning/salary_structure_earning.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalaryStructureEarning(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/hr/doctype/upload_attendance/upload_attendance.py b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
index 3da1078..844806e 100644
--- a/erpnext/hr/doctype/upload_attendance/upload_attendance.py
+++ b/erpnext/hr/doctype/upload_attendance/upload_attendance.py
@@ -8,14 +8,13 @@
 from frappe.utils import cstr, add_days, date_diff
 from frappe import msgprint, _
 from frappe.utils.datautils import UnicodeWriter
+from frappe.model.document import Document
 
 # doclist = None
 doclist = frappe.local('uploadattendance_doclist')
 
-class DocType():
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class UploadAttendance(Document):
+	pass
 
 @frappe.whitelist()
 def get_template():
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 2c6d642..bd5642e 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -4,17 +4,15 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.utils import cint, cstr, flt, now, nowdate
-from frappe.model.doc import addchild
 from frappe.model.bean import getlist
 from frappe.model.code import get_obj
 from frappe import msgprint, _
 
 
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class Bom(Document):
 
 	def autoname(self):
 		last_name = frappe.db.sql("""select max(name) from `tabBOM` 
@@ -75,7 +73,7 @@
 			msgprint("Item %s does not exist in system" % item[0]['item_code'], raise_exception = 1)
 			
 	def set_bom_material_details(self):
-		for item in self.doclist.get({"parentfield": "bom_materials"}):
+		for item in self.get("bom_materials"):
 			ret = self.get_bom_material_detail({"item_code": item.item_code, "bom_no": item.bom_no, 
 				"qty": item.qty})
 
@@ -128,7 +126,7 @@
 		return rate
 		
 	def update_cost(self):
-		for d in self.doclist.get({"parentfield": "bom_materials"}):
+		for d in self.get("bom_materials"):
 			d.rate = self.get_bom_material_detail({
 				'item_code': d.item_code, 
 				'bom_no': d.bom_no,
@@ -188,8 +186,8 @@
 
 	def clear_operations(self):
 		if not self.doc.with_operations:
-			self.doclist = self.doc.clear_table(self.doclist, 'bom_operations')
-			for d in self.doclist.get({"parentfield": "bom_materials"}):
+			self.set('bom_operations', [])
+			for d in self.get("bom_materials"):
 				d.operation_no = None
 
 	def validate_main_item(self):
@@ -210,7 +208,7 @@
 	def validate_operations(self):
 		""" Check duplicate operation no"""
 		self.op = []
-		for d in getlist(self.doclist, 'bom_operations'):
+		for d in self.get('bom_operations'):
 			if cstr(d.operation_no) in self.op:
 				msgprint("Operation no: %s is repeated in Operations Table" % 
 					d.operation_no, raise_exception=1)
@@ -221,7 +219,7 @@
 	def validate_materials(self):
 		""" Validate raw material entries """
 		check_list = []
-		for m in getlist(self.doclist, 'bom_materials'):
+		for m in self.get('bom_materials'):
 			# check if operation no not in op table
 			if self.doc.with_operations and cstr(m.operation_no) not in self.op:
 				msgprint("""Operation no: %s against item: %s at row no: %s \
@@ -315,7 +313,7 @@
 	def calculate_op_cost(self):
 		"""Update workstation rate and calculates totals"""
 		total_op_cost = 0
-		for d in getlist(self.doclist, 'bom_operations'):
+		for d in self.get('bom_operations'):
 			if d.workstation and not d.hour_rate:
 				d.hour_rate = frappe.db.get_value("Workstation", d.workstation, "hour_rate")
 			if d.hour_rate and d.time_in_mins:
@@ -326,7 +324,7 @@
 	def calculate_rm_cost(self):
 		"""Fetch RM rate as per today's valuation rate and calculate totals"""
 		total_rm_cost = 0
-		for d in getlist(self.doclist, 'bom_materials'):
+		for d in self.get('bom_materials'):
 			if d.bom_no:
 				d.rate = self.get_bom_unitcost(d.bom_no)
 			d.amount = flt(d.rate) * flt(d.qty)
@@ -343,7 +341,7 @@
 	def get_exploded_items(self):
 		""" Get all raw materials including items from child bom"""
 		self.cur_exploded_items = {}
-		for d in getlist(self.doclist, 'bom_materials'):
+		for d in self.get('bom_materials'):
 			if d.bom_no:
 				self.get_child_exploded_items(d.bom_no, d.qty)
 			else:
@@ -379,9 +377,9 @@
 
 	def add_exploded_items(self):
 		"Add items to Flat BOM table"
-		self.doclist = self.doc.clear_table(self.doclist, 'flat_bom_details', 1)
+		self.set('flat_bom_details', [])
 		for d in self.cur_exploded_items:
-			ch = addchild(self.doc, 'flat_bom_details', 'BOM Explosion Item', self.doclist)
+			ch = self.doc.append('flat_bom_details', {})
 			for i in self.cur_exploded_items[d].keys():
 				ch.fields[i] = self.cur_exploded_items[d][i]
 			ch.amount = flt(ch.qty) * flt(ch.rate)
diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py
index 26c87f1..bd1b1af 100644
--- a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py
+++ b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class BomExplosionItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.py b/erpnext/manufacturing/doctype/bom_item/bom_item.py
index 26c87f1..f2bef2c 100644
--- a/erpnext/manufacturing/doctype/bom_item/bom_item.py
+++ b/erpnext/manufacturing/doctype/bom_item/bom_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import 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 26c87f1..df55159 100644
--- a/erpnext/manufacturing/doctype/bom_operation/bom_operation.py
+++ b/erpnext/manufacturing/doctype/bom_operation/bom_operation.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import 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 598d822..c406777 100644
--- a/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
+++ b/erpnext/manufacturing/doctype/bom_replace_tool/bom_replace_tool.py
@@ -7,7 +7,9 @@
 from frappe.model.code import get_obj
 from frappe import msgprint, _
 	
-class DocType:
+from frappe.model.document import Document
+
+class BomReplaceTool(Document):
 	def __init__( self, doc, doclist=[]):
 		self.doc = doc
 		self.doclist = doclist
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index abc6cfd..aeea1c0 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -10,10 +10,9 @@
 
 class OverProductionError(frappe.ValidationError): pass
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class ProductionOrder(Document):
 
 	def validate(self):
 		if self.doc.docstatus == 0:
diff --git a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py
index 26c87f1..a9a9c61 100644
--- a/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py
+++ b/erpnext/manufacturing/doctype/production_plan_item/production_plan_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ProductionPlanItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py
index 26c87f1..c0be09e 100644
--- a/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py
+++ b/erpnext/manufacturing/doctype/production_plan_sales_order/production_plan_sales_order.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ProductionPlanSalesOrder(Document):
+	pass
\ No newline at end of file
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 60007cd..89fafbc 100644
--- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
+++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.py
@@ -4,15 +4,13 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.utils import cstr, flt, cint, nowdate, add_days
-from frappe.model.doc import addchild, Document
 from frappe.model.bean import getlist
 from frappe.model.code import get_obj
 from frappe import msgprint, _
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class ProductionPlanningTool(Document):
 		self.item_dict = {}
 
 	def get_so_details(self, so):
@@ -39,10 +37,10 @@
 		return ret
 
 	def clear_so_table(self):
-		self.doclist = self.doc.clear_table(self.doclist, 'pp_so_details')
+		self.set('pp_so_details', [])
 
 	def clear_item_table(self):
-		self.doclist = self.doc.clear_table(self.doclist, 'pp_details')
+		self.set('pp_details', [])
 		
 	def validate_company(self):
 		if not self.doc.company:
@@ -84,11 +82,10 @@
 		""" Add sales orders in the table"""
 		self.clear_so_table()
 
-		so_list = [d.sales_order for d in getlist(self.doclist, 'pp_so_details')]
+		so_list = [d.sales_order for d in self.get('pp_so_details')]
 		for r in open_so:
 			if cstr(r['name']) not in so_list:
-				pp_so = addchild(self.doc, 'pp_so_details', 
-					'Production Plan Sales Order', self.doclist)
+				pp_so = self.doc.append('pp_so_details', {})
 				pp_so.sales_order = r['name']
 				pp_so.sales_order_date = cstr(r['transaction_date'])
 				pp_so.customer = cstr(r['customer'])
@@ -103,7 +100,7 @@
 		self.add_items(items)
 
 	def get_items(self):
-		so_list = filter(None, [d.sales_order for d in getlist(self.doclist, 'pp_so_details')])
+		so_list = filter(None, [d.sales_order for d in self.get('pp_so_details')])
 		if not so_list:
 			msgprint(_("Please enter sales order in the above table"))
 			return []
@@ -138,7 +135,7 @@
 		for p in items:
 			item_details = frappe.db.sql("""select description, stock_uom, default_bom 
 				from tabItem where name=%s""", p['item_code'])
-			pi = addchild(self.doc, 'pp_details', 'Production Plan Item', self.doclist)
+			pi = self.doc.append('pp_details', {})
 			pi.sales_order				= p['parent']
 			pi.warehouse				= p['warehouse']
 			pi.item_code				= p['item_code']
@@ -151,7 +148,7 @@
 
 	def validate_data(self):
 		self.validate_company()
-		for d in getlist(self.doclist, 'pp_details'):
+		for d in self.get('pp_details'):
 			self.validate_bom_no(d)
 			if not flt(d.planned_qty):
 				frappe.throw("Please Enter Planned Qty for item: %s at row no: %s" % 
@@ -193,7 +190,7 @@
 			}
 		"""
 		item_dict, bom_dict = {}, {}
-		for d in self.doclist.get({"parentfield": "pp_details"}):			
+		for d in self.get("pp_details"):			
 			bom_dict.setdefault(d.bom_no, []).append([d.sales_order, flt(d.planned_qty)])
 			item_dict[(d.item_code, d.sales_order, d.warehouse)] = {
 				"production_item"	: d.item_code,
diff --git a/erpnext/manufacturing/doctype/workstation/workstation.py b/erpnext/manufacturing/doctype/workstation/workstation.py
index 2829f41..dd53c56 100644
--- a/erpnext/manufacturing/doctype/workstation/workstation.py
+++ b/erpnext/manufacturing/doctype/workstation/workstation.py
@@ -5,7 +5,9 @@
 import frappe
 from frappe.utils import flt
 
-class DocType:
+from frappe.model.document import Document
+
+class Workstation(Document):
   def __init__(self, doc, doclist=[]):
     self.doc = doc
     self.doclist = doclist
diff --git a/erpnext/projects/doctype/activity_type/activity_type.py b/erpnext/projects/doctype/activity_type/activity_type.py
index 26c87f1..a98d8cf 100644
--- a/erpnext/projects/doctype/activity_type/activity_type.py
+++ b/erpnext/projects/doctype/activity_type/activity_type.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ActivityType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/projects/doctype/project/project.py b/erpnext/projects/doctype/project/project.py
index deac722..99a9d3a 100644
--- a/erpnext/projects/doctype/project/project.py
+++ b/erpnext/projects/doctype/project/project.py
@@ -8,10 +8,9 @@
 from frappe import msgprint
 from erpnext.utilities.transaction_base import delete_events
 
-class DocType:
-	def __init__(self, doc, doclist=None):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class Project(Document):
 	
 	def get_gross_profit(self):
 		pft, per_pft =0, 0
@@ -45,7 +44,7 @@
 		delete_events(self.doc.doctype, self.doc.name)
 		
 		# add events
-		for milestone in self.doclist.get({"parentfield": "project_milestones"}):
+		for milestone in self.get("project_milestones"):
 			if milestone.milestone_date:
 				description = (milestone.milestone or "Milestone") + " for " + self.doc.name
 				frappe.bean({
diff --git a/erpnext/projects/doctype/project_milestone/project_milestone.py b/erpnext/projects/doctype/project_milestone/project_milestone.py
index 26c87f1..57bcfc4 100644
--- a/erpnext/projects/doctype/project_milestone/project_milestone.py
+++ b/erpnext/projects/doctype/project_milestone/project_milestone.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ProjectMilestone(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/projects/doctype/task/task.py b/erpnext/projects/doctype/task/task.py
index 0e76781..289903d 100644
--- a/erpnext/projects/doctype/task/task.py
+++ b/erpnext/projects/doctype/task/task.py
@@ -5,16 +5,12 @@
 import frappe, json
 
 from frappe.utils import getdate, today
-from frappe.model import db_exists
-from frappe.model.bean import copy_doclist
 from frappe import msgprint
 
 
-class DocType:
-	def __init__(self,doc,doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
-	
+from frappe.model.document import Document
+
+class Task(Document):
 	def get_project_details(self):
 		return {
 			"project": self.doc.project
diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py
index 690eb92..3dedef1 100644
--- a/erpnext/projects/doctype/time_log/time_log.py
+++ b/erpnext/projects/doctype/time_log/time_log.py
@@ -11,9 +11,9 @@
 
 class OverlapError(frappe.ValidationError): pass
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class TimeLog(Document):
 		
 	def validate(self):
 		self.set_status()
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 3c3e6e0..89beb9d 100644
--- a/erpnext/projects/doctype/time_log_batch/time_log_batch.py
+++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.py
@@ -7,9 +7,9 @@
 import frappe
 from frappe import _
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class TimeLogBatch(Document):
 
 	def validate(self):
 		self.set_status()
diff --git a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py
index 968a25b..f0c4c1b 100644
--- a/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py
+++ b/erpnext/projects/doctype/time_log_batch_detail/time_log_batch_detail.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class TimeLogBatchDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/campaign/campaign.py b/erpnext/selling/doctype/campaign/campaign.py
index 5015bed..523c62d 100644
--- a/erpnext/selling/doctype/campaign/campaign.py
+++ b/erpnext/selling/doctype/campaign/campaign.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
\ No newline at end of file
+from frappe.model.document import Document
+
+class Campaign(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index d8a095f..1fc2613 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -11,10 +11,7 @@
 from erpnext.utilities.transaction_base import TransactionBase
 from erpnext.accounts.party import create_party_account
 
-class DocType(TransactionBase):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class Customer(TransactionBase):
 				
 	def autoname(self):
 		cust_master_name = frappe.defaults.get_global_default('cust_master_name')
diff --git a/erpnext/selling/doctype/industry_type/industry_type.py b/erpnext/selling/doctype/industry_type/industry_type.py
index 5015bed..f6bf2c8 100644
--- a/erpnext/selling/doctype/industry_type/industry_type.py
+++ b/erpnext/selling/doctype/industry_type/industry_type.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
-		
\ No newline at end of file
+from frappe.model.document import Document
+
+class IndustryType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/installation_note/installation_note.py b/erpnext/selling/doctype/installation_note/installation_note.py
index 3d57db7..404ad33 100644
--- a/erpnext/selling/doctype/installation_note/installation_note.py
+++ b/erpnext/selling/doctype/installation_note/installation_note.py
@@ -11,10 +11,7 @@
 
 from erpnext.utilities.transaction_base import TransactionBase
 
-class DocType(TransactionBase):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class InstallationNote(TransactionBase):
 		self.tname = 'Installation Note Item'
 		self.fname = 'installed_item_details'
 		self.status_updater = [{
@@ -78,7 +75,7 @@
 
 	def validate_serial_no(self):
 		cur_s_no, prevdoc_s_no, sr_list = [], [], []
-		for d in getlist(self.doclist, 'installed_item_details'):
+		for d in self.get('installed_item_details'):
 			self.is_serial_no_added(d.item_code, d.serial_no)
 			if d.serial_no:
 				sr_list = get_valid_serial_nos(d.serial_no, d.qty, d.item_code)
@@ -91,7 +88,7 @@
 				self.is_serial_no_installed(sr_list, d.item_code)
 
 	def validate_installation_date(self):
-		for d in getlist(self.doclist, 'installed_item_details'):
+		for d in self.get('installed_item_details'):
 			if d.prevdoc_docname:
 				d_date = frappe.db.get_value("Delivery Note", d.prevdoc_docname, "posting_date")				
 				if d_date > getdate(self.doc.inst_date):
@@ -99,7 +96,7 @@
 						" for item "+d.item_code, raise_exception=1)
 	
 	def check_item_table(self):
-		if not(getlist(self.doclist, 'installed_item_details')):
+		if not(self.get('installed_item_details')):
 			msgprint("Please fetch items from Delivery Note selected", raise_exception=1)
 	
 	def on_update(self):
@@ -111,7 +108,7 @@
 		frappe.db.set(self.doc, 'status', 'Submitted')
 	
 	def on_cancel(self):
-		for d in getlist(self.doclist, 'installed_item_details'):
+		for d in self.get('installed_item_details'):
 			if d.serial_no:
 				d.serial_no = d.serial_no.replace(",", "\n")
 				for sr_no in d.serial_no.split("\n"):
diff --git a/erpnext/selling/doctype/installation_note_item/installation_note_item.py b/erpnext/selling/doctype/installation_note_item/installation_note_item.py
index 26c87f1..ac3aacf 100644
--- a/erpnext/selling/doctype/installation_note_item/installation_note_item.py
+++ b/erpnext/selling/doctype/installation_note_item/installation_note_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class InstallationNoteItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/lead/lead.py b/erpnext/selling/doctype/lead/lead.py
index 614a9c2..1472ff2 100644
--- a/erpnext/selling/doctype/lead/lead.py
+++ b/erpnext/selling/doctype/lead/lead.py
@@ -10,10 +10,7 @@
 	
 from erpnext.controllers.selling_controller import SellingController
 
-class DocType(SellingController):
-	def __init__(self, doc, doclist):
-		self.doc = doc
-		self.doclist = doclist
+class Lead(SellingController):
 
 		self._prev = frappe._dict({
 			"contact_date": frappe.db.get_value("Lead", self.doc.name, "contact_date") if \
diff --git a/erpnext/selling/doctype/opportunity/opportunity.py b/erpnext/selling/doctype/opportunity/opportunity.py
index d2f7a2e..bbe9a60 100644
--- a/erpnext/selling/doctype/opportunity/opportunity.py
+++ b/erpnext/selling/doctype/opportunity/opportunity.py
@@ -11,19 +11,9 @@
 	
 from erpnext.utilities.transaction_base import TransactionBase
 
-class DocType(TransactionBase):
-	def __init__(self,doc,doclist):
-		self.doc = doc
-		self.doclist = doclist
-		self.fname = 'enq_details'
-		self.tname = 'Opportunity Item'
-		
-		self._prev = frappe._dict({
-			"contact_date": frappe.db.get_value("Opportunity", self.doc.name, "contact_date") if \
-				(not cint(self.doc.fields.get("__islocal"))) else None,
-			"contact_by": frappe.db.get_value("Opportunity", self.doc.name, "contact_by") if \
-				(not cint(self.doc.fields.get("__islocal"))) else None,
-		})
+class Opportunity(TransactionBase):
+	fname = 'enq_details'
+	tname = 'Opportunity Item'
 		
 	def get_item_details(self, item_code):
 		item = frappe.db.sql("""select item_name, stock_uom, description_html, description, item_group, brand
@@ -91,7 +81,7 @@
 		super(DocType, self).add_calendar_event(opts, force)
 
 	def validate_item_details(self):
-		if not getlist(self.doclist, 'enquiry_details'):
+		if not self.get('enquiry_details'):
 			msgprint("Please select items for which enquiry needs to be made")
 			raise Exception
 
@@ -102,6 +92,13 @@
 			msgprint("Customer is mandatory if 'Opportunity From' is selected as Customer", raise_exception=1)
 
 	def validate(self):
+		self._prev = frappe._dict({
+			"contact_date": frappe.db.get_value("Opportunity", self.doc.name, "contact_date") if \
+				(not cint(self.doc.fields.get("__islocal"))) else None,
+			"contact_by": frappe.db.get_value("Opportunity", self.doc.name, "contact_by") if \
+				(not cint(self.doc.fields.get("__islocal"))) else None,
+		})
+		
 		self.set_status()
 		self.validate_item_details()
 		self.validate_uom_is_integer("uom", "qty")
diff --git a/erpnext/selling/doctype/opportunity_item/opportunity_item.py b/erpnext/selling/doctype/opportunity_item/opportunity_item.py
index 26c87f1..26b2999 100644
--- a/erpnext/selling/doctype/opportunity_item/opportunity_item.py
+++ b/erpnext/selling/doctype/opportunity_item/opportunity_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class OpportunityItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index 484c487..530ad24 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -10,10 +10,7 @@
 
 from erpnext.controllers.selling_controller import SellingController
 
-class DocType(SellingController):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class Quotation(SellingController):
 		self.tname = 'Quotation Item'
 		self.fname = 'quotation_details'
 
@@ -22,7 +19,7 @@
 
 	def validate_for_items(self):
 		chk_dupl_itm = []
-		for d in getlist(self.doclist,'quotation_details'):
+		for d in self.get('quotation_details'):
 			if [cstr(d.item_code),cstr(d.description)] in chk_dupl_itm:
 				msgprint("Item %s has been entered twice. Please change description atleast to continue" % d.item_code)
 				raise Exception
@@ -33,7 +30,7 @@
 		super(DocType, self).validate_order_type()
 		
 		if self.doc.order_type in ['Maintenance', 'Service']:
-			for d in getlist(self.doclist, 'quotation_details'):
+			for d in self.get('quotation_details'):
 				is_service_item = frappe.db.sql("select is_service_item from `tabItem` where name=%s", d.item_code)
 				is_service_item = is_service_item and is_service_item[0][0] or 'No'
 				
@@ -41,7 +38,7 @@
 					msgprint("You can not select non service item "+d.item_code+" in Maintenance Quotation")
 					raise Exception
 		else:
-			for d in getlist(self.doclist, 'quotation_details'):
+			for d in self.get('quotation_details'):
 				is_sales_item = frappe.db.sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
 				is_sales_item = is_sales_item and is_sales_item[0][0] or 'No'
 				
@@ -69,7 +66,7 @@
 			frappe.throw(_("Cannot set as Lost as Sales Order is made."))
 	
 	def check_item_table(self):
-		if not getlist(self.doclist, 'quotation_details'):
+		if not self.get('quotation_details'):
 			msgprint("Please enter item details")
 			raise Exception
 		
@@ -89,7 +86,7 @@
 			
 	def print_other_charges(self,docname):
 		print_lst = []
-		for d in getlist(self.doclist,'other_charges'):
+		for d in self.get('other_charges'):
 			lst1 = []
 			lst1.append(d.description)
 			lst1.append(d.total)
diff --git a/erpnext/selling/doctype/quotation_item/quotation_item.py b/erpnext/selling/doctype/quotation_item/quotation_item.py
index 26c87f1..426b199 100644
--- a/erpnext/selling/doctype/quotation_item/quotation_item.py
+++ b/erpnext/selling/doctype/quotation_item/quotation_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class QuotationItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_bom/sales_bom.py b/erpnext/selling/doctype/sales_bom/sales_bom.py
index fb46961..3e97ed9 100644
--- a/erpnext/selling/doctype/sales_bom/sales_bom.py
+++ b/erpnext/selling/doctype/sales_bom/sales_bom.py
@@ -4,9 +4,10 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d,dl
+from frappe.model.document import Document
+
+class SalesBom(Document):
+
 
 	def autoname(self):
 		self.doc.name = self.doc.new_item_code
diff --git a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py
index 26c87f1..e1124d9 100644
--- a/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py
+++ b/erpnext/selling/doctype/sales_bom_item/sales_bom_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalesBomItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index fd915de..25eda9a 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -13,7 +13,7 @@
 
 from erpnext.controllers.selling_controller import SellingController
 
-class DocType(SellingController):
+class SalesOrder(SellingController):
 	def __init__(self, doc, doclist=None):
 		self.doc = doc
 		if not doclist: doclist = []
@@ -48,7 +48,7 @@
 	def validate_for_items(self):
 		check_list, flag = [], 0
 		chk_dupl_itm = []
-		for d in getlist(self.doclist, 'sales_order_details'):
+		for d in self.get('sales_order_details'):
 			e = [d.item_code, d.description, d.warehouse, d.prevdoc_docname or '']
 			f = [d.item_code, d.description]
 
@@ -75,7 +75,7 @@
 			d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0
 
 	def validate_sales_mntc_quotation(self):
-		for d in getlist(self.doclist, 'sales_order_details'):
+		for d in self.get('sales_order_details'):
 			if d.prevdoc_docname:
 				res = frappe.db.sql("select name from `tabQuotation` where name=%s and order_type = %s", (d.prevdoc_docname, self.doc.order_type))
 				if not res:
diff --git a/erpnext/selling/doctype/sales_order_item/sales_order_item.py b/erpnext/selling/doctype/sales_order_item/sales_order_item.py
index 26c87f1..ef2ad09 100644
--- a/erpnext/selling/doctype/sales_order_item/sales_order_item.py
+++ b/erpnext/selling/doctype/sales_order_item/sales_order_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalesOrderItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/sales_team/sales_team.py b/erpnext/selling/doctype/sales_team/sales_team.py
index 26c87f1..01d38d2 100644
--- a/erpnext/selling/doctype/sales_team/sales_team.py
+++ b/erpnext/selling/doctype/sales_team/sales_team.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SalesTeam(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/selling/doctype/selling_settings/selling_settings.py b/erpnext/selling/doctype/selling_settings/selling_settings.py
index 5b44c7b..6823fa1 100644
--- a/erpnext/selling/doctype/selling_settings/selling_settings.py
+++ b/erpnext/selling/doctype/selling_settings/selling_settings.py
@@ -6,9 +6,9 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class SellingSettings(Document):
 		
 	def validate(self):
 		for key in ["cust_master_name", "customer_group", "territory", "maintain_same_sales_rate",
diff --git a/erpnext/selling/doctype/sms_center/sms_center.py b/erpnext/selling/doctype/sms_center/sms_center.py
index 7da6f32..9aeb5ee 100644
--- a/erpnext/selling/doctype/sms_center/sms_center.py
+++ b/erpnext/selling/doctype/sms_center/sms_center.py
@@ -8,10 +8,9 @@
 from frappe.model.code import get_obj
 from frappe import msgprint, _
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class SmsCenter(Document):
 
 	def create_receiver_list(self):
 		rec, where_clause = '', ''
diff --git a/erpnext/setup/doctype/applicable_territory/applicable_territory.py b/erpnext/setup/doctype/applicable_territory/applicable_territory.py
index cb42e2e..25478d6 100644
--- a/erpnext/setup/doctype/applicable_territory/applicable_territory.py
+++ b/erpnext/setup/doctype/applicable_territory/applicable_territory.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ApplicableTerritory(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/authorization_control/authorization_control.py b/erpnext/setup/doctype/authorization_control/authorization_control.py
index b37686a..9b8980c 100644
--- a/erpnext/setup/doctype/authorization_control/authorization_control.py
+++ b/erpnext/setup/doctype/authorization_control/authorization_control.py
@@ -12,9 +12,7 @@
 	
 from erpnext.utilities.transaction_base import TransactionBase
 
-class DocType(TransactionBase):
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+class AuthorizationControl(TransactionBase):
 
 
 	# Get Names of all Approving Users and Roles
diff --git a/erpnext/setup/doctype/authorization_rule/authorization_rule.py b/erpnext/setup/doctype/authorization_rule/authorization_rule.py
index 71f5caf..5255e4c 100644
--- a/erpnext/setup/doctype/authorization_rule/authorization_rule.py
+++ b/erpnext/setup/doctype/authorization_rule/authorization_rule.py
@@ -7,9 +7,9 @@
 from frappe.utils import cint, cstr, flt, has_common
 from frappe import msgprint
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class AuthorizationRule(Document):
 
 
 	def check_duplicate_entry(self):
diff --git a/erpnext/setup/doctype/backup_manager/backup_manager.py b/erpnext/setup/doctype/backup_manager/backup_manager.py
index c397800..8f7e891 100644
--- a/erpnext/setup/doctype/backup_manager/backup_manager.py
+++ b/erpnext/setup/doctype/backup_manager/backup_manager.py
@@ -7,9 +7,9 @@
 import frappe
 from frappe import _
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class BackupManager(Document):
 
 def take_backups_daily():
 	take_backups_if("Daily")
diff --git a/erpnext/setup/doctype/brand/brand.py b/erpnext/setup/doctype/brand/brand.py
index d30eab6..5bdc243 100644
--- a/erpnext/setup/doctype/brand/brand.py
+++ b/erpnext/setup/doctype/brand/brand.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class Brand(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/company/company.py b/erpnext/setup/doctype/company/company.py
index 5162ffb..9c98068 100644
--- a/erpnext/setup/doctype/company/company.py
+++ b/erpnext/setup/doctype/company/company.py
@@ -9,9 +9,10 @@
 import frappe.defaults
 
 
-class DocType:
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d,dl
+from frappe.model.document import Document
+
+class Company(Document):
+
 		
 	def onload(self):
 		self.doc.fields["__transactions_exist"] = self.check_if_transactions_exist()
diff --git a/erpnext/setup/doctype/contact_control/contact_control.py b/erpnext/setup/doctype/contact_control/contact_control.py
index 35bd61c..96e9551 100644
--- a/erpnext/setup/doctype/contact_control/contact_control.py
+++ b/erpnext/setup/doctype/contact_control/contact_control.py
@@ -4,7 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self,doc,doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class ContactControl(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/country/country.py b/erpnext/setup/doctype/country/country.py
index d30eab6..5e16f51 100644
--- a/erpnext/setup/doctype/country/country.py
+++ b/erpnext/setup/doctype/country/country.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class Country(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/currency/currency.py b/erpnext/setup/doctype/currency/currency.py
index 2f6a62a..5541065 100644
--- a/erpnext/setup/doctype/currency/currency.py
+++ b/erpnext/setup/doctype/currency/currency.py
@@ -5,9 +5,9 @@
 import frappe
 from frappe import throw, _
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class Currency(Document):
 		
 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/currency_exchange/currency_exchange.py b/erpnext/setup/doctype/currency_exchange/currency_exchange.py
index 93f4419..a0624de 100644
--- a/erpnext/setup/doctype/currency_exchange/currency_exchange.py
+++ b/erpnext/setup/doctype/currency_exchange/currency_exchange.py
@@ -8,9 +8,7 @@
 from frappe import _, msgprint
 from frappe.model.controller import DocListController
 
-class DocType(DocListController):
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+class CurrencyExchange(DocListController):
 		
 	def autoname(self):
 		self.doc.name = self.doc.from_currency + "-" + self.doc.to_currency
diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py
index 547f19f..214e20c 100644
--- a/erpnext/setup/doctype/customer_group/customer_group.py
+++ b/erpnext/setup/doctype/customer_group/customer_group.py
@@ -7,10 +7,7 @@
 
 	
 from frappe.utils.nestedset import DocTypeNestedSet
-class DocType(DocTypeNestedSet):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class CustomerGroup(DocTypeNestedSet):
 		self.nsm_parent_field = 'parent_customer_group';
 
 	def validate(self): 
diff --git a/erpnext/setup/doctype/email_digest/email_digest.py b/erpnext/setup/doctype/email_digest/email_digest.py
index c46c43e..1344686 100644
--- a/erpnext/setup/doctype/email_digest/email_digest.py
+++ b/erpnext/setup/doctype/email_digest/email_digest.py
@@ -45,9 +45,9 @@
 </span></p>"""
 
 from frappe.model.controller import DocListController
-class DocType(DocListController):
-	def __init__(self, doc, doclist=[]):
-		self.doc, self.doclist = doc, doclist
+class EmailDigest(DocListController):
+	def __init__(self, arg1, arg2=None):
+		super(EmailDigest, self).__init__(arg1, arg2)
 		self.from_date, self.to_date = self.get_from_to_date()
 		self.future_from_date, self.future_to_date = self.get_future_from_to_date()
 		self.currency = frappe.db.get_value("Company", self.doc.company,
diff --git a/erpnext/setup/doctype/features_setup/features_setup.py b/erpnext/setup/doctype/features_setup/features_setup.py
index 0c9d6e4..825163d 100644
--- a/erpnext/setup/doctype/features_setup/features_setup.py
+++ b/erpnext/setup/doctype/features_setup/features_setup.py
@@ -2,9 +2,9 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class FeaturesSetup(Document):
 
 	def validate(self):
 		"""
diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.py b/erpnext/setup/doctype/global_defaults/global_defaults.py
index d61ff8a..bfe3265 100644
--- a/erpnext/setup/doctype/global_defaults/global_defaults.py
+++ b/erpnext/setup/doctype/global_defaults/global_defaults.py
@@ -22,9 +22,9 @@
 	'disable_rounded_total': 'disable_rounded_total',
 }
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class GlobalDefaults(Document):
 		
 	def on_update(self):
 		"""update defaults"""
diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py
index aa1002e..455d752 100644
--- a/erpnext/setup/doctype/item_group/item_group.py
+++ b/erpnext/setup/doctype/item_group/item_group.py
@@ -6,10 +6,7 @@
 
 from frappe.utils.nestedset import DocTypeNestedSet
 
-class DocType(DocTypeNestedSet):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class ItemGroup(DocTypeNestedSet):
 		self.nsm_parent_field = 'parent_item_group'
 	
 	def validate(self):
diff --git a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py
index 4d2d1ea..2c928aa 100644
--- a/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py
+++ b/erpnext/setup/doctype/jobs_email_settings/jobs_email_settings.py
@@ -8,9 +8,9 @@
 from frappe import _
 from frappe.utils import cint
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class JobsEmailSettings(Document):
 		
 	def validate(self):
 		if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \
diff --git a/erpnext/setup/doctype/naming_series/naming_series.py b/erpnext/setup/doctype/naming_series/naming_series.py
index 5b0c9e2..454b38a 100644
--- a/erpnext/setup/doctype/naming_series/naming_series.py
+++ b/erpnext/setup/doctype/naming_series/naming_series.py
@@ -8,9 +8,9 @@
 from frappe import msgprint, throw, _
 import frappe.model.doctype
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class NamingSeries(Document):
 
 	def get_transactions(self, arg=None):
 		return {
diff --git a/erpnext/setup/doctype/notification_control/notification_control.py b/erpnext/setup/doctype/notification_control/notification_control.py
index c513746..21bdcce 100644
--- a/erpnext/setup/doctype/notification_control/notification_control.py
+++ b/erpnext/setup/doctype/notification_control/notification_control.py
@@ -7,9 +7,10 @@
 from frappe import msgprint
 
 
-class DocType:
-	def __init__(self,d,dl):
-		self.doc, self.doclist = d,dl
+from frappe.model.document import Document
+
+class NotificationControl(Document):
+
 
 	def get_message(self, arg):
 		fn = arg.lower().replace(' ', '_') + '_message'
diff --git a/erpnext/setup/doctype/print_heading/print_heading.py b/erpnext/setup/doctype/print_heading/print_heading.py
index 263c31e..eb6d978 100644
--- a/erpnext/setup/doctype/print_heading/print_heading.py
+++ b/erpnext/setup/doctype/print_heading/print_heading.py
@@ -4,12 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-from frappe.model import db_exists
-from frappe.model.bean import copy_doclist
+from frappe.model.document import Document
 
-	
-
-
-class DocType:
-  def __init__(self,doc,doclist=[]):
-    self.doc, self.doclist = doc,doclist
\ No newline at end of file
+class PrintHeading(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py
index d30eab6..ea9f927 100644
--- a/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py
+++ b/erpnext/setup/doctype/quotation_lost_reason/quotation_lost_reason.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class QuotationLostReason(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py
index 4d2d1ea..01e9be4 100644
--- a/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py
+++ b/erpnext/setup/doctype/sales_email_settings/sales_email_settings.py
@@ -8,9 +8,9 @@
 from frappe import _
 from frappe.utils import cint
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class SalesEmailSettings(Document):
 		
 	def validate(self):
 		if cint(self.doc.extract_emails) and not (self.doc.email_id and self.doc.host and \
diff --git a/erpnext/setup/doctype/sales_partner/sales_partner.py b/erpnext/setup/doctype/sales_partner/sales_partner.py
index eefabf6..5e3e569 100644
--- a/erpnext/setup/doctype/sales_partner/sales_partner.py
+++ b/erpnext/setup/doctype/sales_partner/sales_partner.py
@@ -4,12 +4,9 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.utils import cint, cstr, filter_strip_join
+from frappe.model.document import Document
 
-class DocType():
-	def __init__(self, doc, doclist=None):
-		self.doc = doc
-		self.doclist = doclist
-
+class SalesPartner(Document):
 	def validate(self):
 		if self.doc.partner_website and not self.doc.partner_website.startswith("http"):
 			self.doc.partner_website = "http://" + self.doc.partner_website
diff --git a/erpnext/setup/doctype/sales_person/sales_person.py b/erpnext/setup/doctype/sales_person/sales_person.py
index 58ddd13..b128d2c 100644
--- a/erpnext/setup/doctype/sales_person/sales_person.py
+++ b/erpnext/setup/doctype/sales_person/sales_person.py
@@ -7,14 +7,11 @@
 from frappe.utils import flt
 from frappe.utils.nestedset import DocTypeNestedSet
 
-class DocType(DocTypeNestedSet):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class SalesPerson(DocTypeNestedSet):
 		self.nsm_parent_field = 'parent_sales_person';
 
 	def validate(self): 
-		for d in getlist(self.doclist, 'target_details'):
+		for d in self.get('target_details'):
 			if not flt(d.target_qty) and not flt(d.target_amount):
 				frappe.throw(_("Either target qty or target amount is mandatory."))
 	
diff --git a/erpnext/setup/doctype/sms_parameter/sms_parameter.py b/erpnext/setup/doctype/sms_parameter/sms_parameter.py
index 26c87f1..4c54a4f 100644
--- a/erpnext/setup/doctype/sms_parameter/sms_parameter.py
+++ b/erpnext/setup/doctype/sms_parameter/sms_parameter.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import 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 26c87f1..9361d3b 100644
--- a/erpnext/setup/doctype/sms_settings/sms_settings.py
+++ b/erpnext/setup/doctype/sms_settings/sms_settings.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SmsSettings(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/supplier_type/supplier_type.py b/erpnext/setup/doctype/supplier_type/supplier_type.py
index d30eab6..7036956 100644
--- a/erpnext/setup/doctype/supplier_type/supplier_type.py
+++ b/erpnext/setup/doctype/supplier_type/supplier_type.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class SupplierType(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/target_detail/target_detail.py b/erpnext/setup/doctype/target_detail/target_detail.py
index 26c87f1..2332560 100644
--- a/erpnext/setup/doctype/target_detail/target_detail.py
+++ b/erpnext/setup/doctype/target_detail/target_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class TargetDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
index 26c87f1..73ac394 100644
--- a/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
+++ b/erpnext/setup/doctype/terms_and_conditions/terms_and_conditions.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class TermsAndConditions(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 5dfe458..67669d9 100644
--- a/erpnext/setup/doctype/territory/territory.py
+++ b/erpnext/setup/doctype/territory/territory.py
@@ -9,14 +9,11 @@
 
 from frappe.utils.nestedset import DocTypeNestedSet
 	
-class DocType(DocTypeNestedSet):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
-		self.nsm_parent_field = 'parent_territory'
+class Territory(DocTypeNestedSet):
+	nsm_parent_field = 'parent_territory'
 
 	def validate(self): 
-		for d in getlist(self.doclist, 'target_details'):
+		for d in self.get('target_details'):
 			if not flt(d.target_qty) and not flt(d.target_amount):
 				msgprint("Either target qty or target amount is mandatory.")
 				raise Exception
diff --git a/erpnext/setup/doctype/uom/uom.py b/erpnext/setup/doctype/uom/uom.py
index d30eab6..2d076f6 100644
--- a/erpnext/setup/doctype/uom/uom.py
+++ b/erpnext/setup/doctype/uom/uom.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class Uom(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/doctype/website_item_group/website_item_group.py b/erpnext/setup/doctype/website_item_group/website_item_group.py
index cb42e2e..4665cab 100644
--- a/erpnext/setup/doctype/website_item_group/website_item_group.py
+++ b/erpnext/setup/doctype/website_item_group/website_item_group.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class WebsiteItemGroup(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/setup/page/setup_wizard/setup_wizard.py b/erpnext/setup/page/setup_wizard/setup_wizard.py
index eba79d8..b03eeae 100644
--- a/erpnext/setup/page/setup_wizard/setup_wizard.py
+++ b/erpnext/setup/page/setup_wizard/setup_wizard.py
@@ -334,16 +334,14 @@
 		fileurl = save_file(filename, content, "Letter Head", "Standard", decode=True).file_name
 		frappe.db.set_value("Letter Head", "Standard", "content", "<img src='%s' style='max-width: 100%%;'>" % fileurl)
 		
-		
-				
 def add_all_roles_to(name):
-	user = frappe.doc("User", name)
+	user = frappe.get_doc("User", name)
 	for role in frappe.db.sql("""select name from tabRole"""):
 		if role[0] not in ["Administrator", "Guest", "All", "Customer", "Supplier", "Partner"]:
-			d = user.addchild("user_roles", "UserRole")
+			d = user.append("user_roles")
 			d.role = role[0]
-			d.insert()
-			
+	user.save()
+
 def create_territories():
 	"""create two default territories, one for home country and one named Rest of the World"""
 	from frappe.utils.nestedset import get_root_of
diff --git a/erpnext/stock/doctype/batch/batch.py b/erpnext/stock/doctype/batch/batch.py
index 26c87f1..365cb38 100644
--- a/erpnext/stock/doctype/batch/batch.py
+++ b/erpnext/stock/doctype/batch/batch.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class Batch(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py
index 1b5e243..0587f47 100644
--- a/erpnext/stock/doctype/bin/bin.py
+++ b/erpnext/stock/doctype/bin/bin.py
@@ -9,10 +9,9 @@
 import frappe.defaults
 
 
-class DocType:	
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class Bin(Document):	
 		
 	def validate(self):
 		if self.doc.fields.get("__islocal") or not self.doc.stock_uom:
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index a7c4923..8d91e49 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -13,10 +13,7 @@
 from erpnext.stock.utils import update_bin
 from erpnext.controllers.selling_controller import SellingController
 
-class DocType(SellingController):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class DeliveryNote(SellingController):
 		self.tname = 'Delivery Note Item'
 		self.fname = 'delivery_note_details'
 		self.status_updater = [{
@@ -37,14 +34,14 @@
 		billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabSales Invoice Item`
 			where docstatus=1 and delivery_note=%s""", self.doc.name)
 		if billed_qty:
-			total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "delivery_note_details"})))
+			total_qty = sum((item.qty for item in self.get("delivery_note_details")))
 			self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty
 			
 	def get_portal_page(self):
 		return "shipment" if self.doc.docstatus==1 else None
 
 	def set_actual_qty(self):
-		for d in getlist(self.doclist, 'delivery_note_details'):
+		for d in self.get('delivery_note_details'):
 			if d.item_code and d.warehouse:
 				actual_qty = frappe.db.sql("""select actual_qty from `tabBin` 
 					where item_code = %s and warehouse = %s""", (d.item_code, d.warehouse))
@@ -53,7 +50,7 @@
 	def so_required(self):
 		"""check in manage account if sales order required or not"""
 		if frappe.db.get_value("Selling Settings", None, 'so_required') == 'Yes':
-			 for d in getlist(self.doclist,'delivery_note_details'):
+			 for d in self.get('delivery_note_details'):
 				 if not d.against_sales_order:
 					 msgprint("Sales Order No. required against item %s"%d.item_code)
 					 raise Exception
@@ -81,7 +78,7 @@
 		if not self.doc.installation_status: self.doc.installation_status = 'Not Installed'	
 		
 	def validate_with_previous_doc(self):
-		items = self.doclist.get({"parentfield": "delivery_note_details"})
+		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]):
@@ -114,7 +111,7 @@
 
 	def validate_for_items(self):
 		check_list, chk_dupl_itm = [], []
-		for d in getlist(self.doclist,'delivery_note_details'):
+		for d in self.get('delivery_note_details'):
 			e = [d.item_code, d.description, d.warehouse, d.against_sales_order or d.against_sales_invoice, d.batch_no or '']
 			f = [d.item_code, d.description, d.against_sales_order or d.against_sales_invoice]
 
@@ -140,11 +137,11 @@
 				
 
 	def update_current_stock(self):
-		for d in getlist(self.doclist, 'delivery_note_details'):
+		for d in self.get('delivery_note_details'):
 			bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
 			d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
 
-		for d in getlist(self.doclist, 'packing_details'):
+		for d in self.get('packing_details'):
 			bin = frappe.db.sql("select actual_qty, projected_qty from `tabBin` where item_code =	%s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1)
 			d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0
 			d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0
@@ -268,7 +265,7 @@
 	def credit_limit(self):
 		"""check credit limit of items in DN Detail which are not fetched from sales order"""
 		amount, total = 0, 0
-		for d in getlist(self.doclist, 'delivery_note_details'):
+		for d in self.get('delivery_note_details'):
 			if not (d.against_sales_order or d.against_sales_invoice):
 				amount += d.base_amount
 		if amount != 0:
@@ -299,7 +296,7 @@
 		si.set_doclist(si.doclist.get({"parentfield": ["!=", "entries"]}) +
 			si.doclist.get({"parentfield": "entries", "qty": [">", 0]}))
 		
-		if len(si.doclist.get({"parentfield": "entries"})) == 0:
+		if len(si.get("entries")) == 0:
 			frappe.msgprint(_("Hey! All these items have already been invoiced."),
 				raise_exception=True)
 				
diff --git a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py
index 26c87f1..3789cda 100644
--- a/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py
+++ b/erpnext/stock/doctype/delivery_note_item/delivery_note_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class DeliveryNoteItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 58d151a..3a20d8c 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -5,7 +5,6 @@
 import frappe
 
 from frappe.utils import cstr, flt, getdate, now_datetime, formatdate
-from frappe.model.doc import addchild
 from frappe.model.bean import getlist
 from frappe import msgprint, _
 
@@ -13,7 +12,7 @@
 
 class WarehouseNotSet(Exception): pass
 
-class DocType(DocListController):
+class Item(DocListController):
 	def onload(self):
 		self.doc.fields["__sle_exists"] = self.check_if_sle_exists()
 	
@@ -58,13 +57,13 @@
 				raise_exception=WarehouseNotSet)
 			
 	def add_default_uom_in_conversion_factor_table(self):
-		uom_conv_list = [d.uom for d in self.doclist.get({"parentfield": "uom_conversion_details"})]
+		uom_conv_list = [d.uom for d in self.get("uom_conversion_details")]
 		if self.doc.stock_uom not in uom_conv_list:
-			ch = addchild(self.doc, 'uom_conversion_details', 'UOM Conversion Detail', self.doclist)
+			ch = self.doc.append('uom_conversion_details', {})
 			ch.uom = self.doc.stock_uom
 			ch.conversion_factor = 1
 			
-		for d in self.doclist.get({"parentfield": "uom_conversion_details"}):
+		for d in self.get("uom_conversion_details"):
 			if d.conversion_factor == 1 and d.uom != self.doc.stock_uom:
 				self.doclist.remove(d)
 				
@@ -95,7 +94,7 @@
 	
 	def validate_conversion_factor(self):
 		check_list = []
-		for d in getlist(self.doclist,'uom_conversion_details'):
+		for d in self.get('uom_conversion_details'):
 			if cstr(d.uom) in check_list:
 				msgprint(_("UOM %s has been entered more than once in Conversion Factor Table." %
 				 	cstr(d.uom)), raise_exception=1)
@@ -141,14 +140,14 @@
 	def fill_customer_code(self):
 		""" Append all the customer codes and insert into "customer_code" field of item table """
 		cust_code=[]
-		for d in getlist(self.doclist,'item_customer_details'):
+		for d in self.get('item_customer_details'):
 			cust_code.append(d.ref_code)
 		self.doc.customer_code=','.join(cust_code)
 
 	def check_item_tax(self):
 		"""Check whether Tax Rate is not entered twice for same Tax Type"""
 		check_list=[]
-		for d in getlist(self.doclist,'item_tax'):
+		for d in self.get('item_tax'):
 			if d.tax_type:
 				account_type = frappe.db.get_value("Account", d.tax_type, "account_type")
 				
diff --git a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py
index 26c87f1..b0bd280c 100644
--- a/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py
+++ b/erpnext/stock/doctype/item_customer_detail/item_customer_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ItemCustomerDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_price/item_price.py b/erpnext/stock/doctype/item_price/item_price.py
index 879fcae..3c3972b 100644
--- a/erpnext/stock/doctype/item_price/item_price.py
+++ b/erpnext/stock/doctype/item_price/item_price.py
@@ -7,9 +7,9 @@
 
 class ItemPriceDuplicateItem(frappe.ValidationError): pass
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class ItemPrice(Document):
 
 	def validate(self):
 		self.validate_item()
diff --git a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py
index 26c87f1..b659bb0 100644
--- a/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py
+++ b/erpnext/stock/doctype/item_quality_inspection_parameter/item_quality_inspection_parameter.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ItemQualityInspectionParameter(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_reorder/item_reorder.py b/erpnext/stock/doctype/item_reorder/item_reorder.py
index 968a25b..7dcefb0 100644
--- a/erpnext/stock/doctype/item_reorder/item_reorder.py
+++ b/erpnext/stock/doctype/item_reorder/item_reorder.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ItemReorder(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_supplier/item_supplier.py b/erpnext/stock/doctype/item_supplier/item_supplier.py
index 26c87f1..68f4816 100644
--- a/erpnext/stock/doctype/item_supplier/item_supplier.py
+++ b/erpnext/stock/doctype/item_supplier/item_supplier.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ItemSupplier(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_tax/item_tax.py b/erpnext/stock/doctype/item_tax/item_tax.py
index 26c87f1..96363e8 100644
--- a/erpnext/stock/doctype/item_tax/item_tax.py
+++ b/erpnext/stock/doctype/item_tax/item_tax.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ItemTax(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item_website_specification/item_website_specification.py b/erpnext/stock/doctype/item_website_specification/item_website_specification.py
index 968a25b..ceb0727 100644
--- a/erpnext/stock/doctype/item_website_specification/item_website_specification.py
+++ b/erpnext/stock/doctype/item_website_specification/item_website_specification.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class ItemWebsiteSpecification(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py
index 26c87f1..4681361 100644
--- a/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py
+++ b/erpnext/stock/doctype/landed_cost_item/landed_cost_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class LandedCostItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py
index 26c87f1..090f833 100644
--- a/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py
+++ b/erpnext/stock/doctype/landed_cost_purchase_receipt/landed_cost_purchase_receipt.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class LandedCostPurchaseReceipt(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
index c52c820..34cbe3e 100644
--- a/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
+++ b/erpnext/stock/doctype/landed_cost_wizard/landed_cost_wizard.py
@@ -4,13 +4,11 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.utils import flt
-from frappe.model.doc import addchild
 from frappe import msgprint, _
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class LandedCostWizard(Document):
 			
 	def update_landed_cost(self):
 		"""
@@ -18,7 +16,7 @@
 			Recalculate valuation rate in all sle after pr posting date
 		"""
 		purchase_receipts = [row.purchase_receipt for row in 
-			self.doclist.get({"parentfield": "lc_pr_details"})]
+			self.get("lc_pr_details")]
 			
 		self.validate_purchase_receipts(purchase_receipts)
 		self.cancel_pr(purchase_receipts)
@@ -37,10 +35,9 @@
 		
 		for pr in purchase_receipts:
 			pr_bean = frappe.bean('Purchase Receipt', pr)
-			pr_items = pr_bean.doclist.get({"parentfield": "purchase_tax_details"})
-			idx = max([d.idx for d in pr_items]) if pr_items else 0
+			pr_items = pr_bean.get("purchase_tax_details")
 			
-			for lc in self.doclist.get({"parentfield": "landed_cost_details"}):
+			for lc in self.get("landed_cost_details"):
 				amt = flt(lc.amount) * flt(pr_bean.doc.net_total)/ flt(total_amt)
 				
 				matched_row = pr_bean.doclist.get({
@@ -52,7 +49,7 @@
 				})
 				
 				if not matched_row:	# add if not exists
-					ch = addchild(pr_bean.doc, 'other_charges', 'Purchase Taxes and Charges')
+					ch = pr_bean.append("other_charges")
 					ch.category = 'Valuation'
 					ch.add_deduct_tax = 'Add'
 					ch.charge_type = 'Actual'
@@ -62,9 +59,7 @@
 					ch.rate = amt
 					ch.tax_amount = amt
 					ch.docstatus = 1
-					ch.idx = idx + 1
 					ch.save(1)
-					idx += 1
 				else:	# overwrite if exists
 					matched_row[0].rate = amt
 					matched_row[0].tax_amount = amt
diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py
index 2fca85b..c05a8d8 100644
--- a/erpnext/stock/doctype/material_request/material_request.py
+++ b/erpnext/stock/doctype/material_request/material_request.py
@@ -13,19 +13,16 @@
 from frappe import msgprint, _
 
 from erpnext.controllers.buying_controller import BuyingController
-class DocType(BuyingController):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class MaterialRequest(BuyingController):
 		self.tname = 'Material Request Item'
 		self.fname = 'indent_details'
 
 	def check_if_already_pulled(self):
-		pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')]
+		pass#if self.[d.sales_order_no for d in self.get('indent_details')]
 
 	def validate_qty_against_so(self):
 		so_items = {} # Format --> {'SO/00001': {'Item/001': 120, 'Item/002': 24}}
-		for d in getlist(self.doclist, 'indent_details'):
+		for d in self.get('indent_details'):
 			if d.sales_order_no:
 				if not so_items.has_key(d.sales_order_no):
 					so_items[d.sales_order_no] = {d.item_code: flt(d.qty)}
@@ -53,7 +50,7 @@
 						% (actual_so_qty - already_indented, item, so_no))
 				
 	def validate_schedule_date(self):
-		for d in getlist(self.doclist, 'indent_details'):
+		for d in self.get('indent_details'):
 			if d.schedule_date < self.doc.transaction_date:
 				frappe.throw(_("Expected Date cannot be before Material Request Date"))
 				
@@ -84,7 +81,7 @@
 		""" Update Quantity Requested for Purchase in Bin for Material Request of type 'Purchase'"""
 		
 		from erpnext.stock.utils import update_bin
-		for d in getlist(self.doclist, 'indent_details'):
+		for d in self.get('indent_details'):
 			if frappe.db.get_value("Item", d.item_code, "is_stock_item") == "Yes":
 				if not d.warehouse:
 					frappe.throw("Please Enter Warehouse for Item %s as it is stock item" 
@@ -146,7 +143,7 @@
 		if self.doc.material_request_type != "Transfer":
 			return
 			
-		item_doclist = self.doclist.get({"parentfield": "indent_details"})
+		item_doclist = self.get("indent_details")
 		
 		if not mr_items:
 			mr_items = [d.name for d in item_doclist]
@@ -174,7 +171,7 @@
 	if bean.doc.doctype == "Stock Entry":
 		material_request_map = {}
 		
-		for d in bean.doclist.get({"parentfield": "mtn_details"}):
+		for d in bean.get("mtn_details"):
 			if d.material_request:
 				material_request_map.setdefault(d.material_request, []).append(d.material_request_item)
 			
diff --git a/erpnext/stock/doctype/material_request_item/material_request_item.py b/erpnext/stock/doctype/material_request_item/material_request_item.py
index 968a25b..30101f3 100644
--- a/erpnext/stock/doctype/material_request_item/material_request_item.py
+++ b/erpnext/stock/doctype/material_request_item/material_request_item.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class MaterialRequestItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/packed_item/packed_item.py b/erpnext/stock/doctype/packed_item/packed_item.py
index b01307d..b7a15b7 100644
--- a/erpnext/stock/doctype/packed_item/packed_item.py
+++ b/erpnext/stock/doctype/packed_item/packed_item.py
@@ -6,12 +6,11 @@
 from __future__ import unicode_literals
 import frappe
 from frappe.utils import cstr, flt
-from frappe.model.doc import addchild
 from frappe.model.bean import getlist
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class PackedItem(Document):
 		
 def get_sales_bom_items(item_code):
 	return frappe.db.sql("""select t1.item_code, t1.qty, t1.uom 
@@ -39,7 +38,7 @@
 			break
 
 	if not exists:
-		pi = addchild(obj.doc, 'packing_details', 'Packed Item', obj.doclist)
+		pi = obj.doc.append('packing_details', {})
 
 	pi.parent_item = line.item_code
 	pi.item_code = packing_item_code
@@ -81,7 +80,7 @@
 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.doclist.get({"parentfield": "packing_details"}):
+	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])
diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.py b/erpnext/stock/doctype/packing_slip/packing_slip.py
index b7b6473..99a6ee3 100644
--- a/erpnext/stock/doctype/packing_slip/packing_slip.py
+++ b/erpnext/stock/doctype/packing_slip/packing_slip.py
@@ -5,11 +5,10 @@
 import frappe
 from frappe.utils import flt, cint
 from frappe import msgprint, _
-from frappe.model.doc import addchild
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class PackingSlip(Document):
 
 	def validate(self):
 		"""
@@ -36,7 +35,7 @@
 			msgprint(_("""Invalid Delivery Note. Delivery Note should exist and should be in draft state. Please rectify and try again."""), raise_exception=1)
 	
 	def validate_items_mandatory(self):
-		rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})]
+		rows = [d.item_code for d in self.get("item_details")]
 		if not rows:
 			frappe.msgprint(_("No Items to Pack"), raise_exception=1)
 
@@ -87,7 +86,7 @@
 			* No. of Cases of this packing slip
 		"""
 		
-		rows = [d.item_code for d in self.doclist.get({"parentfield": "item_details"})]
+		rows = [d.item_code for d in self.get("item_details")]
 		
 		condition = ""
 		if rows:
@@ -132,7 +131,7 @@
 		if not self.doc.from_case_no:
 			self.doc.from_case_no = self.get_recommended_case_no()
 
-		for d in self.doclist.get({"parentfield": "item_details"}):
+		for d in self.get("item_details"):
 			res = frappe.db.get_value("Item", d.item_code, 
 				["net_weight", "weight_uom"], as_dict=True)
 			
@@ -151,12 +150,12 @@
 		return cint(recommended_case_no[0][0]) + 1
 		
 	def get_items(self):
-		self.doclist = self.doc.clear_table(self.doclist, "item_details", 1)
+		self.set("item_details", [])
 		
 		dn_details = self.get_details_for_packing()[0]
 		for item in dn_details:
 			if flt(item.qty) > flt(item.packed_qty):
-				ch = addchild(self.doc, 'item_details', 'Packing Slip Item', self.doclist)
+				ch = self.doc.append('item_details', {})
 				ch.item_code = item.item_code
 				ch.item_name = item.item_name
 				ch.stock_uom = item.stock_uom
diff --git a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py
index 968a25b..033e44b 100644
--- a/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py
+++ b/erpnext/stock/doctype/packing_slip_item/packing_slip_item.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PackingSlipItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py
index 37b9567..420c6c5 100644
--- a/erpnext/stock/doctype/price_list/price_list.py
+++ b/erpnext/stock/doctype/price_list/price_list.py
@@ -8,12 +8,12 @@
 from frappe.model.controller import DocListController
 import frappe.defaults
 
-class DocType(DocListController):
+class PriceList(DocListController):
 	def validate(self):
 		if not cint(self.doc.buying) and not cint(self.doc.selling):
 			throw(_("Price List must be applicable for Buying or Selling"))
 				
-		if not self.doclist.get({"parentfield": "valid_for_territories"}):
+		if not self.get("valid_for_territories"):
 			# if no territory, set default territory
 			if frappe.defaults.get_user_default("territory"):
 				self.doclist.append({
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index d1e86a8..bad59a6 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -12,10 +12,7 @@
 from erpnext.stock.utils import update_bin
 
 from erpnext.controllers.buying_controller import BuyingController
-class DocType(BuyingController):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class PurchaseReceipt(BuyingController):
 		self.tname = 'Purchase Receipt Item'
 		self.fname = 'purchase_receipt_details'
 		self.count = 0
@@ -35,7 +32,7 @@
 		billed_qty = frappe.db.sql("""select sum(ifnull(qty, 0)) from `tabPurchase Invoice Item`
 			where purchase_receipt=%s""", self.doc.name)
 		if billed_qty:
-			total_qty = sum((item.qty for item in self.doclist.get({"parentfield": "purchase_receipt_details"})))
+			total_qty = sum((item.qty for item in self.get("purchase_receipt_details")))
 			self.doc.fields["__billing_complete"] = billed_qty[0][0] == total_qty
 
 	def validate(self):
@@ -68,7 +65,7 @@
 		self.update_valuation_rate("purchase_receipt_details")
 
 	def validate_rejected_warehouse(self):
-		for d in self.doclist.get({"parentfield": "purchase_receipt_details"}):
+		for d in self.get("purchase_receipt_details"):
 			if flt(d.rejected_qty) and not d.rejected_warehouse:
 				d.rejected_warehouse = self.doc.rejected_warehouse
 				if not d.rejected_warehouse:
@@ -76,7 +73,7 @@
 
 	# validate accepted and rejected qty
 	def validate_accepted_rejected_qty(self):
-		for d in getlist(self.doclist, "purchase_receipt_details"):
+		for d in self.get("purchase_receipt_details"):
 			if not flt(d.received_qty) and flt(d.qty):
 				d.received_qty = flt(d.qty) - flt(d.rejected_qty)
 
@@ -129,7 +126,7 @@
 
 	def po_required(self):
 		if frappe.db.get_value("Buying Settings", None, "po_required") == 'Yes':
-			 for d in getlist(self.doclist,'purchase_receipt_details'):
+			 for d in self.get('purchase_receipt_details'):
 				 if not d.prevdoc_docname:
 					 msgprint("Purchse Order No. required against item %s"%d.item_code)
 					 raise Exception
@@ -138,7 +135,7 @@
 		sl_entries = []
 		stock_items = self.get_stock_items()
 		
-		for d in getlist(self.doclist, 'purchase_receipt_details'):
+		for d in self.get('purchase_receipt_details'):
 			if d.item_code in stock_items and d.warehouse:
 				pr_qty = flt(d.qty) * flt(d.conversion_factor)
 				
@@ -162,7 +159,7 @@
 				
 	def update_ordered_qty(self):
 		stock_items = self.get_stock_items()
-		for d in self.doclist.get({"parentfield": "purchase_receipt_details"}):
+		for d in self.get("purchase_receipt_details"):
 			if d.item_code in stock_items and d.warehouse \
 					and cstr(d.prevdoc_doctype) == 'Purchase Order':
 									
@@ -198,7 +195,7 @@
 		return po_qty, po_warehouse
 	
 	def bk_flush_supp_wh(self, sl_entries):
-		for d in getlist(self.doclist, 'pr_raw_material_details'):
+		for d in self.get('pr_raw_material_details'):
 			# negative quantity is passed as raw material qty has to be decreased 
 			# when PR is submitted and it has to be increased when PR is cancelled
 			sl_entries.append(self.get_sl_entries(d, {
@@ -209,7 +206,7 @@
 			}))
 
 	def validate_inspection(self):
-		for d in getlist(self.doclist, 'purchase_receipt_details'):		 #Enter inspection date for all items that require inspection
+		for d in self.get('purchase_receipt_details'):		 #Enter inspection date for all items that require inspection
 			ins_reqd = frappe.db.sql("select inspection_required from `tabItem` where name = %s",
 				(d.item_code,), as_dict = 1)
 			ins_reqd = ins_reqd and ins_reqd[0]['inspection_required'] or 'No'
@@ -219,7 +216,7 @@
 	# Check for Stopped status
 	def check_for_stopped_status(self, pc_obj):
 		check_list =[]
-		for d in getlist(self.doclist, 'purchase_receipt_details'):
+		for d in self.get('purchase_receipt_details'):
 			if d.fields.has_key('prevdoc_docname') and d.prevdoc_docname and d.prevdoc_docname not in check_list:
 				check_list.append(d.prevdoc_docname)
 				pc_obj.check_for_stopped_status( d.prevdoc_doctype, d.prevdoc_docname)
@@ -282,7 +279,7 @@
 		self.make_cancel_gl_entries()
 			
 	def get_current_stock(self):
-		for d in getlist(self.doclist, 'pr_raw_material_details'):
+		for d in self.get('pr_raw_material_details'):
 			if self.doc.supplier_warehouse:
 				bin = frappe.db.sql("select actual_qty from `tabBin` where item_code = %s and warehouse = %s", (d.rm_item_code, self.doc.supplier_warehouse), as_dict = 1)
 				d.current_stock = bin and flt(bin[0]['actual_qty']) or 0
diff --git a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 862bd84..2a2e821 100644
--- a/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -95,7 +95,7 @@
 		pr.insert()
 		
 		self.assertEquals(pr.doclist[1].rm_supp_cost, 70000.0)
-		self.assertEquals(len(pr.doclist.get({"parentfield": "pr_raw_material_details"})), 2)
+		self.assertEquals(len(pr.get("pr_raw_material_details")), 2)
 		
 	def test_serial_no_supplier(self):
 		pr = frappe.bean(copy=test_records[0])
diff --git a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py
index 26c87f1..35fca0d 100644
--- a/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py
+++ b/erpnext/stock/doctype/purchase_receipt_item/purchase_receipt_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class PurchaseReceiptItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/serial_no/serial_no.py b/erpnext/stock/doctype/serial_no/serial_no.py
index d52d48d..d8bdb77 100644
--- a/erpnext/stock/doctype/serial_no/serial_no.py
+++ b/erpnext/stock/doctype/serial_no/serial_no.py
@@ -20,7 +20,7 @@
 class SerialNoNotExistsError(ValidationError): pass
 class SerialNoDuplicateError(ValidationError): pass
 
-class DocType(StockController):
+class SerialNo(StockController):
 	def __init__(self, doc, doclist=None):
 		self.doc = doc
 		self.doclist = doclist or []
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 3aeb507..785ad97 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -6,7 +6,6 @@
 import frappe.defaults
 
 from frappe.utils import cstr, cint, flt, comma_or, nowdate
-from frappe.model.doc import addchild
 from frappe.model.bean import getlist
 from frappe.model.code import get_obj
 from frappe import msgprint, _
@@ -24,10 +23,7 @@
 	
 from erpnext.controllers.stock_controller import StockController
 
-class DocType(StockController):
-	def __init__(self, doc, doclist=None):
-		self.doc = doc
-		self.doclist = doclist
+class StockEntry(StockController):
 		self.fname = 'mtn_details' 
 		
 	def validate(self):
@@ -77,7 +73,7 @@
 		
 	def validate_item(self):
 		stock_items = self.get_stock_items()
-		for item in self.doclist.get({"parentfield": "mtn_details"}):
+		for item in self.get("mtn_details"):
 			if item.item_code not in stock_items:
 				msgprint(_("""Only Stock Items are allowed for Stock Entry"""),
 					raise_exception=True)
@@ -93,14 +89,14 @@
 
 		if self.doc.purpose in source_mandatory and self.doc.purpose not in target_mandatory:
 			self.doc.to_warehouse = None
-			for d in getlist(self.doclist, 'mtn_details'):
+			for d in self.get('mtn_details'):
 				d.t_warehouse = None
 		elif self.doc.purpose in target_mandatory and self.doc.purpose not in source_mandatory:
 			self.doc.from_warehouse = None
-			for d in getlist(self.doclist, 'mtn_details'):
+			for d in self.get('mtn_details'):
 				d.s_warehouse = None
 
-		for d in getlist(self.doclist, 'mtn_details'):
+		for d in self.get('mtn_details'):
 			if not d.s_warehouse and not d.t_warehouse:
 				d.s_warehouse = self.doc.from_warehouse
 				d.t_warehouse = self.doc.to_warehouse
@@ -176,11 +172,11 @@
 					+ self.doc.production_order + ":" + ", ".join(other_ste), DuplicateEntryForProductionOrderError)
 
 	def set_total_amount(self):
-		self.doc.total_amount = sum([flt(item.amount) for item in self.doclist.get({"parentfield": "mtn_details"})])
+		self.doc.total_amount = sum([flt(item.amount) for item in self.get("mtn_details")])
 			
 	def get_stock_and_rate(self):
 		"""get stock and incoming rate on posting date"""
-		for d in getlist(self.doclist, 'mtn_details'):
+		for d in self.get('mtn_details'):
 			args = frappe._dict({
 				"item_code": d.item_code,
 				"warehouse": d.s_warehouse or d.t_warehouse,
@@ -225,12 +221,12 @@
 		return incoming_rate
 		
 	def validate_incoming_rate(self):
-		for d in getlist(self.doclist, 'mtn_details'):
+		for d in self.get('mtn_details'):
 			if d.t_warehouse:
 				self.validate_value("incoming_rate", ">", 0, d, raise_exception=IncorrectValuationRateError)
 					
 	def validate_bom(self):
-		for d in getlist(self.doclist, 'mtn_details'):
+		for d in self.get('mtn_details'):
 			if d.bom_no and not frappe.db.sql("""select name from `tabBOM`
 					where item = %s and name = %s and docstatus = 1 and is_active = 1""",
 					(d.item_code, d.bom_no)):
@@ -240,7 +236,7 @@
 					
 	def validate_finished_goods(self):
 		"""validation: finished good quantity should be same as manufacturing quantity"""
-		for d in getlist(self.doclist, 'mtn_details'):
+		for d in self.get('mtn_details'):
 			if d.bom_no and flt(d.transfer_qty) != flt(self.doc.fg_completed_qty):
 				msgprint(_("Row #") + " %s: " % d.idx 
 					+ _("Quantity should be equal to Manufacturing Quantity. To fetch items again, click on 'Get Items' button or update the Quantity manually."), raise_exception=1)
@@ -275,7 +271,7 @@
 			stock_items = get_stock_items_for_return(ref.doclist, ref.parentfields)
 			already_returned_item_qty = self.get_already_returned_item_qty(ref.fieldname)
 			
-			for item in self.doclist.get({"parentfield": "mtn_details"}):
+			for item in self.get("mtn_details"):
 				# validate if item exists in the ref doclist and that it is a stock item
 				if item.item_code not in stock_items:
 					msgprint(_("Item") + ': "' + item.item_code + _("\" does not exist in ") +
@@ -303,7 +299,7 @@
 						
 	def update_stock_ledger(self):
 		sl_entries = []			
-		for d in getlist(self.doclist, 'mtn_details'):
+		for d in self.get('mtn_details'):
 			if cstr(d.s_warehouse) and self.doc.docstatus == 1:
 				sl_entries.append(self.get_sl_entries(d, {
 					"warehouse": cstr(d.s_warehouse),
@@ -431,7 +427,7 @@
 		
 	def get_items(self):
 		self.doclist = filter(lambda d: d.parentfield!="mtn_details", self.doclist)
-		# self.doclist = self.doc.clear_table(self.doclist, 'mtn_details')
+		# self.set('mtn_details', [])
 		
 		pro_obj = None
 		if self.doc.production_order:
@@ -566,8 +562,7 @@
 			["default_expense_account", "cost_center"])[0]
 
 		for d in item_dict:
-			se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail', 
-				self.doclist)
+			se_child = self.doc.append('mtn_details', {})
 			se_child.idx = idx
 			se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse)
 			se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse)
@@ -592,7 +587,7 @@
 		return idx
 		
 	def validate_with_material_request(self):
-		for item in self.doclist.get({"parentfield": "mtn_details"}):
+		for item in self.get("mtn_details"):
 			if item.material_request:
 				mreq_item = frappe.db.get_value("Material Request Item", 
 					{"name": item.material_request_item, "parent": item.material_request},
@@ -801,7 +796,7 @@
 	
 	# income account entries
 	children = []
-	for se_item in se.doclist.get({"parentfield": "mtn_details"}):
+	for se_item in se.get("mtn_details"):
 		# find item in ref.doclist
 		ref_item = ref.doclist.getone({"item_code": se_item.item_code})
 		
@@ -843,7 +838,7 @@
 	parent = {}
 	children = []
 	
-	for se_item in se.doclist.get({"parentfield": "mtn_details"}):
+	for se_item in se.get("mtn_details"):
 		for sales_invoice in invoices_against_delivery:
 			si = frappe.bean("Sales Invoice", sales_invoice)
 			
@@ -900,7 +895,7 @@
 	parent = {}
 	children = []
 	
-	for se_item in se.doclist.get({"parentfield": "mtn_details"}):
+	for se_item in se.get("mtn_details"):
 		for purchase_invoice in invoice_against_receipt:
 			pi = frappe.bean("Purchase Invoice", purchase_invoice)
 			ref_item = pi.doclist.get({"item_code": se_item.item_code})
diff --git a/erpnext/stock/doctype/stock_entry/test_stock_entry.py b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
index d14e896..dc27cc9 100644
--- a/erpnext/stock/doctype/stock_entry/test_stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/test_stock_entry.py
@@ -335,7 +335,7 @@
 		si = frappe.bean(si_doclist)
 		si.doc.posting_date = dn.doc.posting_date
 		si.doc.debit_to = "_Test Customer - _TC"
-		for d in si.doclist.get({"parentfield": "entries"}):
+		for d in si.get("entries"):
 			d.income_account = "Sales - _TC"
 			d.cost_center = "_Test Cost Center - _TC"
 		si.insert()
@@ -433,7 +433,7 @@
 		si = frappe.bean(si_doclist)
 		si.doc.posting_date = dn.doc.posting_date
 		si.doc.debit_to = "_Test Customer - _TC"
-		for d in si.doclist.get({"parentfield": "entries"}):
+		for d in si.get("entries"):
 			d.income_account = "Sales - _TC"
 			d.cost_center = "_Test Cost Center - _TC"
 		si.insert()
@@ -479,11 +479,11 @@
 		pi = frappe.bean(pi_doclist)
 		pi.doc.posting_date = pr.doc.posting_date
 		pi.doc.credit_to = "_Test Supplier - _TC"
-		for d in pi.doclist.get({"parentfield": "entries"}):
+		for d in pi.get("entries"):
 			d.expense_account = "_Test Account Cost for Goods Sold - _TC"
 			d.cost_center = "_Test Cost Center - _TC"
 
-		for d in pi.doclist.get({"parentfield": "other_charges"}):
+		for d in pi.get("other_charges"):
 			d.cost_center = "_Test Cost Center - _TC"
 
 		pi.run_method("calculate_taxes_and_totals")
@@ -582,10 +582,10 @@
 		pi = frappe.bean(pi_doclist)
 		pi.doc.posting_date = pr.doc.posting_date
 		pi.doc.credit_to = "_Test Supplier - _TC"
-		for d in pi.doclist.get({"parentfield": "entries"}):
+		for d in pi.get("entries"):
 			d.expense_account = "_Test Account Cost for Goods Sold - _TC"
 			d.cost_center = "_Test Cost Center - _TC"
-		for d in pi.doclist.get({"parentfield": "other_charges"}):
+		for d in pi.get("other_charges"):
 			d.cost_center = "_Test Cost Center - _TC"
 
 		pi.run_method("calculate_taxes_and_totals")
diff --git a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py
index 26c87f1..2570b68 100644
--- a/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py
+++ b/erpnext/stock/doctype/stock_entry_detail/stock_entry_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class StockEntryDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/stock_ledger/stock_ledger.py b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
index 664eadb..452ad35 100644
--- a/erpnext/stock/doctype/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
@@ -12,10 +12,9 @@
 from erpnext.stock.utils import get_valid_serial_nos
 
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class StockLedger(Document):
 		
 	def update_stock(self, values, is_amended = 'No'):
 		for v in values:
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index 9bb9911..dfc75d5 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -11,10 +11,7 @@
 
 class StockFreezeError(frappe.ValidationError): pass
 
-class DocType(DocListController):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class StockLedgerEntry(DocListController):
 
 	def validate(self):
 		from erpnext.stock.utils import validate_warehouse_company
diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
index 7eef0a4..c4195c6 100644
--- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
+++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py
@@ -10,7 +10,7 @@
 from erpnext.stock.stock_ledger import update_entries_after
 from erpnext.controllers.stock_controller import StockController
 
-class DocType(StockController):
+class StockReconciliation(StockController):
 	def setup(self):
 		self.head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]
 		self.entries = []
diff --git a/erpnext/stock/doctype/stock_settings/stock_settings.py b/erpnext/stock/doctype/stock_settings/stock_settings.py
index 7f03bb1..cb266ed 100644
--- a/erpnext/stock/doctype/stock_settings/stock_settings.py
+++ b/erpnext/stock/doctype/stock_settings/stock_settings.py
@@ -7,9 +7,9 @@
 import frappe
 from frappe import _
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class StockSettings(Document):
 
 	def validate(self):
 		for key in ["item_naming_by", "item_group", "stock_uom",
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 8ff8938..62c80d2 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
@@ -7,7 +7,9 @@
 from frappe import msgprint, _
 
 
-class DocType:
+from frappe.model.document import Document
+
+class StockUomReplaceUtility(Document):
 	def __init__(self, d, dl=[]):
 		self.doc, self.doclist = d,dl
 
diff --git a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py
index 26c87f1..00cd847 100644
--- a/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py
+++ b/erpnext/stock/doctype/uom_conversion_detail/uom_conversion_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class UomConversionDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 8ec6235..d098cfe 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -6,10 +6,9 @@
 from frappe.utils import cint, validate_email_add
 from frappe import throw, msgprint, _
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class Warehouse(Document):
 	
 	def autoname(self):
 		suffix = " - " + frappe.db.get_value("Company", self.doc.company, "abbr")
diff --git a/erpnext/stock/doctype/warehouse_user/warehouse_user.py b/erpnext/stock/doctype/warehouse_user/warehouse_user.py
index 968a25b..59bfefe 100644
--- a/erpnext/stock/doctype/warehouse_user/warehouse_user.py
+++ b/erpnext/stock/doctype/warehouse_user/warehouse_user.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class WarehouseUser(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py
index 39d494c..8bfc083 100644
--- a/erpnext/stock/get_item_details.py
+++ b/erpnext/stock/get_item_details.py
@@ -138,7 +138,7 @@
 			if args.transaction_type == "selling" else item.buying_cost_center,
 		"batch_no": None,
 		"item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in 
-			item_bean.doclist.get({"parentfield": "item_tax"})))),
+			item_bean.get("item_tax")))),
 		"uom": item.stock_uom,
 		"min_order_qty": flt(item.min_order_qty) if args.doctype == "Material Request" else "",
 		"conversion_factor": 1.0,
diff --git a/erpnext/stock/utils.py b/erpnext/stock/utils.py
index 3a0766a..e5099c4 100644
--- a/erpnext/stock/utils.py
+++ b/erpnext/stock/utils.py
@@ -299,7 +299,7 @@
 	for mr in mr_list:
 		msg += "<p><b><u>" + mr.doc.name + """</u></b></p><table class='table table-bordered'><tr>
 			<th>Item Code</th><th>Warehouse</th><th>Qty</th><th>UOM</th></tr>"""
-		for item in mr.doclist.get({"parentfield": "indent_details"}):
+		for item in mr.get("indent_details"):
 			msg += "<tr><td>" + item.item_code + "</td><td>" + item.warehouse + "</td><td>" + \
 				cstr(item.qty) + "</td><td>" + cstr(item.uom) + "</td></tr>"
 		msg += "</table>"
diff --git a/erpnext/support/doctype/customer_issue/customer_issue.py b/erpnext/support/doctype/customer_issue/customer_issue.py
index 128accd..406ea61 100644
--- a/erpnext/support/doctype/customer_issue/customer_issue.py
+++ b/erpnext/support/doctype/customer_issue/customer_issue.py
@@ -11,10 +11,7 @@
 
 from erpnext.utilities.transaction_base import TransactionBase
 
-class DocType(TransactionBase):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class CustomerIssue(TransactionBase):
 	
 	def validate(self):
 		if session['user'] != 'Guest' and not self.doc.customer:
diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py
index 2fcd200..9f7aef1 100644
--- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py
+++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.py
@@ -5,16 +5,12 @@
 import frappe
 
 from frappe.utils import add_days, cstr, getdate, cint
-from frappe.model.doc import addchild
 from frappe.model.bean import getlist
 from frappe import throw, _
 from erpnext.utilities.transaction_base import TransactionBase, delete_events
 from erpnext.stock.utils import get_valid_serial_nos
 
-class DocType(TransactionBase):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class MaintenanceSchedule(TransactionBase):
 	
 	def get_item_details(self, item_code):
 		item = frappe.db.sql("""select item_name, description from `tabItem` 
@@ -26,17 +22,16 @@
 		return ret
 		
 	def generate_schedule(self):
-		self.doclist = self.doc.clear_table(self.doclist, 'maintenance_schedule_detail')
+		self.set('maintenance_schedule_detail', [])
 		frappe.db.sql("""delete from `tabMaintenance Schedule Detail` 
 			where parent=%s""", (self.doc.name))
 		count = 1
-		for d in getlist(self.doclist, 'item_maintenance_detail'):
+		for d in self.get('item_maintenance_detail'):
 			self.validate_maintenance_detail()
 			s_list = []
 			s_list = self.create_schedule_list(d.start_date, d.end_date, d.no_of_visits, d.sales_person)
 			for i in range(d.no_of_visits):
-				child = addchild(self.doc, 'maintenance_schedule_detail',
-					'Maintenance Schedule Detail', self.doclist)
+				child = self.append('maintenance_schedule_detail')
 				child.item_code = d.item_code
 				child.item_name = d.item_name
 				child.scheduled_date = s_list[i].strftime('%Y-%m-%d')
@@ -50,13 +45,13 @@
 		self.on_update()
 
 	def on_submit(self):
-		if not getlist(self.doclist, 'maintenance_schedule_detail'):
+		if not self.get('maintenance_schedule_detail'):
 			throw("Please click on 'Generate Schedule' to get schedule")
 		self.check_serial_no_added()
 		self.validate_schedule()
 
 		email_map = {}
-		for d in getlist(self.doclist, 'item_maintenance_detail'):
+		for d in self.get('item_maintenance_detail'):
 			if d.serial_no:
 				serial_nos = get_valid_serial_nos(d.serial_no)
 				self.validate_serial_no(serial_nos, d.start_date)
@@ -174,10 +169,10 @@
 		return ret
 
 	def validate_maintenance_detail(self):
-		if not getlist(self.doclist, 'item_maintenance_detail'):
+		if not self.get('item_maintenance_detail'):
 			throw(_("Please enter Maintaince Details first"))
 		
-		for d in getlist(self.doclist, 'item_maintenance_detail'):
+		for d in self.get('item_maintenance_detail'):
 			if not d.item_code:
 				throw(_("Please select item code"))
 			elif not d.start_date or not d.end_date:
@@ -191,7 +186,7 @@
 				throw(_("Start date should be less than end date for item") + " " + d.item_code)
 	
 	def validate_sales_order(self):
-		for d in getlist(self.doclist, 'item_maintenance_detail'):
+		for d in self.get('item_maintenance_detail'):
 			if d.prevdoc_docname:
 				chk = frappe.db.sql("""select ms.name from `tabMaintenance Schedule` ms, 
 					`tabMaintenance Schedule Item` msi where msi.parent=ms.name and 
@@ -233,11 +228,11 @@
 	def validate_schedule(self):
 		item_lst1 =[]
 		item_lst2 =[]
-		for d in getlist(self.doclist, 'item_maintenance_detail'):
+		for d in self.get('item_maintenance_detail'):
 			if d.item_code not in item_lst1:
 				item_lst1.append(d.item_code)
 		
-		for m in getlist(self.doclist, 'maintenance_schedule_detail'):
+		for m in self.get('maintenance_schedule_detail'):
 			if m.item_code not in item_lst2:
 				item_lst2.append(m.item_code)
 		
@@ -252,17 +247,17 @@
 	
 	def check_serial_no_added(self):
 		serial_present =[]
-		for d in getlist(self.doclist, 'item_maintenance_detail'):
+		for d in self.get('item_maintenance_detail'):
 			if d.serial_no:
 				serial_present.append(d.item_code)
 		
-		for m in getlist(self.doclist, 'maintenance_schedule_detail'):
+		for m in self.get('maintenance_schedule_detail'):
 			if serial_present:
 				if m.item_code in serial_present and not m.serial_no:
 					throw("Please click on 'Generate Schedule' to fetch serial no added for item "+m.item_code)
 
 	def on_cancel(self):
-		for d in getlist(self.doclist, 'item_maintenance_detail'):
+		for d in self.get('item_maintenance_detail'):
 			if d.serial_no:
 				serial_nos = get_valid_serial_nos(d.serial_no)
 				self.update_amc_date(serial_nos)
diff --git a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py
index 26c87f1..8c15d32 100644
--- a/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py
+++ b/erpnext/support/doctype/maintenance_schedule_detail/maintenance_schedule_detail.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class MaintenanceScheduleDetail(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py
index 26c87f1..47000c1 100644
--- a/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py
+++ b/erpnext/support/doctype/maintenance_schedule_item/maintenance_schedule_item.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class MaintenanceScheduleItem(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py
index 1ddf67b..234756b 100644
--- a/erpnext/support/doctype/maintenance_visit/maintenance_visit.py
+++ b/erpnext/support/doctype/maintenance_visit/maintenance_visit.py
@@ -12,29 +12,26 @@
 
 from erpnext.utilities.transaction_base import TransactionBase
 
-class DocType(TransactionBase):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class MaintenanceVisit(TransactionBase):
 	
 	def get_item_details(self, item_code):
 		return frappe.db.get_value("Item", item_code, ["item_name", "description"], as_dict=1)
 			
 	def validate_serial_no(self):
-		for d in getlist(self.doclist, 'maintenance_visit_details'):
+		for d in self.get('maintenance_visit_details'):
 			if d.serial_no and not frappe.db.exists("Serial No", d.serial_no):
 				frappe.throw("Serial No: "+ d.serial_no + " not exists in the system")
 
 	
 	def validate(self):
-		if not getlist(self.doclist, 'maintenance_visit_details'):
+		if not self.get('maintenance_visit_details'):
 			msgprint("Please enter maintenance details")
 			raise Exception
 
 		self.validate_serial_no()
 	
 	def update_customer_issue(self, flag):
-		for d in getlist(self.doclist, 'maintenance_visit_details'):
+		for d in self.get('maintenance_visit_details'):
 			if d.prevdoc_docname and d.prevdoc_doctype == 'Customer Issue' :
 				if flag==1:
 					mntc_date = self.doc.mntc_date
@@ -64,7 +61,7 @@
 	def check_if_last_visit(self):
 		"""check if last maintenance visit against same sales order/ customer issue"""
 		check_for_docname = check_for_doctype = None
-		for d in getlist(self.doclist, 'maintenance_visit_details'):
+		for d in self.get('maintenance_visit_details'):
 			if d.prevdoc_docname:
 				check_for_docname = d.prevdoc_docname
 				check_for_doctype = d.prevdoc_doctype
diff --git a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py
index 26c87f1..ac30b7a 100644
--- a/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py
+++ b/erpnext/support/doctype/maintenance_visit_purpose/maintenance_visit_purpose.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class MaintenanceVisitPurpose(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/support/doctype/newsletter/newsletter.py b/erpnext/support/doctype/newsletter/newsletter.py
index 72d05af..7ede45c 100644
--- a/erpnext/support/doctype/newsletter/newsletter.py
+++ b/erpnext/support/doctype/newsletter/newsletter.py
@@ -7,10 +7,9 @@
 import frappe.utils
 from frappe.utils import cstr
 from frappe import msgprint, throw, _
+from frappe.model.document import Document
 
-class DocType():
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+class Newsletter(Document):
 		
 	def onload(self):
 		if self.doc.email_sent:
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 203bf72..65edf23 100644
--- a/erpnext/support/doctype/support_email_settings/support_email_settings.py
+++ b/erpnext/support/doctype/support_email_settings/support_email_settings.py
@@ -6,9 +6,9 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class SupportEmailSettings(Document):
 		
 	def validate(self):
 		"""
diff --git a/erpnext/support/doctype/support_ticket/support_ticket.py b/erpnext/support/doctype/support_ticket/support_ticket.py
index 57d141e..a01dad3 100644
--- a/erpnext/support/doctype/support_ticket/support_ticket.py
+++ b/erpnext/support/doctype/support_ticket/support_ticket.py
@@ -7,10 +7,7 @@
 from erpnext.utilities.transaction_base import TransactionBase
 from frappe.utils import now, extract_email_id
 
-class DocType(TransactionBase):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class SupportTicket(TransactionBase):
 	
 	def get_sender(self, comm):
 		return frappe.db.get_value('Support Email Settings',None,'support_email')
diff --git a/erpnext/utilities/doctype/address/address.py b/erpnext/utilities/doctype/address/address.py
index b80f13a..b698658 100644
--- a/erpnext/utilities/doctype/address/address.py
+++ b/erpnext/utilities/doctype/address/address.py
@@ -7,10 +7,9 @@
 from frappe import msgprint, throw, _
 from frappe.utils import cstr, cint
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import Document
+
+class Address(Document):
 
 	def autoname(self):
 		if not self.doc.address_title:
diff --git a/erpnext/utilities/doctype/contact/contact.py b/erpnext/utilities/doctype/contact/contact.py
index 948b753..16522a8 100644
--- a/erpnext/utilities/doctype/contact/contact.py
+++ b/erpnext/utilities/doctype/contact/contact.py
@@ -7,10 +7,7 @@
 
 from erpnext.controllers.status_updater import StatusUpdater
 
-class DocType(StatusUpdater):
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+class Contact(StatusUpdater):
 
 	def autoname(self):
 		# concat first and last name
diff --git a/erpnext/utilities/doctype/note/note.py b/erpnext/utilities/doctype/note/note.py
index 99846d9..8936da7 100644
--- a/erpnext/utilities/doctype/note/note.py
+++ b/erpnext/utilities/doctype/note/note.py
@@ -6,9 +6,9 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class Note(Document):
 		
 	def autoname(self):
 		# replace forbidden characters
diff --git a/erpnext/utilities/doctype/note_user/note_user.py b/erpnext/utilities/doctype/note_user/note_user.py
index 968a25b..1594f78 100644
--- a/erpnext/utilities/doctype/note_user/note_user.py
+++ b/erpnext/utilities/doctype/note_user/note_user.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class NoteUser(Document):
+	pass
\ No newline at end of file
diff --git a/erpnext/utilities/doctype/rename_tool/rename_tool.py b/erpnext/utilities/doctype/rename_tool/rename_tool.py
index 835e647..7ee46df 100644
--- a/erpnext/utilities/doctype/rename_tool/rename_tool.py
+++ b/erpnext/utilities/doctype/rename_tool/rename_tool.py
@@ -7,9 +7,9 @@
 import frappe
 from frappe import _
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
+from frappe.model.document import Document
+
+class RenameTool(Document):
 		
 @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 832c443..b160ad9 100644
--- a/erpnext/utilities/doctype/sms_control/sms_control.py
+++ b/erpnext/utilities/doctype/sms_control/sms_control.py
@@ -10,10 +10,9 @@
 from frappe import msgprint, throw, _
 from frappe.model.bean import getlist
 
-class DocType:
-	def __init__(self, doc, doclist=[]):
-		self.doc = doc
-		self.doclist = doclist
+from frappe.model.document import 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 26c87f1..573054e 100644
--- a/erpnext/utilities/doctype/sms_log/sms_log.py
+++ b/erpnext/utilities/doctype/sms_log/sms_log.py
@@ -4,6 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-class DocType:
-	def __init__(self, d, dl):
-		self.doc, self.doclist = d, dl
\ No newline at end of file
+from frappe.model.document import Document
+
+class SmsLog(Document):
+	pass