frappe/frappe#478, more changes, removed bean
diff --git a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html
index d4a49ef..8dc39f9 100644
--- a/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html
+++ b/erpnext/accounts/Print Format/SalesInvoice/SalesInvoice.html
@@ -65,7 +65,7 @@
 				<th>Basic Rate</th>
 				<th>Amount</th>
 			</tr>
-			{%- for row in doclist.get({"doctype":"Sales Invoice Item"}) %}
+			{%- for row in doc.get({"doctype":"Sales Invoice Item"}) %}
 			<tr>
 				<td style="width: 3%;">{{ row.idx }}</td>
 				<td style="width: 20%;">{{ row.item_name }}</td>
@@ -106,7 +106,7 @@
 								utils.fmt_money(doc.net_total_export, currency=doc.currency)
 							}}</td>
 						</tr>
-						{%- for charge in doclist.get({"doctype":"Sales Taxes and Charges"}) -%}
+						{%- for charge in doc.get({"doctype":"Sales Taxes and Charges"}) -%}
 						{%- if not charge.included_in_print_rate -%}
 						<tr>
 							<td>{{ charge.description }}</td>
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 094edd0..59637a5 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -40,13 +40,13 @@
 				["name", "group_or_ledger", "report_type"], as_dict=1)
 			if not par:
 				throw(_("Parent account does not exists"))
-			elif par[0]["name"] == self.name:
+			elif par["name"] == self.name:
 				throw(_("You can not assign itself as parent account"))
-			elif par[0]["group_or_ledger"] != 'Group':
+			elif par["group_or_ledger"] != 'Group':
 				throw(_("Parent account can not be a ledger"))
 				
-			if par[0]["report_type"]:
-				self.report_type = par[0]["report_type"]
+			if par["report_type"]:
+				self.report_type = par["report_type"]
 	
 	def validate_duplicate_account(self):
 		if self.get('__islocal') or not self.name:
diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
index bc950d5..b7288e0 100644
--- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
+++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.py
@@ -25,5 +25,5 @@
 				frappe.throw(_("Company is missing in following warehouses") + ": \n" + 
 					"\n".join(warehouse_with_no_company))
 			for wh in warehouse_list:
-				wh_bean = frappe.get_doc("Warehouse", wh.name)
-				wh_bean.save()
\ No newline at end of file
+				wh_doc = frappe.get_doc("Warehouse", wh.name)
+				wh_doc.save()
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/budget_distribution/test_records.json b/erpnext/accounts/doctype/budget_distribution/test_records.json
index 0637a08..7e8c640 100644
--- a/erpnext/accounts/doctype/budget_distribution/test_records.json
+++ b/erpnext/accounts/doctype/budget_distribution/test_records.json
@@ -1 +1,44 @@
-[]
\ No newline at end of file
+[{
+	"doctype": "Budget Distribution",
+	"distribution_id": "_Test Distribution",
+	"fiscal_year": "_Test Fiscal Year 2013",
+	"budget_distribution_details": [
+		{
+			"month": "January",
+			"percentage_allocation": "8"
+		}, {
+			"month": "February",
+			"percentage_allocation": "8"
+		}, {
+			"month": "March",
+			"percentage_allocation": "8"
+		}, {
+			"month": "April",
+			"percentage_allocation": "8"
+		}, {
+			"month": "May",
+			"percentage_allocation": "8"
+		}, {
+			"month": "June",
+			"percentage_allocation": "8"
+		}, {
+			"month": "July",
+			"percentage_allocation": "8"
+		}, {
+			"month": "August",
+			"percentage_allocation": "8"
+		}, {
+			"month": "September",
+			"percentage_allocation": "8"
+		}, {
+			"month": "October",
+			"percentage_allocation": "8"
+		}, {
+			"month": "November",
+			"percentage_allocation": "10"
+		}, {
+			"month": "December",
+			"percentage_allocation": "10"
+		}		
+	]
+}]
diff --git a/erpnext/accounts/doctype/chart_of_accounts/import_charts.py b/erpnext/accounts/doctype/chart_of_accounts/import_charts.py
index fd36bf8..9e60551 100644
--- a/erpnext/accounts/doctype/chart_of_accounts/import_charts.py
+++ b/erpnext/accounts/doctype/chart_of_accounts/import_charts.py
@@ -13,13 +13,13 @@
 				chart = json.loads(f.read())
 				country = frappe.db.get_value("Country", {"code": fname.split("_", 1)[0]})
 				if country:
-					bean = frappe.get_doc({
+					doc = frappe.get_doc({
 						"doctype":"Chart of Accounts",
 						"chart_name": chart.get("name"),
 						"source_file": fname,
 						"country": country
 					}).insert()
-					print bean.name.encode("utf-8")
+					print doc.name.encode("utf-8")
 				else:
 					print "No chart for: " + chart.get("name").encode("utf-8")
 				
diff --git a/erpnext/accounts/doctype/cost_center/cost_center.py b/erpnext/accounts/doctype/cost_center/cost_center.py
index ac69e75..7013ffb 100644
--- a/erpnext/accounts/doctype/cost_center/cost_center.py
+++ b/erpnext/accounts/doctype/cost_center/cost_center.py
@@ -13,7 +13,7 @@
 	
 	def autoname(self):
 		self.name = self.cost_center_name.strip() + ' - ' + \
-			frappe.get_value("Company", self.company, "abbr")
+			frappe.db.get_value("Company", self.company, "abbr")
 		
 	def validate_mandatory(self):
 		if not self.group_or_ledger:
diff --git a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py
index d0e6c6c..edceddb 100644
--- a/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py
+++ b/erpnext/accounts/doctype/fiscal_year/test_fiscal_year.py
@@ -3,4 +3,6 @@
 
 from __future__ import unicode_literals
 
+import frappe
+
 test_records = frappe.get_test_records('Fiscal Year')
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
index 3af9a03..9829a17 100644
--- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
+++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.py
@@ -349,8 +349,8 @@
 def get_payment_entry_from_sales_invoice(sales_invoice):
 	from erpnext.accounts.utils import get_balance_on
 	si = frappe.get_doc("Sales Invoice", sales_invoice)
-	jv = get_payment_entry(si.doc)
-	jv.remark = 'Payment received against Sales Invoice %(name)s. %(remarks)s' % si.fields
+	jv = get_payment_entry(si)
+	jv.remark = 'Payment received against Sales Invoice {0}. {1}'.format(si.name, si.remarks)
 
 	# credit customer
 	jv.doclist[1].account = si.debit_to
@@ -367,8 +367,8 @@
 def get_payment_entry_from_purchase_invoice(purchase_invoice):
 	from erpnext.accounts.utils import get_balance_on
 	pi = frappe.get_doc("Purchase Invoice", purchase_invoice)
-	jv = get_payment_entry(pi.doc)
-	jv.remark = 'Payment against Purchase Invoice %(name)s. %(remarks)s' % pi.fields
+	jv = get_payment_entry(pi)
+	jv.remark = 'Payment against Purchase Invoice {0}. {1}'.format(pi.name, pi.remarks)
 	
 	# credit supplier
 	jv.doclist[1].account = pi.credit_to
@@ -384,7 +384,7 @@
 def get_payment_entry(doc):
 	bank_account = get_default_bank_cash_account(doc.company, "Bank Voucher")
 	
-	jv = frappe.new_bean('Journal Voucher')
+	jv = frappe.new_doc('Journal Voucher')
 	jv.voucher_type = 'Bank Voucher'
 
 	jv.company = doc.company
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 910e380..25dbf95 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
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class PurchaseTaxesAndCharges(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 fb9a0ab..e93c572 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
@@ -5,5 +5,5 @@
 import frappe
 from frappe.model.document import Document
 
-class PurchaseTaxesAndChargesMaster(Document):
+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 e9e9869..ba34b49 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -192,7 +192,7 @@
 			for item in self.get("entries"):
 				if item.get('item_code'):
 					for fname, val in get_pos_settings_item_details(pos, 
-						frappe._dict(item.fields), pos).items():
+						frappe._dict(item.as_dict()), pos).items():
 						
 						if (not for_validate) or (for_validate and not item.get(fname)):
 							item.set(fname, val)
@@ -696,7 +696,7 @@
 		raise Exception, exception_message
 
 def make_new_invoice(ref_wrapper, posting_date):
-	from frappe.model.bean import clone
+	from frappe.model.doc import clone
 	from erpnext.accounts.utils import get_fiscal_year
 	new_invoice = clone(ref_wrapper)
 	
@@ -736,7 +736,7 @@
 	from frappe.core.doctype.print_format.print_format import get_html
 	frappe.sendmail(new_rv.notification_email_address, 
 		subject="New Invoice : " + new_rv.name, 
-		message = get_html(new_rv.doc, new_rv, "SalesInvoice"))
+		message = get_html(new_rv, new_rv, "SalesInvoice"))
 		
 def notify_errors(inv, customer, owner):
 	from frappe.utils.user import get_system_managers
@@ -797,8 +797,8 @@
 	from frappe.model.mapper import get_mapped_doc
 	
 	def set_missing_values(source, target):
-		bean = frappe.get_doc(target)
-		bean.run_method("onload_post_render")
+		doc = frappe.get_doc(target)
+		doc.run_method("onload_post_render")
 		
 	def update_item(source_doc, target_doc, source_parent):
 		target_doc.base_amount = (flt(source_doc.qty) - flt(source_doc.delivered_qty)) * \
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index 7879dcb..109d0e5 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -4,7 +4,7 @@
 import frappe
 import unittest, json
 from frappe.utils import flt
-from frappe.model.bean import DocstatusTransitionError, TimestampMismatchError
+from frappe.model.doc import DocstatusTransitionError, TimestampMismatchError
 from erpnext.accounts.utils import get_stock_and_account_difference
 from erpnext.stock.doctype.purchase_receipt.test_purchase_receipt import set_perpetual_inventory
 
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 8f621de..f4a9448 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
@@ -6,5 +6,5 @@
 
 from frappe.model.document import Document
 
-class SalesTaxesAndCharges(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 76417e3..f63a767 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 SalesTaxesAndChargesMaster(DocListController):		
+class SalesTaxesandChargesMaster(DocListController):		
 	def validate(self):
 		if self.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 d27565e..9e88f22 100644
--- a/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
+++ b/erpnext/accounts/doctype/shipping_rule/shipping_rule.py
@@ -66,7 +66,7 @@
 		for i in xrange(0, len(self.shipping_rule_conditions)):
 			for j in xrange(i+1, len(self.shipping_rule_conditions)):
 				d1, d2 = self.shipping_rule_conditions[i], self.shipping_rule_conditions[j]
-				if d1.fields != d2.fields:
+				if d1.as_dict() != d2.as_dict():
 					# in our case, to_value can be zero, hence pass the from_value if so
 					range_a = (d1.from_value, d1.to_value or d1.from_value)
 					range_b = (d2.from_value, d2.to_value or d2.from_value)
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index e86d6a9..a159a73 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -25,8 +25,8 @@
 	if not ignore_permissions and not frappe.has_permission(party_type, "read", party):
 		frappe.throw("Not Permitted", frappe.PermissionError)
 
-	party_bean = frappe.get_doc(party_type, party)
-	party = party_bean.doc
+	party_doc = frappe.get_doc(party_type, party)
+	party = party_doc
 
 	set_address_details(out, party, party_type)
 	set_contact_details(out, party, party_type)
@@ -41,7 +41,7 @@
 		out["sales_team"] = [{
 			"sales_person": d.sales_person, 
 			"sales_designation": d.sales_designation
-		} for d in party_bean.get("sales_team")]
+		} for d in party_doc.get("sales_team")]
 	
 	return out