Merge pull request #1319 from pdvyas/about-version

update about erpnext with version number
diff --git a/accounts/doctype/accounts_settings/accounts_settings.py b/accounts/doctype/accounts_settings/accounts_settings.py
index a6e9938..2475fda 100644
--- a/accounts/doctype/accounts_settings/accounts_settings.py
+++ b/accounts/doctype/accounts_settings/accounts_settings.py
@@ -6,6 +6,7 @@
 from __future__ import unicode_literals
 import webnotes
 from webnotes import _
+from webnotes.utils import cint
 
 class DocType:
 	def __init__(self, d, dl):
@@ -14,7 +15,12 @@
 	def on_update(self):
 		webnotes.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock)
 		
-		if self.doc.auto_accounting_for_stock:
+		if cint(self.doc.auto_accounting_for_stock):
+			# set default perpetual account in company
+			for company in webnotes.conn.sql("select name from tabCompany"):
+				webnotes.bean("Company", company[0]).save()
+			
+			# Create account head for warehouses
 			warehouse_list = webnotes.conn.sql("select name, company from tabWarehouse", as_dict=1)
 			warehouse_with_no_company = [d.name for d in warehouse_list if not d.company]
 			if warehouse_with_no_company:
diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt
index 09a3757..4319c26 100755
--- a/accounts/doctype/pos_setting/pos_setting.txt
+++ b/accounts/doctype/pos_setting/pos_setting.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-24 12:15:51", 
   "docstatus": 0, 
-  "modified": "2013-11-02 16:58:38", 
+  "modified": "2014-01-15 16:23:58", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -154,7 +154,7 @@
   "reqd": 1
  }, 
  {
-  "depends_on": "eval:sys_defaults.auto_accounting_for_stock", 
+  "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
   "doctype": "DocField", 
   "fieldname": "expense_account", 
   "fieldtype": "Link", 
diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py
index 06b7a3a..fcd6846 100644
--- a/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -302,6 +302,7 @@
 		self.make_gl_entries()
 		self.update_against_document_in_jv()
 		self.update_prevdoc_status()
+		self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
 
 	def make_gl_entries(self):
 		auto_accounting_for_stock = \
@@ -421,7 +422,7 @@
 		remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_voucher")
 		
 		self.update_prevdoc_status()
-		
+		self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
 		self.make_cancel_gl_entries()
 		
 	def on_update(self):
diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py
index bfba30f..a39702b 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/accounts/doctype/sales_invoice/sales_invoice.py
@@ -88,6 +88,7 @@
 		
 		self.update_status_updater_args()
 		self.update_prevdoc_status()
+		self.update_billing_status_for_zero_amount_refdoc("Sales Order")
 		
 		# this sequence because outstanding may get -ve
 		self.make_gl_entries()
@@ -114,6 +115,7 @@
 
 		self.update_status_updater_args()
 		self.update_prevdoc_status()
+		self.update_billing_status_for_zero_amount_refdoc("Sales Order")
 		
 		self.make_cancel_gl_entries()
 		
diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt
index 99bfe5c..0433f31 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.txt
+++ b/accounts/doctype/sales_invoice/sales_invoice.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-24 19:29:05", 
   "docstatus": 0, 
-  "modified": "2013-11-18 15:16:50", 
+  "modified": "2014-01-16 15:36:16", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -1091,7 +1091,7 @@
   "fieldtype": "Select", 
   "label": "Recurring Type", 
   "no_copy": 1, 
-  "options": "Monthly\nQuarterly\nHalf-yearly\nYearly", 
+  "options": "\nMonthly\nQuarterly\nHalf-yearly\nYearly", 
   "print_hide": 1, 
   "read_only": 0
  }, 
diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js
index 14b8279..e3957ab 100644
--- a/buying/doctype/purchase_common/purchase_common.js
+++ b/buying/doctype/purchase_common/purchase_common.js
@@ -302,11 +302,11 @@
 	
 	calculate_totals: function() {
 		var tax_count = this.frm.tax_doclist.length;
-		this.frm.doc.grand_total = flt(
-			tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
+		this.frm.doc.grand_total = flt(tax_count ? 
+			this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total,
 			precision("grand_total"));
-		this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate,
-			precision("grand_total_import"));
+		this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total / 
+			this.frm.doc.conversion_rate, precision("grand_total_import"));
 			
 		this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
 			precision("total_tax"));
@@ -321,20 +321,26 @@
 		}
 		
 		// other charges added/deducted
+		this.frm.doc.other_charges_added = 0.0
+		this.frm.doc.other_charges_deducted = 0.0
 		if(tax_count) {
 			this.frm.doc.other_charges_added = wn.utils.sum($.map(this.frm.tax_doclist, 
-				function(tax) { return (tax.add_deduct_tax == "Add" && in_list(["Valuation and Total", "Total"], tax.category)) ? tax.tax_amount : 0.0; }));
+				function(tax) { return (tax.add_deduct_tax == "Add" 
+					&& in_list(["Valuation and Total", "Total"], tax.category)) ? 
+					tax.tax_amount : 0.0; }));
 		
 			this.frm.doc.other_charges_deducted = wn.utils.sum($.map(this.frm.tax_doclist, 
-				function(tax) { return (tax.add_deduct_tax == "Deduct" && in_list(["Valuation and Total", "Total"], tax.category)) ? tax.tax_amount : 0.0; }));
+				function(tax) { return (tax.add_deduct_tax == "Deduct" 
+					&& in_list(["Valuation and Total", "Total"], tax.category)) ? 
+					tax.tax_amount : 0.0; }));
 			
-			wn.model.round_floats_in(this.frm.doc, ["other_charges_added", "other_charges_deducted"]);
-			
-			this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added / this.frm.doc.conversion_rate,
-				precision("other_charges_added_import"));
-			this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted / this.frm.doc.conversion_rate,
-				precision("other_charges_deducted_import"));
+			wn.model.round_floats_in(this.frm.doc,
+				["other_charges_added", "other_charges_deducted"]);
 		}
+		this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added /
+			this.frm.doc.conversion_rate, precision("other_charges_added_import"));
+		this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted / 
+			this.frm.doc.conversion_rate, precision("other_charges_deducted_import"));
 	},
 	
 	_cleanup: function() {
diff --git a/config.json b/config.json
index 45acaf2..c252467 100644
--- a/config.json
+++ b/config.json
@@ -1,6 +1,6 @@
 {
  "app_name": "ERPNext", 
- "app_version": "3.6.1", 
+ "app_version": "3.6.2", 
  "base_template": "app/portal/templates/base.html", 
  "modules": {
   "Accounts": {
@@ -74,5 +74,5 @@
    "type": "module"
   }
  }, 
- "requires_framework_version": "==3.7.1"
+ "requires_framework_version": "==3.7.2"
 }
\ No newline at end of file
diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py
index 7954ca0..bdc7327 100644
--- a/controllers/buying_controller.py
+++ b/controllers/buying_controller.py
@@ -124,8 +124,8 @@
 		self.round_floats_in(self.doc, ["net_total", "net_total_import"])
 		
 	def calculate_totals(self):
-		self.doc.grand_total = flt(self.tax_doclist and \
-			self.tax_doclist[-1].total or self.doc.net_total, self.precision("grand_total"))
+		self.doc.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist 
+			else self.doc.net_total, self.precision("grand_total"))
 		self.doc.grand_total_import = flt(self.doc.grand_total / self.doc.conversion_rate,
 			self.precision("grand_total_import"))
 
@@ -137,6 +137,24 @@
 		
 		if self.meta.get_field("rounded_total_import"):
 			self.doc.rounded_total_import = _round(self.doc.grand_total_import)
+				
+		if self.meta.get_field("other_charges_added"):
+			self.doc.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist 
+				if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]), 
+				self.precision("other_charges_added"))
+				
+		if self.meta.get_field("other_charges_deducted"):
+			self.doc.other_charges_deducted = flt(sum([flt(d.tax_amount) for d in self.tax_doclist 
+				if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]), 
+				self.precision("other_charges_deducted"))
+				
+		if self.meta.get_field("other_charges_added_import"):
+			self.doc.other_charges_added_import = flt(self.doc.other_charges_added / 
+				self.doc.conversion_rate, self.precision("other_charges_added_import"))
+				
+		if self.meta.get_field("other_charges_deducted_import"):
+			self.doc.other_charges_deducted_import = flt(self.doc.other_charges_deducted / 
+				self.doc.conversion_rate, self.precision("other_charges_deducted_import"))
 			
 	def calculate_outstanding_amount(self):
 		if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus < 2:
diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py
index 67c1462..4806c73 100644
--- a/controllers/selling_controller.py
+++ b/controllers/selling_controller.py
@@ -191,7 +191,8 @@
 			
 		self.doc.other_charges_total = flt(self.doc.grand_total - self.doc.net_total,
 			self.precision("other_charges_total"))
-		self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export,
+		self.doc.other_charges_total_export = flt(
+			self.doc.grand_total_export - self.doc.net_total_export,
 			self.precision("other_charges_total_export"))
 		
 		self.doc.rounded_total = _round(self.doc.grand_total)
diff --git a/controllers/status_updater.py b/controllers/status_updater.py
index a285c47..1743887 100644
--- a/controllers/status_updater.py
+++ b/controllers/status_updater.py
@@ -232,6 +232,43 @@
 								'Fully %(keyword)s', 'Partly %(keyword)s'))
 							where name='%(name)s'""" % args)
 							
+							
+	def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
+		ref_fieldname = ref_dt.lower().replace(" ", "_")
+		zero_amount_refdoc = []
+		all_zero_amount_refdoc = webnotes.conn.sql_list("""select name from `tab%s` 
+			where docstatus=1 and net_total = 0""" % ref_dt)
+	
+		for item in self.doclist.get({"parentfield": "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:
+					zero_amount_refdoc.append(item.fields[ref_fieldname])
+		
+		if zero_amount_refdoc:
+			self.update_biling_status(zero_amount_refdoc, ref_dt, ref_fieldname)
+	
+	def update_biling_status(self, zero_amount_refdoc, ref_dt, ref_fieldname):
+		for ref_dn in zero_amount_refdoc:
+			ref_doc_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0)) from `tab%s Item` 
+				where parent=%s""" % (ref_dt, '%s'), (ref_dn))[0][0])
+			
+			billed_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0)) 
+				from `tab%s Item` where %s=%s and docstatus=1""" % 
+				(self.doc.doctype, ref_fieldname, '%s'), (ref_dn))[0][0])
+			
+			per_billed = ((ref_doc_qty if billed_qty > ref_doc_qty else billed_qty)\
+				/ ref_doc_qty)*100
+			webnotes.conn.set_value(ref_dt, ref_dn, "per_billed", per_billed)
+			
+			from webnotes.model.meta import has_field
+			if has_field(ref_dt, "billing_status"):
+				if per_billed < 0.001: billing_status = "Not Billed"
+				elif per_billed >= 99.99: billing_status = "Fully Billed"
+				else: billing_status = "Partly Billed"
+			
+				webnotes.conn.set_value(ref_dt, ref_dn, "billing_status", billing_status)
+							
 def get_tolerance_for(item_code, item_tolerance={}, global_tolerance=None):
 	"""
 		Returns the tolerance for the item, if not set, returns global tolerance
diff --git a/hr/doctype/salary_manager/salary_manager.js b/hr/doctype/salary_manager/salary_manager.js
index 032c29e..ec485ca 100644
--- a/hr/doctype/salary_manager/salary_manager.js
+++ b/hr/doctype/salary_manager/salary_manager.js
@@ -43,7 +43,7 @@
 		jv = locals['Journal Voucher'][jv];
 		jv.voucher_type = 'Bank Voucher';
 		jv.user_remark = wn._('Payment of salary for the month: ') + doc.month + 
-			wn._('and fiscal year: ') + doc.fiscal_year;
+			wn._(' and fiscal year: ') + doc.fiscal_year;
 		jv.fiscal_year = doc.fiscal_year;
 		jv.company = doc.company;
 		jv.posting_date = dateutil.obj_to_str(new Date());
diff --git a/hr/report/monthly_salary_register/monthly_salary_register.py b/hr/report/monthly_salary_register/monthly_salary_register.py
index 9b8a84f..42c62e4 100644
--- a/hr/report/monthly_salary_register/monthly_salary_register.py
+++ b/hr/report/monthly_salary_register/monthly_salary_register.py
@@ -50,9 +50,9 @@
 		where ifnull(d_modified_amount, 0) != 0 and parent in (%s)""" % 
 		(', '.join(['%s']*len(salary_slips))), tuple([d.name for d in salary_slips]))
 		
-	columns = columns + [(e + ":Link/Earning Type:120") for e in earning_types] + \
+	columns = columns + [(e + ":Currency:120") for e in earning_types] + \
 		["Arrear Amount:Currency:120", "Leave Encashment Amount:Currency:150", 
-		"Gross Pay:Currency:120"] + [(d + ":Link/Deduction Type:120") for d in ded_types] + \
+		"Gross Pay:Currency:120"] + [(d + ":Currency:120") for d in ded_types] + \
 		["Total Deduction:Currency:120", "Net Pay:Currency:120"]
 
 	return columns, earning_types, ded_types
@@ -102,6 +102,6 @@
 	ss_ded_map = {}
 	for d in ss_deductions:
 		ss_ded_map.setdefault(d.parent, webnotes._dict()).setdefault(d.d_type, [])
-		ss_ded_map[d.parent][d.e_type] = flt(d.d_modified_amount)
+		ss_ded_map[d.parent][d.d_type] = flt(d.d_modified_amount)
 	
 	return ss_ded_map
\ No newline at end of file
diff --git a/patches/1401/update_billing_status_for_zero_value_order.py b/patches/1401/update_billing_status_for_zero_value_order.py
new file mode 100644
index 0000000..afeed55
--- /dev/null
+++ b/patches/1401/update_billing_status_for_zero_value_order.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import webnotes
+from webnotes.utils import flt
+
+def execute():
+	for order_type in ["Sales", "Purchase"]:
+		for d in webnotes.conn.sql("""select par.name, sum(ifnull(child.qty, 0)) as total_qty 
+			from `tab%s Order` par, `tab%s Order Item` child  
+			where par.name = child.parent and par.docstatus = 1 
+			and ifnull(par.net_total, 0) = 0 group by par.name""" % 
+			(order_type, order_type), as_dict=1):
+				
+				billed_qty = flt(webnotes.conn.sql("""select sum(ifnull(qty, 0)) 
+					from `tab%s Invoice Item` where %s=%s and docstatus=1""" % 
+					(order_type, "sales_order" if order_type=="Sales" else "purchase_order", '%s'), 
+					(d.name))[0][0])
+				
+				per_billed = ((d.total_qty if billed_qty > d.total_qty else billed_qty)\
+					/ d.total_qty)*100
+				webnotes.conn.set_value(order_type+ " Order", d.name, "per_billed", per_billed)
+				
+				if order_type == "Sales":
+					if per_billed < 0.001: billing_status = "Not Billed"
+					elif per_billed >= 99.99: billing_status = "Fully Billed"
+					else: billing_status = "Partly Billed"
+	
+					webnotes.conn.set_value("Sales Order", d.name, "billing_status", billing_status)
\ No newline at end of file
diff --git a/patches/patch_list.py b/patches/patch_list.py
index 04a9288..2598ae8 100644
--- a/patches/patch_list.py
+++ b/patches/patch_list.py
@@ -265,4 +265,5 @@
 	"patches.1312.p02_update_item_details_in_item_price",
 	"patches.1401.p01_move_related_property_setters_to_custom_field",
 	"patches.1401.p01_make_buying_selling_as_check_box_in_price_list",
+	"patches.1401.update_billing_status_for_zero_value_order",
 ]
\ No newline at end of file
diff --git a/selling/doctype/campaign/campaign.js b/selling/doctype/campaign/campaign.js
index 6271a16..3347957 100644
--- a/selling/doctype/campaign/campaign.js
+++ b/selling/doctype/campaign/campaign.js
@@ -1,13 +1,2 @@
 // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-// License: GNU General Public License v3. See license.txt
-
- 
-
-//--------- ONLOAD -------------
-cur_frm.cscript.onload = function(doc, cdt, cdn) {
-   
-}
-
-cur_frm.cscript.refresh = function(doc, cdt, cdn) {
-   
-}
\ No newline at end of file
+// License: GNU General Public License v3. See license.txt
\ No newline at end of file
diff --git a/selling/doctype/campaign/campaign.txt b/selling/doctype/campaign/campaign.txt
index 7025bf5..7170e05 100644
--- a/selling/doctype/campaign/campaign.txt
+++ b/selling/doctype/campaign/campaign.txt
@@ -2,11 +2,12 @@
  {
   "creation": "2013-01-10 16:34:18", 
   "docstatus": 0, 
-  "modified": "2013-07-05 14:29:57", 
+  "modified": "2014-01-16 12:52:19", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
  {
+  "allow_rename": 1, 
   "autoname": "field:campaign_name", 
   "description": "Keep Track of Sales Campaigns. Keep track of Leads, Quotations, Sales Order etc from Campaigns to gauge Return on Investment. ", 
   "doctype": "DocType", 
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
index 88d9dca..34e5ca4 100644
--- a/setup/doctype/company/company.py
+++ b/setup/doctype/company/company.py
@@ -244,8 +244,6 @@
 					webnotes.conn.set(self.doc, a, account_name)
 			
 		_set_default_accounts({
-			"default_income_account": "Sales",
-			"default_expense_account": "Cost of Goods Sold",
 			"receivables_group": "Accounts Receivable",
 			"payables_group": "Accounts Payable",
 			"default_cash_account": "Cash"
@@ -257,8 +255,6 @@
 				"stock_adjustment_account": "Stock Adjustment",
 				"expenses_included_in_valuation": "Expenses Included In Valuation"
 			})
-		
-		
 
 	def create_default_cost_center(self):
 		cc_list = [
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
index c9aa75e..e18a0f2 100644
--- a/stock/doctype/item/item.js
+++ b/stock/doctype/item/item.js
@@ -29,10 +29,7 @@
 
 cur_frm.cscript.edit_prices_button = function() {
 	cur_frm.add_custom_button("Add / Edit Prices", function() {
-		wn.route_options = {
-			"item_code": cur_frm.doc.name
-		};
-		wn.set_route("Report", "Item Price");
+		wn.set_route("Report", "Item Price", {"item_code": cur_frm.doc.name});
 	}, "icon-money");
 }
 
diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
index 1d93979..9bc66a4 100755
--- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
+++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-24 19:29:10", 
   "docstatus": 0, 
-  "modified": "2014-01-03 18:28:20", 
+  "modified": "2014-01-15 16:00:44", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -336,7 +336,7 @@
  }, 
  {
   "default": ":Company", 
-  "depends_on": "eval:sys_defaults.auto_accounting_for_stock", 
+  "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
   "doctype": "DocField", 
   "fieldname": "cost_center", 
   "fieldtype": "Link", 
diff --git a/stock/doctype/stock_entry_detail/stock_entry_detail.txt b/stock/doctype/stock_entry_detail/stock_entry_detail.txt
index b97928b..25835e0bf 100644
--- a/stock/doctype/stock_entry_detail/stock_entry_detail.txt
+++ b/stock/doctype/stock_entry_detail/stock_entry_detail.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-29 18:22:12", 
   "docstatus": 0, 
-  "modified": "2013-11-08 16:15:44", 
+  "modified": "2014-01-15 16:08:45", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -165,7 +165,7 @@
   "read_only": 1
  }, 
  {
-  "depends_on": "eval:sys_defaults.auto_accounting_for_stock", 
+  "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
   "doctype": "DocField", 
   "fieldname": "expense_account", 
   "fieldtype": "Link", 
@@ -175,7 +175,7 @@
  }, 
  {
   "default": ":Company", 
-  "depends_on": "eval:sys_defaults.auto_accounting_for_stock", 
+  "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
   "doctype": "DocField", 
   "fieldname": "cost_center", 
   "fieldtype": "Link", 
diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.txt b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
index c9959d3..7d5021c 100644
--- a/stock/doctype/stock_reconciliation/stock_reconciliation.txt
+++ b/stock/doctype/stock_reconciliation/stock_reconciliation.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-28 10:35:31", 
   "docstatus": 0, 
-  "modified": "2013-09-24 15:35:12", 
+  "modified": "2014-01-15 15:45:07", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -102,7 +102,7 @@
   "reqd": 1
  }, 
  {
-  "depends_on": "eval:sys_defaults.auto_accounting_for_stock", 
+  "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
   "doctype": "DocField", 
   "fieldname": "expense_account", 
   "fieldtype": "Link", 
@@ -110,6 +110,7 @@
   "options": "Account"
  }, 
  {
+  "depends_on": "eval:cint(sys_defaults.auto_accounting_for_stock)", 
   "doctype": "DocField", 
   "fieldname": "cost_center", 
   "fieldtype": "Link", 
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index 5c28d8d..6c515a5 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -78,10 +78,12 @@
 			3. Clears existing Sales Team and fetches the one mentioned in Customer
 		"""
 		customer_defaults = self.get_customer_defaults()
-					
-		customer_defaults["selling_price_list"] = customer_defaults.get("price_list") or \
-			webnotes.conn.get_value("Customer Group", self.doc.customer_group, "default_price_list") or \
-			self.doc.selling_price_list
+
+		customer_defaults["selling_price_list"] = \
+			self.get_user_default_price_list("selling_price_list") or \
+			customer_defaults.get("price_list") or \
+			webnotes.conn.get_value("Customer Group", self.doc.customer_group, 
+				"default_price_list") or self.doc.selling_price_list
 			
 		for fieldname, val in customer_defaults.items():
 			if self.meta.get_field(fieldname):
@@ -90,6 +92,12 @@
 		if self.meta.get_field("sales_team") and self.doc.customer:
 			self.set_sales_team_for_customer()
 			
+	def get_user_default_price_list(self, price_list):
+		from webnotes.defaults import get_defaults_for
+		user_default_price_list = get_defaults_for(webnotes.session.user).get(price_list)
+		return cstr(user_default_price_list) \
+			if not isinstance(user_default_price_list, list) else ""
+			
 	def set_sales_team_for_customer(self):
 		from webnotes.model import default_fields
 		
@@ -120,8 +128,9 @@
 		out["supplier_name"] = supplier.supplier_name
 		if supplier.default_currency:
 			out["currency"] = supplier.default_currency
-		if supplier.default_price_list:
-			out["buying_price_list"] = supplier.default_price_list
+			
+		out["buying_price_list"] = self.get_user_default_price_list("buying_price_list") or \
+			supplier.default_price_list or self.doc.buying_price_list
 		
 		return out