Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/accounts/doctype/fiscal_year/fiscal_year.py b/accounts/doctype/fiscal_year/fiscal_year.py
index 6b2dfde..48d7d91 100644
--- a/accounts/doctype/fiscal_year/fiscal_year.py
+++ b/accounts/doctype/fiscal_year/fiscal_year.py
@@ -133,8 +133,8 @@
 
 			# build dict
 			p = {
-				'debit': flt(entry[2])
-				,'credit':flt(entry[3])
+				'debit': entry[4]=='No' and flt(entry[2]) or 0
+				,'credit': entry[4]=='No' and flt(entry[3]) or 0
 				,'opening': entry[4]=='Yes' and diff or 0
 				
 				# end date conditino only if it is not opening
diff --git a/setup/doctype/manage_account/manage_account.py b/setup/doctype/manage_account/manage_account.py
index a0ed2fa..651794f 100644
--- a/setup/doctype/manage_account/manage_account.py
+++ b/setup/doctype/manage_account/manage_account.py
@@ -29,7 +29,7 @@
     set_default(defkey, defvalue)
 
     if defkey == 'fiscal_year':
-      ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", defvalue)
+      ysd = sql("select year_start_date from `tabFiscal Year` where name=%s", cstr(defvalue))
       ysd = ysd and ysd[0][0] or ''
       if ysd:
         set_default('year_start_date', ysd.strftime('%Y-%m-%d'))
diff --git a/setup/doctype/sales_browser_control/sales_browser_control.py b/setup/doctype/sales_browser_control/sales_browser_control.py
index d4c4a13..e9f8242 100644
--- a/setup/doctype/sales_browser_control/sales_browser_control.py
+++ b/setup/doctype/sales_browser_control/sales_browser_control.py
@@ -131,7 +131,7 @@
 
     r = eval(args)
     
-    if r['lft'] == 0:
+    if r['lft'] == 0 and r['action'] != 'Create':
       n = sql("select lft,rgt from `tab%s` where name = '%s'"%(r['node_title'],r['nm']))
       r['lft'] = n[0][0]
       r['rgt'] = n[0][1]
@@ -212,4 +212,4 @@
     if res:
       msgprint("'%s' record is already exist."%(r['nm']))
       return 'true'
-    return 'false'      
\ No newline at end of file
+    return 'false'