Merge pull request #172 from anandpdoshi/master

remove previous field property setter
diff --git a/data/master.sql.gz b/data/master.sql.gz
index f3eaf34..9f2ed7f 100644
--- a/data/master.sql.gz
+++ b/data/master.sql.gz
Binary files differ
diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
index ca79387..41722d5 100644
--- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
+++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.js
@@ -66,7 +66,7 @@
         get_server_fields('get_default_values', args, 'entries', doc, el[i].doctype, el[i].name, 1);
       }
     }
-    cur_frm.cscript.calc_total(doc);
+    cur_frm.cscript.calc_amount(doc, 1);
   }
 
   if(doc.supplier) get_server_fields('get_default_supplier_address', JSON.stringify({supplier: doc.supplier}),'', doc, dt, dn, 1,callback);
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
index 12b57d9..c2b478e 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.js
@@ -18,6 +18,8 @@
 		if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
 		if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()});
 		if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
+		if(!doc.currency && sys_defaults.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
+		if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
 
 		//for previously created sales invoice, set required field related to pos
 		if(doc.is_pos ==1) cur_frm.cscript.is_pos(doc, dt, dn);
@@ -234,13 +236,6 @@
 
 /* **************************** TRIGGERS ********************************** */
 
-
-
-// Posting Date
-// ------------
-//cur_frm.cscript.posting_date = cur_frm.cscript.debit_to;
-
-
 // Get Items based on SO or DN Selected
 cur_frm.cscript['Get Items'] = function(doc, dt, dn) {
 	var callback = function(r,rt) {
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
index 57d8c55..9e4baa1 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
@@ -164,6 +164,10 @@
 				ret['actual_qty']= actual_qty and flt(actual_qty[0][0]) or 0
 		return ret
  
+	# Fetch ref rate from item master as per selected price list
+	def get_adj_percent(self, arg=''):
+		get_obj('Sales Common').get_adj_percent(self)
+
 
 	# Get tax rate if account type is tax
 	# ------------------------------------
@@ -516,7 +520,7 @@
 			if stock_item[0]['is_stock_item'] == "Yes":
 				# Reduce actual qty from warehouse
 				self.make_sl_entry( d, d.warehouse, - flt(d.qty) , 0, update_stock)
-		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
+		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values, self.doc.amended_from and 'Yes' or 'No')
 
 
 	#-------------------POS Stock Updatation Part----------------------------------------------
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
index eedb01c..497c99f 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2010-08-08 17:09:18',
 		'docstatus': 0,
-		'modified': '2011-12-08 16:28:22',
+		'modified': '2011-12-20 18:23:36',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
@@ -21,7 +21,7 @@
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1323341785',
+		'_last_update': '1324367593',
 		'change_log': '1. Change in pull_details method dt.-26-06-2009',
 		'colour': 'White:FFF',
 		'default_print_format': 'Standard',
@@ -34,7 +34,7 @@
 		'server_code_error': ' ',
 		'show_in_menu': 0,
 		'subject': 'To %(customer_name)s worth %(currency)s %(grand_total_export)s due on %(due_date)s | %(outstanding_amount)s outstanding',
-		'version': 388
+		'version': 391
 	},
 
 	# These values are common for all DocFormat
@@ -470,42 +470,26 @@
 	# DocField
 	{
 		'colour': 'White:FFF',
-		'description': 'Select Items from Sales Order',
+		'description': 'Select the currency in which price list is maintained',
 		'doctype': 'DocField',
-		'fieldname': 'sales_order_main',
-		'fieldtype': 'Link',
-		'label': 'Sales Order',
-		'oldfieldname': 'sales_order_main',
-		'oldfieldtype': 'Link',
-		'options': 'Sales Order',
+		'fieldname': 'price_list_currency',
+		'fieldtype': 'Select',
+		'label': 'Price List Currency',
+		'options': 'link:Currency',
 		'permlevel': 0,
-		'print_hide': 1
+		'reqd': 1
 	},
 
 	# DocField
 	{
 		'colour': 'White:FFF',
-		'description': 'Select Items from Delivery Note',
+		'description': 'Rate at which Price list currency is converted to your currency',
 		'doctype': 'DocField',
-		'fieldname': 'delivery_note_main',
-		'fieldtype': 'Link',
-		'label': 'Delivery Note',
-		'oldfieldname': 'delivery_note_main',
-		'oldfieldtype': 'Link',
-		'options': 'Delivery Note',
+		'fieldname': 'plc_conversion_rate',
+		'fieldtype': 'Currency',
+		'label': 'Price List Currency Conversion Rate',
 		'permlevel': 0,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'label': 'Get Items',
-		'oldfieldtype': 'Button',
-		'permlevel': 0,
-		'print_hide': 1,
-		'trigger': 'Client'
+		'reqd': 1
 	},
 
 	# DocField
@@ -546,6 +530,47 @@
 
 	# DocField
 	{
+		'colour': 'White:FFF',
+		'description': 'Select Items from Sales Order',
+		'doctype': 'DocField',
+		'fieldname': 'sales_order_main',
+		'fieldtype': 'Link',
+		'label': 'Sales Order',
+		'oldfieldname': 'sales_order_main',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Order',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Select Items from Delivery Note',
+		'doctype': 'DocField',
+		'fieldname': 'delivery_note_main',
+		'fieldtype': 'Link',
+		'label': 'Delivery Note',
+		'oldfieldname': 'delivery_note_main',
+		'oldfieldtype': 'Link',
+		'options': 'Delivery Note',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'label': 'Get Items',
+		'oldfieldtype': 'Button',
+		'permlevel': 0,
+		'print_hide': 1,
+		'trigger': 'Client'
+	},
+
+	# DocField
+	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
 		'permlevel': 0
diff --git a/erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js b/erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js
index 9222997..d9735b6 100644
--- a/erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js
+++ b/erpnext/buying/doctype/purchase_other_charges/purchase_other_charges.js
@@ -111,15 +111,14 @@
 /*---------------------- Get rate if account_head has account_type as TAX or CHARGEABLE-------------------------------------*/
 
 cur_frm.fields_dict['purchase_tax_details'].grid.get_field("account_head").get_query = function(doc,cdt,cdn) {
-  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable" or (tabAccount.is_pl_account = "Yes" and tabAccount.debit_or_credit = "Debit")) AND  tabAccount.name LIKE "%s"'
+  return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable" or (tabAccount.is_pl_account = "Yes" and tabAccount.debit_or_credit = "Debit")) AND tabAccount.company = "' + doc.company + '" AND  tabAccount.name LIKE "%s"'
 }
 
-//--------------------filter other charges master company-wise-----------------------------------------
-/*
-cur_frm.fields_dict.charge.get_query = function(doc) {
-  return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.docstatus !=2 AND `tabOther Charges`.name LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
+
+cur_frm.fields_dict['purchase_tax_details'].grid.get_field("cost_center").get_query = function(doc) {
+	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY	`tabCost Center`.`name` ASC LIMIT 50';
 }
-*/
+
 
 cur_frm.cscript.account_head = function(doc, cdt, cdn) {
   var d = locals[cdt][cdn];
diff --git a/erpnext/hr/doctype/attendance/attendance.txt b/erpnext/hr/doctype/attendance/attendance.txt
index 4f189b1..9c795bb 100644
--- a/erpnext/hr/doctype/attendance/attendance.txt
+++ b/erpnext/hr/doctype/attendance/attendance.txt
@@ -5,15 +5,16 @@
 	{
 		'creation': '2010-09-23 10:26:03',
 		'docstatus': 0,
-		'modified': '2011-06-27 14:39:08',
+		'modified': '2011-12-19 14:11:15',
 		'modified_by': 'Administrator',
 		'owner': 'ashwini@webnotestech.com'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1308808105',
+		'_last_update': '1317365120',
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'document_type': 'Master',
 		'module': 'HR',
@@ -22,7 +23,7 @@
 		'section_style': 'Simple',
 		'server_code_error': ' ',
 		'show_in_menu': 0,
-		'version': 74
+		'version': 75
 	},
 
 	# These values are common for all DocField
@@ -72,7 +73,6 @@
 	{
 		'amend': 0,
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'role': 'System Manager'
 	},
 
@@ -80,7 +80,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Attendance Details',
 		'oldfieldtype': 'Section Break',
 		'options': 'Simple'
@@ -91,7 +90,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'naming_series',
 		'fieldtype': 'Select',
-		'idx': 2,
 		'label': 'Naming Series',
 		'no_copy': 1,
 		'oldfieldname': 'naming_series',
@@ -106,7 +104,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'employee',
 		'fieldtype': 'Link',
-		'idx': 3,
 		'in_filter': 1,
 		'label': 'Employee',
 		'oldfieldname': 'employee',
@@ -122,7 +119,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'employee_name',
 		'fieldtype': 'Data',
-		'idx': 4,
 		'label': 'Employee Name',
 		'oldfieldname': 'employee_name',
 		'oldfieldtype': 'Data'
@@ -134,27 +130,14 @@
 		'doctype': 'DocField',
 		'fieldname': 'status',
 		'fieldtype': 'Select',
-		'idx': 5,
 		'in_filter': 1,
 		'label': 'Status',
+		'no_copy': 1,
 		'oldfieldname': 'status',
 		'oldfieldtype': 'Select',
 		'options': '\nPresent\nAbsent\nHalf Day',
 		'reqd': 1,
-		'search_index': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'shifts',
-		'fieldtype': 'Select',
-		'idx': 6,
-		'label': 'Shifts',
-		'oldfieldname': 'shifts',
-		'oldfieldtype': 'Select',
-		'options': '\nDay\nNight',
-		'reqd': 0
+		'search_index': 1
 	},
 
 	# DocField
@@ -164,7 +147,6 @@
 		'fieldname': 'leave_type',
 		'fieldtype': 'Link',
 		'hidden': 1,
-		'idx': 7,
 		'label': 'Leave Type',
 		'oldfieldname': 'leave_type',
 		'oldfieldtype': 'Link',
@@ -177,7 +159,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 8,
 		'oldfieldtype': 'Column Break',
 		'width': '50%'
 	},
@@ -187,13 +168,12 @@
 		'doctype': 'DocField',
 		'fieldname': 'att_date',
 		'fieldtype': 'Date',
-		'idx': 9,
 		'in_filter': 1,
 		'label': 'Attendance Date',
 		'oldfieldname': 'att_date',
 		'oldfieldtype': 'Date',
 		'reqd': 1,
-		'search_index': 1
+		'search_index': 0
 	},
 
 	# DocField
@@ -201,7 +181,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'fiscal_year',
 		'fieldtype': 'Select',
-		'idx': 10,
 		'in_filter': 1,
 		'label': 'Fiscal Year',
 		'oldfieldname': 'fiscal_year',
@@ -215,7 +194,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'company',
 		'fieldtype': 'Select',
-		'idx': 11,
 		'in_filter': 1,
 		'label': 'Company',
 		'oldfieldname': 'company',
diff --git a/erpnext/patches/auto_indent.py b/erpnext/patches/auto_indent.py
new file mode 100644
index 0000000..a8488e7
--- /dev/null
+++ b/erpnext/patches/auto_indent.py
@@ -0,0 +1,8 @@
+def execute():
+	import webnotes
+	from webnotes.modules.module_manager import reload_doc
+	reload_doc('setup', 'doctype', 'manage_account')
+	reload_doc('stock', 'doctype', 'item')
+	webnotes.conn.sql("delete from `tabDocField` where fieldname='minimum_inventory_level' and parent='item'")
+	webnotes.conn.sql("update `tabItem` set re_order_level = minimum_inventory_level where ifnull(re_order_level,0) = 0 ")
+		
diff --git a/erpnext/patches/c_form_patch.py b/erpnext/patches/c_form_patch.py
index a55768d..0f8fa22 100644
--- a/erpnext/patches/c_form_patch.py
+++ b/erpnext/patches/c_form_patch.py
@@ -4,7 +4,7 @@
 
 	reload_doc('accounts', 'doctype', 'receivable_voucher')
 	reload_doc('accounts', 'doctype', 'c_form')
-	reload_doc('accounts', 'doctype', 'c_form_invoice_details')
+	reload_doc('accounts', 'doctype', 'c_form_invoice_detail')
 	reload_doc('accounts', 'Module Def', 'Accounts')
 
 	sql = webnotes.conn.sql
diff --git a/erpnext/patches/delivery_billing_status_patch.py b/erpnext/patches/delivery_billing_status_patch.py
index 1fcd8bf..7de04b7 100644
--- a/erpnext/patches/delivery_billing_status_patch.py
+++ b/erpnext/patches/delivery_billing_status_patch.py
@@ -49,7 +49,7 @@
 	sql("""update `tabDelivery Note` set billing_status = if(ifnull(per_billed,0) < 0.001, 'Not Billed', 
 			if(per_billed >= 99.99, 'Fully Billed', 'Partly Billed'))""")
 			
-def run_patch():
+def execute():
 	update_delivered_billed_qty()
 	update_percent()
 	update_status()
diff --git a/erpnext/patches/employeewise_balance_leave_report.py b/erpnext/patches/employeewise_balance_leave_report.py
index 6af2364..59c5940 100644
--- a/erpnext/patches/employeewise_balance_leave_report.py
+++ b/erpnext/patches/employeewise_balance_leave_report.py
@@ -6,7 +6,9 @@
 """
 def execute():
 	from webnotes.model.doc import Document
+	from webnotes.modules.module_manager import reload_doc
+	reload_doc('hr', 'search_criteria', 'employeewise_balance_leave_report')
 	d = Document('Search Criteria', 'employeewise_balance_leave_report')
 	d.criteria_name = 'Employee Leave Balance Report'
 	d.description = 'Employeewise Balance Leave Report'
-	d.save()
\ No newline at end of file
+	d.save()
diff --git a/erpnext/patches/patch.py b/erpnext/patches/patch.py
index 7e8a083..4e32c02 100644
--- a/erpnext/patches/patch.py
+++ b/erpnext/patches/patch.py
@@ -6,6 +6,7 @@
 #-------------------------------------------
 
 def execute(patch_no):
+	return
 	import webnotes
 	from webnotes.modules.module_manager import reload_doc
 
diff --git a/erpnext/patches/price_list_patch.py b/erpnext/patches/price_list_patch.py
new file mode 100644
index 0000000..0f485b3
--- /dev/null
+++ b/erpnext/patches/price_list_patch.py
@@ -0,0 +1,13 @@
+def execute():
+	import webnotes
+	from webnotes.modules.module_manager import reload_doc
+
+	reload_doc('accounts', 'doctype', 'receivable_voucher')
+	reload_doc('stock', 'doctype', 'delivery_note')
+	reload_doc('selling', 'doctype', 'sales_order')
+	reload_doc('selling', 'doctype', 'quotation')
+	reload_doc('setup', 'doctype', 'manage_account')
+
+
+	for d in ['Receivable Voucher', 'Delivery Note', 'Sales Order', 'Quotation']:
+		webnotes.conn.sql("update `tab%s` set price_list_currency = currency, plc_conversion_rate = conversion_rate" % d)
diff --git a/erpnext/patches/reload_employeewise_balance_leave_report.py b/erpnext/patches/reload_employeewise_balance_leave_report.py
new file mode 100644
index 0000000..b03b44b
--- /dev/null
+++ b/erpnext/patches/reload_employeewise_balance_leave_report.py
@@ -0,0 +1,4 @@
+def execute():
+	import webnotes
+	from webnotes.modules.module_manager import reload_doc
+	reload_doc('hr', 'search_criteria', 'employeewise_balance_leave_report')
diff --git a/erpnext/patches/remove_page_break_from_defaults.py b/erpnext/patches/remove_page_break_from_defaults.py
index b565e93..8d842e3 100644
--- a/erpnext/patches/remove_page_break_from_defaults.py
+++ b/erpnext/patches/remove_page_break_from_defaults.py
@@ -1,5 +1,3 @@
 def execute():
 	import webnotes
-	webnotes.conn.sql("""\
-		DELETE FROM `tabDefaultValue`
-		WHERE parent='Control Panel' AND defkey='page_break'""")
+	webnotes.conn.sql("""delete from `tabDefaultValue` where defkey in ('page_break', 'projects', 'packing_details', 'discounts', 'brands', 'item_batch_nos', 'after_sales_installations', 'item_searial_nos', 'item_group_in_details', 'exports', 'imports', 'item_advanced', 'sales_extras', 'more_info', 'quality', 'manufacturing', 'pos', 'item_serial_nos', 'purchase_discounts', 'recurring_invoice') and parent = 'Control Panel'""")
diff --git a/erpnext/patches/repost_stock.py b/erpnext/patches/repost_stock.py
index 680e06f..a19494c 100644
--- a/erpnext/patches/repost_stock.py
+++ b/erpnext/patches/repost_stock.py
@@ -2,6 +2,7 @@
     import webnotes
     sql = webnotes.conn.sql
     from webnotes.model.code import get_obj
+    from webnotes.utils import flt
 
     # update incoming rate in serial nos
     sr = sql("""select name, item_code, purchase_document_no from `tabSerial No`
diff --git a/erpnext/patches/task_email_notification.py b/erpnext/patches/task_email_notification.py
new file mode 100644
index 0000000..e6a7afa
--- /dev/null
+++ b/erpnext/patches/task_email_notification.py
@@ -0,0 +1,4 @@
+def execute():
+	import webnotes
+	from webnotes.modules.module_manager import reload_doc
+	reload_doc('projects', 'doctype', 'ticket')
diff --git a/erpnext/projects/doctype/project_milestone/project_milestone.txt b/erpnext/projects/doctype/project_milestone/project_milestone.txt
index eab533b..6d45a7c 100644
--- a/erpnext/projects/doctype/project_milestone/project_milestone.txt
+++ b/erpnext/projects/doctype/project_milestone/project_milestone.txt
@@ -5,21 +5,22 @@
 	{
 		'creation': '2010-08-08 17:09:15',
 		'docstatus': 0,
-		'modified': '2011-01-05 15:24:43',
-		'modified_by': 'sneha@webnotestech.com',
+		'modified': '2011-12-19 14:11:40',
+		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'istable': 1,
 		'module': 'Projects',
 		'name': '__common__',
 		'section_style': 'Simple',
 		'server_code_error': ' ',
-		'version': 2
+		'version': 4
 	},
 
 	# These values are common for all DocField
@@ -43,7 +44,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'milestone_date',
 		'fieldtype': 'Date',
-		'idx': 1,
 		'label': 'Milestone Date',
 		'oldfieldname': 'milestone_date',
 		'oldfieldtype': 'Date'
@@ -52,18 +52,8 @@
 	# DocField
 	{
 		'doctype': 'DocField',
-		'fieldname': 'actual_completion_date_',
-		'fieldtype': 'Date',
-		'idx': 2,
-		'label': 'Actual Completion Date '
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
 		'fieldname': 'milestone',
 		'fieldtype': 'Text',
-		'idx': 3,
 		'label': 'Milestone',
 		'oldfieldname': 'milestone',
 		'oldfieldtype': 'Text',
@@ -75,8 +65,8 @@
 		'doctype': 'DocField',
 		'fieldname': 'status',
 		'fieldtype': 'Select',
-		'idx': 4,
 		'label': 'Status',
+		'no_copy': 1,
 		'oldfieldname': 'status',
 		'oldfieldtype': 'Select',
 		'options': 'Pending\nCompleted'
diff --git a/erpnext/projects/doctype/ticket/ticket.py b/erpnext/projects/doctype/ticket/ticket.py
index baf85e7..4d3e988 100644
--- a/erpnext/projects/doctype/ticket/ticket.py
+++ b/erpnext/projects/doctype/ticket/ticket.py
@@ -7,9 +7,9 @@
 from webnotes.model.doclist import getlist, copy_doclist
 from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
 from webnotes import session, form, is_testing, msgprint, errprint
-
 sql = webnotes.conn.sql
 set = webnotes.conn.set
+get_value = webnotes.conn.get_value
 
 # -----------------------------------------------------------------------------------------
 
@@ -32,7 +32,7 @@
       return ret
   
   def get_allocated_to_name(self):
-    as_em = sql("select first_name, last_name from `tabProfile` where name=%s",self.doc.allocated_to)
+    as_em = sql("select first_name, last_name from `tabProfile` where name=%s",str(self.doc.allocated_to))
     ret = { 'allocated_to_name' : as_em and (as_em[0][0] + ' ' + as_em[0][1]) or ''}
     return ret
 
@@ -68,6 +68,13 @@
   #--------------------------------------------   
   
   def on_update(self):
+    if (self.doc.status =='Open') and (self.doc.task_email_notify==1):
+       	msg2= 'A task %s has been assigned to you by %s on %s <br/> \
+       	Project:%s <br/> Review Date:%s <br /> Closing Date:%s <br /> Details  %s' \
+       	%(self.doc.name,self.doc.senders_name,self.doc.opening_date,self.doc.project, \
+       	self.doc.review_date,self.doc.closing_date,self.doc.description)
+    	sendmail(self.doc.allocated_to, sender='automail@webnotestech.com', \
+    	subject='A task has been assigned', parts=[['text/plain',msg2]])
     pass
         
   #validate before sending for approval
diff --git a/erpnext/projects/doctype/ticket/ticket.txt b/erpnext/projects/doctype/ticket/ticket.txt
index e9d5ff0..cd984ac 100644
--- a/erpnext/projects/doctype/ticket/ticket.txt
+++ b/erpnext/projects/doctype/ticket/ticket.txt
@@ -5,17 +5,18 @@
 	{
 		'creation': '2011-01-28 17:52:35',
 		'docstatus': 0,
-		'modified': '2010-12-03 10:04:58',
+		'modified': '2011-12-21 16:32:30',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1307707462',
+		'_last_update': '1324394580',
 		'allow_trash': 1,
 		'autoname': 'TIC/.####',
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'document_type': 'Master',
 		'module': 'Projects',
@@ -25,7 +26,7 @@
 		'show_in_menu': 0,
 		'subject': '%(subject)s',
 		'tag_fields': 'status',
-		'version': 245
+		'version': 247
 	},
 
 	# These values are common for all DocField
@@ -44,7 +45,8 @@
 		'parent': 'Ticket',
 		'parentfield': 'permissions',
 		'parenttype': 'DocType',
-		'read': 1
+		'read': 1,
+		'submit': 0
 	},
 
 	# DocType, Ticket
@@ -55,11 +57,21 @@
 
 	# DocPerm
 	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
+		'doctype': 'DocPerm',
+		'permlevel': 1,
+		'role': 'Projects User',
+		'write': 0
+	},
+
+	# DocPerm
+	{
 		'amend': 1,
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'permlevel': 0,
 		'role': 'All',
 		'write': 1
@@ -67,8 +79,10 @@
 
 	# DocPerm
 	{
+		'amend': 0,
+		'cancel': 0,
+		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 2,
 		'permlevel': 1,
 		'role': 'All',
 		'write': 0
@@ -80,25 +94,15 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 3,
 		'permlevel': 0,
 		'role': 'Projects User',
 		'write': 1
 	},
 
-	# DocPerm
-	{
-		'doctype': 'DocPerm',
-		'idx': 4,
-		'permlevel': 1,
-		'role': 'Projects User'
-	},
-
 	# DocField
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Task Details',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -111,7 +115,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'subject',
 		'fieldtype': 'Data',
-		'idx': 2,
 		'in_filter': 1,
 		'label': 'Subject',
 		'oldfieldname': 'subject',
@@ -125,8 +128,8 @@
 		'doctype': 'DocField',
 		'fieldname': 'status',
 		'fieldtype': 'Select',
-		'idx': 3,
 		'label': 'Status',
+		'no_copy': 1,
 		'oldfieldname': 'status',
 		'oldfieldtype': 'Select',
 		'options': 'Open\nPending Review\nClosed\nCancelled',
@@ -137,9 +140,17 @@
 	# DocField
 	{
 		'doctype': 'DocField',
+		'fieldname': 'task_email_notify',
+		'fieldtype': 'Check',
+		'label': 'Sent Mail Notification',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
 		'fieldname': 'opening_date',
 		'fieldtype': 'Date',
-		'idx': 4,
 		'label': 'Creation Date',
 		'oldfieldname': 'opening_date',
 		'oldfieldtype': 'Date',
@@ -155,7 +166,6 @@
 		'fieldname': 'review_date',
 		'fieldtype': 'Date',
 		'hidden': 1,
-		'idx': 5,
 		'label': 'Review Date',
 		'oldfieldname': 'review_date',
 		'oldfieldtype': 'Date',
@@ -170,7 +180,6 @@
 		'fieldname': 'closing_date',
 		'fieldtype': 'Date',
 		'hidden': 1,
-		'idx': 6,
 		'label': 'Closing Date',
 		'oldfieldname': 'closing_date',
 		'oldfieldtype': 'Date',
@@ -182,7 +191,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'priority',
 		'fieldtype': 'Select',
-		'idx': 7,
 		'in_filter': 1,
 		'label': 'Priority',
 		'oldfieldname': 'priority',
@@ -199,7 +207,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'project',
 		'fieldtype': 'Link',
-		'idx': 8,
 		'label': 'Project',
 		'oldfieldname': 'project',
 		'oldfieldtype': 'Link',
@@ -214,7 +221,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer',
 		'fieldtype': 'Link',
-		'idx': 9,
 		'label': 'Customer',
 		'oldfieldname': 'customer',
 		'oldfieldtype': 'Link',
@@ -228,7 +234,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_name',
 		'fieldtype': 'Data',
-		'idx': 10,
 		'label': 'Customer Name',
 		'oldfieldname': 'customer_name',
 		'oldfieldtype': 'Data',
@@ -239,7 +244,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 11,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -251,7 +255,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'allocated_to',
 		'fieldtype': 'Link',
-		'idx': 12,
 		'label': 'Allocated To',
 		'oldfieldname': 'allocated_to',
 		'oldfieldtype': 'Link',
@@ -266,7 +269,6 @@
 		'fieldname': 'allocated_to_name',
 		'fieldtype': 'Data',
 		'hidden': 1,
-		'idx': 13,
 		'label': 'Allocated To Name',
 		'oldfieldname': 'allocated_to_name',
 		'oldfieldtype': 'Data',
@@ -278,7 +280,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'senders_name',
 		'fieldtype': 'Data',
-		'idx': 14,
 		'in_filter': 1,
 		'label': 'Raised By',
 		'oldfieldname': 'senders_name',
@@ -293,7 +294,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'senders_email',
 		'fieldtype': 'Data',
-		'idx': 15,
 		'label': 'Email',
 		'oldfieldname': 'senders_email',
 		'oldfieldtype': 'Data',
@@ -306,7 +306,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'senders_contact_no',
 		'fieldtype': 'Data',
-		'idx': 16,
 		'label': 'Senders Contact No',
 		'oldfieldname': 'senders_contact_no',
 		'oldfieldtype': 'Data',
@@ -318,7 +317,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'senders_company',
 		'fieldtype': 'Data',
-		'idx': 17,
 		'label': 'Senders Company',
 		'oldfieldname': 'senders_company',
 		'oldfieldtype': 'Data',
@@ -330,7 +328,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'category',
 		'fieldtype': 'Link',
-		'idx': 18,
 		'label': 'Category',
 		'oldfieldname': 'category',
 		'oldfieldtype': 'Link',
@@ -343,7 +340,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'external_or_internal',
 		'fieldtype': 'Select',
-		'idx': 19,
 		'label': 'External or Internal',
 		'oldfieldname': 'external_or_internal',
 		'oldfieldtype': 'Select',
@@ -357,7 +353,6 @@
 		'fieldname': 'amended_from',
 		'fieldtype': 'Data',
 		'hidden': 1,
-		'idx': 20,
 		'label': 'Amended From',
 		'no_copy': 1,
 		'oldfieldname': 'amended_from',
@@ -373,7 +368,6 @@
 		'fieldname': 'amendment_date',
 		'fieldtype': 'Date',
 		'hidden': 1,
-		'idx': 21,
 		'label': 'Amendment Date',
 		'no_copy': 1,
 		'oldfieldname': 'amendment_date',
@@ -387,7 +381,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 22,
 		'oldfieldtype': 'Section Break',
 		'options': 'Simple',
 		'permlevel': 0
@@ -398,7 +391,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'description',
 		'fieldtype': 'Text Editor',
-		'idx': 23,
 		'label': 'Details',
 		'oldfieldname': 'description',
 		'oldfieldtype': 'Text Editor',
@@ -414,7 +406,6 @@
 		'fieldname': 'first_creation_flag',
 		'fieldtype': 'Int',
 		'hidden': 1,
-		'idx': 24,
 		'in_filter': 0,
 		'label': 'First Creation Flag',
 		'no_copy': 1,
@@ -431,7 +422,6 @@
 		'fieldname': 'second_creation_flag',
 		'fieldtype': 'Int',
 		'hidden': 1,
-		'idx': 25,
 		'label': 'Second Creation Flag',
 		'no_copy': 1,
 		'oldfieldname': 'second_creation_flag',
@@ -444,7 +434,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 26,
 		'label': 'Time and Budget',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -454,7 +443,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 27,
 		'label': 'Expected',
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
@@ -466,7 +454,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'exp_start_date',
 		'fieldtype': 'Date',
-		'idx': 28,
 		'label': 'Expected Start Date',
 		'oldfieldname': 'exp_start_date',
 		'oldfieldtype': 'Date',
@@ -479,7 +466,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'exp_end_date',
 		'fieldtype': 'Date',
-		'idx': 29,
 		'in_filter': 1,
 		'label': 'Expected End Date',
 		'oldfieldname': 'exp_end_date',
@@ -494,7 +480,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'exp_total_hrs',
 		'fieldtype': 'Data',
-		'idx': 30,
 		'label': 'Total Hours (Expected)',
 		'oldfieldname': 'exp_total_hrs',
 		'oldfieldtype': 'Data',
@@ -507,7 +492,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'allocated_budget',
 		'fieldtype': 'Currency',
-		'idx': 31,
 		'label': 'Allocated Budget',
 		'oldfieldname': 'allocated_budget',
 		'oldfieldtype': 'Currency',
@@ -518,7 +502,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 32,
 		'label': 'Actual',
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
@@ -530,7 +513,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'act_start_date',
 		'fieldtype': 'Date',
-		'idx': 33,
 		'label': 'Actual Start Date',
 		'oldfieldname': 'act_start_date',
 		'oldfieldtype': 'Date',
@@ -542,7 +524,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'act_end_date',
 		'fieldtype': 'Date',
-		'idx': 34,
 		'label': 'Actual End Date',
 		'oldfieldname': 'act_end_date',
 		'oldfieldtype': 'Date',
@@ -554,7 +535,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'act_total_hrs',
 		'fieldtype': 'Data',
-		'idx': 35,
 		'label': 'Total Hours (Actual)',
 		'oldfieldname': 'act_total_hrs',
 		'oldfieldtype': 'Data',
@@ -566,7 +546,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'actual_budget',
 		'fieldtype': 'Currency',
-		'idx': 36,
 		'label': 'Actual Budget',
 		'oldfieldname': 'actual_budget',
 		'oldfieldtype': 'Currency',
diff --git a/erpnext/selling/doctype/enquiry/enquiry.txt b/erpnext/selling/doctype/enquiry/enquiry.txt
index 260e077..0bf3b7f 100644
--- a/erpnext/selling/doctype/enquiry/enquiry.txt
+++ b/erpnext/selling/doctype/enquiry/enquiry.txt
@@ -5,15 +5,16 @@
 	{
 		'creation': '2010-08-08 17:09:00',
 		'docstatus': 0,
-		'modified': '2011-05-12 18:27:46',
+		'modified': '2011-12-19 14:11:27',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1305205067',
+		'_last_update': '1316075905',
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'document_type': 'Transaction',
 		'module': 'Selling',
@@ -23,7 +24,7 @@
 		'server_code_error': ' ',
 		'show_in_menu': 0,
 		'subject': 'To %(customer_name)s%(lead_name)s on %(transaction_date)s',
-		'version': 586
+		'version': 587
 	},
 
 	# These values are common for all DocField
@@ -57,7 +58,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'permlevel': 1,
 		'role': 'Sales Manager',
 		'submit': 0,
@@ -70,7 +70,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 2,
 		'permlevel': 0,
 		'role': 'System Manager',
 		'submit': 1,
@@ -80,7 +79,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 3,
 		'permlevel': 1,
 		'role': 'System Manager'
 	},
@@ -91,7 +89,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 4,
 		'permlevel': 0,
 		'role': 'Sales User',
 		'submit': 1,
@@ -104,7 +101,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 5,
 		'permlevel': 1,
 		'role': 'Sales User',
 		'submit': 0,
@@ -117,7 +113,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 6,
 		'permlevel': 0,
 		'role': 'Sales Manager',
 		'submit': 1,
@@ -130,7 +125,6 @@
 		'description': 'Enter customer enquiry for which you might raise a quotation in future',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Basic Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -143,7 +137,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'naming_series',
 		'fieldtype': 'Select',
-		'idx': 2,
 		'label': 'Series',
 		'no_copy': 1,
 		'oldfieldname': 'naming_series',
@@ -159,7 +152,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'enquiry_from',
 		'fieldtype': 'Select',
-		'idx': 3,
 		'label': 'Enquiry From',
 		'oldfieldname': 'enquiry_from',
 		'oldfieldtype': 'Select',
@@ -178,7 +170,6 @@
 		'fieldname': 'customer',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 4,
 		'in_filter': 1,
 		'label': 'Customer',
 		'oldfieldname': 'customer',
@@ -187,7 +178,7 @@
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 0,
-		'search_index': 1,
+		'search_index': 0,
 		'trigger': 'Client'
 	},
 
@@ -196,7 +187,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_address',
 		'fieldtype': 'Link',
-		'idx': 5,
 		'in_filter': 1,
 		'label': 'Customer Address',
 		'options': 'Address',
@@ -210,7 +200,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_person',
 		'fieldtype': 'Link',
-		'idx': 6,
 		'in_filter': 1,
 		'label': 'Contact Person',
 		'options': 'Contact',
@@ -224,7 +213,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_name',
 		'fieldtype': 'Data',
-		'idx': 7,
 		'label': 'Customer Name',
 		'permlevel': 1,
 		'print_hide': 0
@@ -236,7 +224,6 @@
 		'fieldname': 'lead',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 8,
 		'in_filter': 1,
 		'label': 'Lead',
 		'oldfieldname': 'lead',
@@ -244,7 +231,6 @@
 		'options': 'Lead',
 		'permlevel': 0,
 		'print_hide': 1,
-		'search_index': 1,
 		'trigger': 'Client'
 	},
 
@@ -254,7 +240,6 @@
 		'fieldname': 'lead_name',
 		'fieldtype': 'Data',
 		'hidden': 0,
-		'idx': 9,
 		'label': 'Name',
 		'oldfieldname': 'lead_name',
 		'oldfieldtype': 'Data',
@@ -267,7 +252,6 @@
 		'fieldname': 'address_display',
 		'fieldtype': 'Small Text',
 		'hidden': 0,
-		'idx': 10,
 		'label': 'Address',
 		'oldfieldname': 'address',
 		'oldfieldtype': 'Small Text',
@@ -279,7 +263,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_display',
 		'fieldtype': 'Small Text',
-		'idx': 11,
 		'label': 'Contact',
 		'permlevel': 1
 	},
@@ -289,7 +272,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_mobile',
 		'fieldtype': 'Text',
-		'idx': 12,
 		'label': 'Contact Mobile No',
 		'permlevel': 1
 	},
@@ -299,7 +281,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_email',
 		'fieldtype': 'Text',
-		'idx': 13,
 		'label': 'Contact Email',
 		'permlevel': 1
 	},
@@ -308,7 +289,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 14,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -321,13 +301,11 @@
 		'doctype': 'DocField',
 		'fieldname': 'transaction_date',
 		'fieldtype': 'Date',
-		'idx': 15,
 		'label': 'Enquiry Date',
 		'oldfieldname': 'transaction_date',
 		'oldfieldtype': 'Date',
 		'permlevel': 0,
 		'reqd': 1,
-		'search_index': 1,
 		'width': '50px'
 	},
 
@@ -337,7 +315,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'enquiry_type',
 		'fieldtype': 'Select',
-		'idx': 16,
 		'label': 'Enquiry Type',
 		'oldfieldname': 'enquiry_type',
 		'oldfieldtype': 'Select',
@@ -353,7 +330,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'status',
 		'fieldtype': 'Select',
-		'idx': 17,
 		'label': 'Status',
 		'no_copy': 1,
 		'oldfieldname': 'status',
@@ -368,7 +344,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'amended_from',
 		'fieldtype': 'Data',
-		'idx': 18,
 		'label': 'Amended From',
 		'no_copy': 1,
 		'oldfieldname': 'amended_from',
@@ -383,7 +358,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'amendment_date',
 		'fieldtype': 'Date',
-		'idx': 19,
 		'label': 'Amendment Date',
 		'no_copy': 1,
 		'oldfieldname': 'amendment_date',
@@ -400,26 +374,25 @@
 		'doctype': 'DocField',
 		'fieldname': 'territory',
 		'fieldtype': 'Link',
-		'idx': 20,
 		'in_filter': 1,
 		'label': 'Territory',
 		'options': 'Territory',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
-		'search_index': 0,
+		'search_index': 1,
 		'trigger': 'Client'
 	},
 
 	# DocField
 	{
 		'colour': 'White:FFF',
+		'depends_on': 'eval:doc.enquiry_from=="Customer"',
 		'description': '<a href="javascript:cur_frm.cscript.CGHelp();">To Manage Customer Groups, click here</a>',
 		'doctype': 'DocField',
 		'fieldname': 'customer_group',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 21,
 		'in_filter': 1,
 		'label': 'Customer Group',
 		'oldfieldname': 'customer_group',
@@ -428,7 +401,7 @@
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 0,
-		'search_index': 0,
+		'search_index': 1,
 		'trigger': 'Client'
 	},
 
@@ -437,7 +410,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 22,
 		'label': 'Items',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -450,7 +422,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'enquiry_details',
 		'fieldtype': 'Table',
-		'idx': 23,
 		'label': 'Enquiry Details',
 		'oldfieldname': 'enquiry_details',
 		'oldfieldtype': 'Table',
@@ -464,7 +435,6 @@
 		'description': 'Filing in Additional Information about the Enquiry will help you analyze your data better.',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 24,
 		'label': 'More Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -474,7 +444,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 25,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -485,7 +454,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'company',
 		'fieldtype': 'Link',
-		'idx': 26,
 		'in_filter': 1,
 		'label': 'Company',
 		'oldfieldname': 'company',
@@ -494,7 +462,7 @@
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
-		'search_index': 0
+		'search_index': 1
 	},
 
 	# DocField
@@ -502,7 +470,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'fiscal_year',
 		'fieldtype': 'Select',
-		'idx': 27,
 		'in_filter': 1,
 		'label': 'Fiscal Year',
 		'oldfieldname': 'fiscal_year',
@@ -511,7 +478,7 @@
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
-		'search_index': 0
+		'search_index': 1
 	},
 
 	# DocField
@@ -519,7 +486,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'source',
 		'fieldtype': 'Select',
-		'idx': 28,
 		'label': 'Source',
 		'oldfieldname': 'source',
 		'oldfieldtype': 'Select',
@@ -534,7 +500,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'campaign',
 		'fieldtype': 'Link',
-		'idx': 29,
 		'label': 'Campaign',
 		'oldfieldname': 'campaign',
 		'oldfieldtype': 'Link',
@@ -549,7 +514,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'order_lost_reason',
 		'fieldtype': 'Small Text',
-		'idx': 30,
 		'label': 'Order Lost Reason',
 		'no_copy': 1,
 		'oldfieldname': 'order_lost_reason',
@@ -562,7 +526,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 31,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -575,7 +538,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_by',
 		'fieldtype': 'Link',
-		'idx': 32,
 		'in_filter': 1,
 		'label': 'Next Contact By',
 		'oldfieldname': 'contact_by',
@@ -592,7 +554,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_date',
 		'fieldtype': 'Date',
-		'idx': 33,
 		'label': 'Next Contact Date',
 		'oldfieldname': 'contact_date',
 		'oldfieldtype': 'Date',
@@ -608,7 +569,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'last_contact_date',
 		'fieldtype': 'Date',
-		'idx': 34,
 		'label': 'Last Contact Date',
 		'no_copy': 1,
 		'oldfieldname': 'last_contact_date',
@@ -622,7 +582,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'to_discuss',
 		'fieldtype': 'Small Text',
-		'idx': 35,
 		'label': 'To Discuss',
 		'no_copy': 1,
 		'oldfieldname': 'to_discuss',
@@ -636,7 +595,6 @@
 		'description': 'Keep a track of communication related to this enquiry which will help for future reference.',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 36,
 		'label': 'Communication History',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -649,7 +607,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'follow_up',
 		'fieldtype': 'Table',
-		'idx': 37,
 		'label': 'Follow Up',
 		'oldfieldname': 'follow_up',
 		'oldfieldtype': 'Table',
diff --git a/erpnext/selling/doctype/quotation/quotation.js b/erpnext/selling/doctype/quotation/quotation.js
index 21eceb9..4c205a9 100644
--- a/erpnext/selling/doctype/quotation/quotation.js
+++ b/erpnext/selling/doctype/quotation/quotation.js
@@ -18,7 +18,8 @@
   if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
   if(!doc.conversion_rate) set_multiple(cdt,cdn,{conversion_rate:'1.00'});
   if(!doc.currency && sys_defaults.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
-  //if(!doc.price_list_name && sys_defaults.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
+  if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
+
   if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
   if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
 
@@ -51,7 +52,6 @@
     hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
     doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
   }
-  //refresh_many(['lead','customer']);
 }
 
 
@@ -59,10 +59,6 @@
 //================ hide - unhide fields on basis of quotation to either lead or customer ===============================
 cur_frm.cscript.quotation_to = function(doc,cdt,cdn){
   cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
-  //doc.customer_address = doc.territory = doc.contact_no = doc.email_id = "";
-  //refresh_many(['territory','customer_address','contact_no','email_id']);
-  //doc.address_display = doc.contact_display = "";
-  //refresh_many(['address_display','contact_display']);
 }
 
 
@@ -80,31 +76,8 @@
 
   if (!doc.docstatus) hide_field(['Update Follow up']);
   else unhide_field(['Update Follow up']);
-  //cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
 }
 
-// ============== Lead and its Details ============================
-
-/*
-//================ create new contact ============================================================================
-cur_frm.cscript.new_contact = function(){
-  tn = createLocal('Contact');
-  locals['Contact'][tn].is_customer = 1;
-  if(doc.customer) locals['Contact'][tn].customer = doc.customer;
-  loaddoc('Contact', tn);
-}
-*/
-
-
-// DOCTYPE TRIGGERS
-// ====================================================================================
-
-/*
-// ***************** Get Contact Person based on customer selected *****************
-cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
-  return 'SELECT `tabContact`.contact_name, `tabContact`.email_id FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.docstatus != 2 AND `tabContact`.customer = "'+ doc.customer +'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
-}
-*/
 
 //customer
 cur_frm.cscript.customer = function(doc,dt,dn) {
@@ -274,14 +247,6 @@
 }
 
 
-
-
-/*
-//get query select Territory
-cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
-  return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s"  ORDER BY  `tabTerritory`.`name` ASC LIMIT 50';}
-*/
-
 //===================== Quotation to validation - either customer or lead mandatory ====================
 cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
 
@@ -293,14 +258,11 @@
     }
   }
   else if(doc.quotation_to == 'Customer'){
-
     if(!doc.customer){
       alert("Customer is mandatory.");
       validated = false;
     }
-
   }
-
 }
 
 //===================validation function =================================
diff --git a/erpnext/selling/doctype/quotation/quotation.txt b/erpnext/selling/doctype/quotation/quotation.txt
index 6763c2d..86b7b5f 100644
--- a/erpnext/selling/doctype/quotation/quotation.txt
+++ b/erpnext/selling/doctype/quotation/quotation.txt
@@ -5,18 +5,19 @@
 	{
 		'creation': '2010-08-08 17:09:17',
 		'docstatus': 0,
-		'modified': '2011-06-21 17:17:07',
+		'modified': '2011-12-20 14:01:09',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1308741898',
+		'_last_update': '1322549700',
 		'allow_attach': 1,
 		'allow_email': 0,
 		'allow_trash': 1,
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'document_type': 'Transaction',
 		'hide_toolbar': 0,
@@ -31,7 +32,7 @@
 		'show_in_menu': 0,
 		'subject': 'To %(customer_name)s on %(transaction_date)s worth %(currency)s %(grand_total_export)s',
 		'tag_fields': 'status',
-		'version': 596
+		'version': 597
 	},
 
 	# These values are common for all DocField
@@ -49,8 +50,7 @@
 		'name': '__common__',
 		'parent': 'Quotation',
 		'parentfield': 'permissions',
-		'parenttype': 'DocType',
-		'read': 1
+		'parenttype': 'DocType'
 	},
 
 	# DocType, Quotation
@@ -61,12 +61,19 @@
 
 	# DocPerm
 	{
+		'doctype': 'DocPerm',
+		'permlevel': 0,
+		'role': 'user print'
+	},
+
+	# DocPerm
+	{
 		'amend': 0,
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'permlevel': 1,
+		'read': 1,
 		'role': 'Sales Manager',
 		'submit': 0,
 		'write': 0
@@ -78,8 +85,8 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 2,
 		'permlevel': 0,
+		'read': 1,
 		'role': 'Sales Manager',
 		'submit': 1,
 		'write': 1
@@ -91,8 +98,8 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 3,
 		'permlevel': 0,
+		'read': 1,
 		'role': 'Sales User',
 		'submit': 1,
 		'write': 1
@@ -104,8 +111,8 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 4,
 		'permlevel': 1,
+		'read': 1,
 		'role': 'Sales User',
 		'submit': 0,
 		'write': 0
@@ -114,9 +121,9 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 5,
 		'match': 'customer_name',
 		'permlevel': 0,
+		'read': 1,
 		'role': 'Customer'
 	},
 
@@ -126,8 +133,8 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 6,
 		'permlevel': 0,
+		'read': 1,
 		'role': 'Maintenance Manager',
 		'submit': 1,
 		'write': 1
@@ -136,8 +143,8 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 7,
 		'permlevel': 1,
+		'read': 1,
 		'role': 'Maintenance Manager'
 	},
 
@@ -147,8 +154,8 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 8,
 		'permlevel': 0,
+		'read': 1,
 		'role': 'Maintenance User',
 		'submit': 1,
 		'write': 1
@@ -157,8 +164,8 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 9,
 		'permlevel': 1,
+		'read': 1,
 		'role': 'Maintenance User'
 	},
 
@@ -167,7 +174,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Basic Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -178,7 +184,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 2,
 		'permlevel': 0,
 		'width': '50%'
 	},
@@ -190,7 +195,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'naming_series',
 		'fieldtype': 'Select',
-		'idx': 3,
 		'label': 'Series',
 		'no_copy': 1,
 		'oldfieldname': 'naming_series',
@@ -207,7 +211,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'quotation_to',
 		'fieldtype': 'Select',
-		'idx': 4,
 		'in_filter': 1,
 		'label': 'Quotation To',
 		'oldfieldname': 'quotation_to',
@@ -227,7 +230,6 @@
 		'fieldname': 'customer',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 5,
 		'in_filter': 1,
 		'label': 'Customer',
 		'oldfieldname': 'customer',
@@ -246,7 +248,6 @@
 		'fieldname': 'customer_address',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 6,
 		'in_filter': 1,
 		'label': 'Customer Address',
 		'options': 'Address',
@@ -262,7 +263,6 @@
 		'fieldname': 'contact_person',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 7,
 		'in_filter': 1,
 		'label': 'Contact Person',
 		'oldfieldname': 'contact_person',
@@ -279,7 +279,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_name',
 		'fieldtype': 'Data',
-		'idx': 8,
 		'label': 'Name',
 		'permlevel': 1
 	},
@@ -291,7 +290,6 @@
 		'fieldname': 'lead',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 9,
 		'in_filter': 1,
 		'label': 'Lead',
 		'oldfieldname': 'lead',
@@ -308,7 +306,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'lead_name',
 		'fieldtype': 'Text',
-		'idx': 10,
 		'label': 'Name',
 		'permlevel': 1
 	},
@@ -320,7 +317,6 @@
 		'fieldname': 'address_display',
 		'fieldtype': 'Small Text',
 		'hidden': 0,
-		'idx': 11,
 		'in_filter': 0,
 		'label': 'Address',
 		'oldfieldname': 'customer_address',
@@ -337,7 +333,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_display',
 		'fieldtype': 'Small Text',
-		'idx': 12,
 		'in_filter': 0,
 		'label': 'Contact',
 		'permlevel': 1,
@@ -351,7 +346,6 @@
 		'fieldname': 'contact_mobile',
 		'fieldtype': 'Text',
 		'hidden': 0,
-		'idx': 13,
 		'label': 'Mobile No',
 		'permlevel': 1,
 		'print_hide': 0
@@ -363,7 +357,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_email',
 		'fieldtype': 'Text',
-		'idx': 14,
 		'label': 'Contact Email',
 		'permlevel': 1,
 		'print_hide': 1
@@ -374,7 +367,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 15,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -387,7 +379,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'transaction_date',
 		'fieldtype': 'Date',
-		'idx': 16,
 		'in_filter': 1,
 		'label': 'Quotation Date',
 		'no_copy': 1,
@@ -405,7 +396,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'order_type',
 		'fieldtype': 'Select',
-		'idx': 17,
 		'in_filter': 1,
 		'label': 'Order Type',
 		'oldfieldname': 'order_type',
@@ -425,7 +415,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'status',
 		'fieldtype': 'Select',
-		'idx': 18,
 		'in_filter': 1,
 		'label': 'Status',
 		'no_copy': 1,
@@ -443,7 +432,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'amended_from',
 		'fieldtype': 'Data',
-		'idx': 19,
 		'label': 'Amended From',
 		'no_copy': 1,
 		'oldfieldname': 'amended_from',
@@ -459,7 +447,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'amendment_date',
 		'fieldtype': 'Date',
-		'idx': 20,
 		'label': 'Amendment Date',
 		'no_copy': 1,
 		'oldfieldname': 'amendment_date',
@@ -477,7 +464,6 @@
 		'fieldname': 'enq_no',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 21,
 		'in_filter': 1,
 		'label': 'Enquiry No',
 		'no_copy': 0,
@@ -495,7 +481,6 @@
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
 		'hidden': 0,
-		'idx': 22,
 		'label': 'Pull Enquiry Detail',
 		'no_copy': 0,
 		'oldfieldtype': 'Button',
@@ -513,7 +498,6 @@
 		'fieldname': 'territory',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 23,
 		'in_filter': 1,
 		'label': 'Territory',
 		'options': 'Territory',
@@ -530,7 +514,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_group',
 		'fieldtype': 'Link',
-		'idx': 24,
 		'in_filter': 1,
 		'label': 'Customer Group',
 		'oldfieldname': 'customer_group',
@@ -548,7 +531,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 25,
 		'label': 'Items',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -558,24 +540,11 @@
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'idx': 26,
-		'label': 'Clear Table',
-		'oldfieldtype': 'Button',
-		'options': 'clear_quotation_details',
-		'permlevel': 0,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
 		'colour': 'White:FFF',
 		'description': 'Select the price list as entered in "Price List" master. This will pull the reference rates of items against this price list as specified in "Item" master.',
 		'doctype': 'DocField',
 		'fieldname': 'price_list_name',
 		'fieldtype': 'Select',
-		'idx': 27,
 		'in_filter': 1,
 		'label': 'Price List',
 		'oldfieldname': 'price_list_name',
@@ -591,9 +560,33 @@
 
 	# DocField
 	{
+		'colour': 'White:FFF',
+		'description': 'Select the currency in which price list is maintained',
+		'doctype': 'DocField',
+		'fieldname': 'price_list_currency',
+		'fieldtype': 'Select',
+		'label': 'Price List Currency',
+		'options': 'link:Currency',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Rate at which Price list currency is converted to your currency',
+		'doctype': 'DocField',
+		'fieldname': 'plc_conversion_rate',
+		'fieldtype': 'Currency',
+		'label': 'Price List Currency Conversion Rate',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 28,
 		'permlevel': 0,
 		'width': '50%'
 	},
@@ -605,7 +598,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'currency',
 		'fieldtype': 'Select',
-		'idx': 29,
 		'in_filter': 1,
 		'label': 'Currency',
 		'oldfieldname': 'currency',
@@ -627,7 +619,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'conversion_rate',
 		'fieldtype': 'Currency',
-		'idx': 30,
 		'label': 'Currency Conversion Rate',
 		'oldfieldname': 'conversion_rate',
 		'oldfieldtype': 'Currency',
@@ -641,8 +632,18 @@
 	# DocField
 	{
 		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'label': 'Clear Table',
+		'oldfieldtype': 'Button',
+		'options': 'clear_quotation_details',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 31,
 		'options': 'Simple',
 		'permlevel': 0
 	},
@@ -655,7 +656,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'quotation_details',
 		'fieldtype': 'Table',
-		'idx': 32,
 		'label': 'Quotation Details',
 		'oldfieldname': 'quotation_details',
 		'oldfieldtype': 'Table',
@@ -669,7 +669,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'net_total',
 		'fieldtype': 'Currency',
-		'idx': 33,
 		'label': 'Net Total*',
 		'no_copy': 0,
 		'oldfieldname': 'net_total',
@@ -684,7 +683,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 34,
 		'label': 'Re-Calculate Values',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -697,7 +695,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 35,
 		'label': 'Note HTML',
 		'oldfieldtype': 'HTML',
 		'options': '<div style="margin-top:16px"><b>Note :</b> * In Base Currency\n</div>',
@@ -710,7 +707,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 36,
 		'label': 'Taxes',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -722,7 +718,6 @@
 		'fieldname': 'charge',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 37,
 		'label': 'Select Charges Master',
 		'oldfieldname': 'charge',
 		'oldfieldtype': 'Link',
@@ -737,7 +732,6 @@
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
 		'hidden': 0,
-		'idx': 38,
 		'label': 'Get Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -750,7 +744,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'other_charges',
 		'fieldtype': 'Table',
-		'idx': 39,
 		'label': 'Other Charges',
 		'oldfieldname': 'other_charges',
 		'oldfieldtype': 'Table',
@@ -763,7 +756,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 40,
 		'label': 'Calculate Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -776,7 +768,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'other_charges_total',
 		'fieldtype': 'Currency',
-		'idx': 41,
 		'label': 'Charges Total*',
 		'oldfieldname': 'other_charges_total',
 		'oldfieldtype': 'Currency',
@@ -789,7 +780,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total',
 		'fieldtype': 'Currency',
-		'idx': 42,
 		'label': 'Grand Total*',
 		'no_copy': 0,
 		'oldfieldname': 'grand_total',
@@ -804,7 +794,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 43,
 		'label': 'Other Charges Calculation',
 		'oldfieldtype': 'HTML',
 		'permlevel': 0,
@@ -815,7 +804,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 44,
 		'label': 'OT Notes',
 		'oldfieldtype': 'HTML',
 		'options': '<div style="margin-top:16px"><b>Note :</b> * In Base Currency\n</div>',
@@ -828,7 +816,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 45,
 		'label': 'Totals',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -840,7 +827,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total',
 		'fieldtype': 'Currency',
-		'idx': 46,
 		'label': 'Rounded Total',
 		'no_copy': 0,
 		'oldfieldname': 'rounded_total',
@@ -858,7 +844,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words',
 		'fieldtype': 'Data',
-		'idx': 47,
 		'label': 'In Words',
 		'no_copy': 0,
 		'oldfieldname': 'in_words',
@@ -872,7 +857,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 48,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -884,7 +868,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total_export',
 		'fieldtype': 'Currency',
-		'idx': 49,
 		'label': 'Grand Total (Export)',
 		'no_copy': 0,
 		'oldfieldname': 'grand_total_export',
@@ -900,7 +883,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total_export',
 		'fieldtype': 'Currency',
-		'idx': 50,
 		'label': 'Rounded Total (Export)',
 		'no_copy': 0,
 		'oldfieldname': 'rounded_total_export',
@@ -918,7 +900,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words_export',
 		'fieldtype': 'Data',
-		'idx': 51,
 		'label': 'In Words (Export)',
 		'no_copy': 0,
 		'oldfieldname': 'in_words_export',
@@ -934,7 +915,6 @@
 		'description': 'Add Terms and Conditions for the Quotation like Payment Terms, Validity of Offer etc. You can also prepare a master Term Sheet and use the Template',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 52,
 		'label': 'Terms',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -947,7 +927,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'letter_head',
 		'fieldtype': 'Select',
-		'idx': 53,
 		'label': 'Letter Head',
 		'oldfieldname': 'letter_head',
 		'oldfieldtype': 'Select',
@@ -961,7 +940,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'tc_name',
 		'fieldtype': 'Link',
-		'idx': 54,
 		'label': 'Select Terms',
 		'oldfieldname': 'tc_name',
 		'oldfieldtype': 'Link',
@@ -975,7 +953,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 55,
 		'label': 'Get Terms',
 		'oldfieldtype': 'Button',
 		'options': 'get_tc_details',
@@ -986,7 +963,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 56,
 		'label': 'Terms HTML',
 		'oldfieldtype': 'HTML',
 		'options': 'You can add Terms and Notes that will be printed in the Transaction',
@@ -999,7 +975,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'terms',
 		'fieldtype': 'Text Editor',
-		'idx': 57,
 		'label': 'Term Details',
 		'oldfieldname': 'terms',
 		'oldfieldtype': 'Text Editor',
@@ -1012,7 +987,6 @@
 		'description': 'Filling in additional information about the Quotation will help you analyze your data better.',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 58,
 		'label': 'More Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1026,7 +1000,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'company',
 		'fieldtype': 'Link',
-		'idx': 59,
 		'in_filter': 1,
 		'label': 'Company',
 		'oldfieldname': 'company',
@@ -1046,7 +1019,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'fiscal_year',
 		'fieldtype': 'Select',
-		'idx': 60,
 		'in_filter': 1,
 		'label': 'Fiscal Year',
 		'oldfieldname': 'fiscal_year',
@@ -1065,7 +1037,6 @@
 		'fieldname': 'enq_det',
 		'fieldtype': 'Text',
 		'hidden': 1,
-		'idx': 61,
 		'label': 'Enquiry Detail',
 		'no_copy': 0,
 		'oldfieldname': 'enq_det',
@@ -1082,7 +1053,6 @@
 		'fieldname': 'source',
 		'fieldtype': 'Select',
 		'hidden': 0,
-		'idx': 62,
 		'label': 'Source',
 		'no_copy': 0,
 		'oldfieldname': 'source',
@@ -1100,7 +1070,6 @@
 		'fieldname': 'campaign',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 63,
 		'label': 'Campaign',
 		'no_copy': 0,
 		'oldfieldname': 'campaign',
@@ -1117,7 +1086,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'select_print_heading',
 		'fieldtype': 'Link',
-		'idx': 64,
 		'label': 'Select Print Heading',
 		'no_copy': 1,
 		'oldfieldname': 'select_print_heading',
@@ -1134,7 +1102,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'cancel_reason',
 		'fieldtype': 'Data',
-		'idx': 65,
 		'label': 'Cancel Reason',
 		'no_copy': 1,
 		'oldfieldname': 'cancel_reason',
@@ -1150,7 +1117,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'order_lost_reason',
 		'fieldtype': 'Small Text',
-		'idx': 66,
 		'label': 'Order Lost Reason',
 		'no_copy': 1,
 		'oldfieldname': 'order_lost_reason',
@@ -1163,7 +1129,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 67,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1176,7 +1141,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_by',
 		'fieldtype': 'Link',
-		'idx': 68,
 		'label': 'Next Contact By',
 		'oldfieldname': 'contact_by',
 		'oldfieldtype': 'Link',
@@ -1191,7 +1155,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_date',
 		'fieldtype': 'Date',
-		'idx': 69,
 		'label': 'Next Contact Date',
 		'oldfieldname': 'contact_date',
 		'oldfieldtype': 'Date',
@@ -1206,7 +1169,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'last_contact_date',
 		'fieldtype': 'Date',
-		'idx': 70,
 		'label': 'Last Contact Date',
 		'no_copy': 1,
 		'oldfieldname': 'last_contact_date',
@@ -1220,7 +1182,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'to_discuss',
 		'fieldtype': 'Small Text',
-		'idx': 71,
 		'label': 'To Discuss',
 		'oldfieldname': 'to_discuss',
 		'oldfieldtype': 'Small Text',
@@ -1234,7 +1195,6 @@
 		'description': 'Keep a track on communications regarding this Quotation. This will help you remember earlier communications in case the Customer comes back again',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 72,
 		'label': 'Communication History',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1248,7 +1208,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'follow_up',
 		'fieldtype': 'Table',
-		'idx': 73,
 		'label': 'Follow up',
 		'oldfieldname': 'follow_up',
 		'oldfieldtype': 'Table',
@@ -1265,7 +1224,6 @@
 		'fieldname': 'file_list',
 		'fieldtype': 'Small Text',
 		'hidden': 1,
-		'idx': 74,
 		'label': 'File List',
 		'no_copy': 1,
 		'permlevel': 0,
diff --git a/erpnext/selling/doctype/sales_common/sales_common.js b/erpnext/selling/doctype/sales_common/sales_common.js
index f4b3f02..23e0420 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.js
+++ b/erpnext/selling/doctype/sales_common/sales_common.js
@@ -19,9 +19,10 @@
 // -----------------
 // Shipping Address
 // -----------------
-//cur_frm.add_fetch('ship_det_no', 'shipping_address', 'shipping_address');
-//cur_frm.add_fetch('ship_det_no', 'ship_to', 'ship_to');
+
 cur_frm.add_fetch('company', 'default_currency', 'currency');
+cur_frm.add_fetch('company', 'default_currency', 'price_list_currency');
+
 
 
 // ============== Customer and its primary contact Details ============================
@@ -59,15 +60,6 @@
 	loadpage('Sales Browser',call_back);
 }
 
-/*
-// ============= Customer's Contact Person Details =====================================
-cur_frm.cscript.contact_person = function(doc, cdt, cdn) {
-  var callback = function(){
-    refresh_many(['contact_no','email_id','customer_mobile_no','customer_address']);
-  }
-  get_server_fields('get_contact_details','','',doc, cdt, cdn, 1, callback);
-}
-*/
 
 // TRIGGERS FOR CALCULATIONS
 // =====================================================================================================
@@ -77,10 +69,17 @@
 	cur_frm.cscript.price_list_name(doc, cdt, cdn);
 }
 
+cur_frm.cscript.price_list_currency = cur_frm.cscript.currency;
+cur_frm.cscript.conversion_rate = cur_frm.cscript.currency;
+cur_frm.cscript.plc_conversion_rate = cur_frm.cscript.currency;
+
+
+
 // ******************** PRICE LIST ******************************
 cur_frm.cscript.price_list_name = function(doc, cdt, cdn) {
   var fname = cur_frm.cscript.fname;
-  if(doc.price_list_name && doc.currency) {
+  var cl = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname);
+  if(doc.price_list_name && doc.currency && doc.price_list_currency && doc.conversion_rate && doc.plc_conversion_rate && cl.length) {
     $c_obj(make_doclist(doc.doctype, doc.name), 'get_adj_percent', '',
       function(r, rt) {
         refresh_field(fname);
@@ -92,8 +91,6 @@
 }
 
 
-// ******************* CONVERSION RATE ***************************
-cur_frm.cscript.conversion_rate = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 3);/*cur_frm.cscript.price_list_name(doc, cdt, cdn);*/ }
 
 // ******************** ITEM CODE ******************************** 
 cur_frm.fields_dict[cur_frm.cscript.fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
@@ -104,7 +101,6 @@
 }
 
 
-
 cur_frm.cscript.item_code = function(doc, cdt, cdn) {
   var fname = cur_frm.cscript.fname;
   var d = locals[cdt][cdn];
@@ -125,6 +121,7 @@
   }
 }
 
+
 // *********************** QUANTITY ***************************
 cur_frm.cscript.qty = function(doc, cdt, cdn) { cur_frm.cscript.recalc(doc, 1); }
   
@@ -154,6 +151,8 @@
 // ************************ EXPORT RATE *************************
 cur_frm.cscript.export_rate = function(doc,cdt,cdn) { cur_frm.cscript.recalc(doc, 3);}
 
+
+
 // ************* GET OTHER CHARGES BASED ON COMPANY *************
 cur_frm.fields_dict.charge.get_query = function(doc) {
   return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.docstatus != 2 AND `tabOther Charges`.%(key)s LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
@@ -176,6 +175,7 @@
   var other_fname  = cur_frm.cscript.other_fname;
   
   if(!flt(doc.conversion_rate)) { doc.conversion_rate = 1; refresh_field('conversion_rate'); }
+  if(!flt(doc.plc_conversion_rate)) { doc.plc_conversion_rate = 1; refresh_field('plc_conversion_rate'); }
 
   if(n > 0) cur_frm.cscript.update_fname_table(doc , tname , fname , n); // updates all values in table (i.e. amount, export amount, net total etc.)
   
@@ -367,7 +367,7 @@
       set_multiple(tname, cl[i].name, {'basic_rate': flt(flt(cl[i].export_rate) * flt(doc.conversion_rate))}, fname);
       set_multiple(tname, cl[i].name, {'amount' : flt(flt(cl[i].basic_rate) * flt(cl[i].qty)), 'export_amount': flt(flt(cl[i].export_rate) * flt(cl[i].qty))}, fname);
       if(cl[i].ref_rate > 0)
-        set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].export_rate) * 100 / flt(cl[i].ref_rate)), 'base_ref_rate': flt(flt(cl[i].ref_rate) * flt(doc.conversion_rate)) }, fname);
+		set_multiple(tname, cl[i].name, {'adj_rate': 100 - flt(flt(cl[i].export_rate) * 100 / flt(cl[i].ref_rate)), 'base_ref_rate': flt(flt(cl[i].ref_rate) * flt(doc.conversion_rate)) }, fname);
     }
     net_total += flt(flt(cl[i].qty) * flt(cl[i].basic_rate));
   }
diff --git a/erpnext/selling/doctype/sales_common/sales_common.py b/erpnext/selling/doctype/sales_common/sales_common.py
index 78454ee..ea9ffe9 100644
--- a/erpnext/selling/doctype/sales_common/sales_common.py
+++ b/erpnext/selling/doctype/sales_common/sales_common.py
@@ -135,32 +135,31 @@
 			'batch_no'				: ''
 		}
 		if(obj.doc.price_list_name and item):	#this is done to fetch the changed BASIC RATE and REF RATE based on PRICE LIST
-			ref_rate =	self.get_ref_rate(item_code, obj.doc.price_list_name, obj.doc.currency)
-			ret['ref_rate'] = flt(ref_rate)
-			ret['export_rate'] = flt(ref_rate)
-			ret['base_ref_rate'] = flt(ref_rate) * flt(obj.doc.conversion_rate)
-			ret['basic_rate'] = flt(ref_rate) * flt(obj.doc.conversion_rate)
-			
-		if obj.doc.doctype == 'Receivable Voucher':
-			return ret
-			
+			base_ref_rate =	self.get_ref_rate(item_code, obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
+			ret['ref_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
+			ret['export_rate'] = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
+			ret['base_ref_rate'] = flt(base_ref_rate)
+			ret['basic_rate'] = flt(base_ref_rate)
+
 		return ret
 	
 	# ***************** Get Ref rate as entered in Item Master ********************
-	def get_ref_rate(self, item_code, price_list_name, currency):
-		ref_rate = sql("select ref_rate from `tabRef Rate Detail` where parent = %s and price_list_name = %s and ref_currency = %s", (item_code, price_list_name, currency))
-		return ref_rate and ref_rate[0][0] or 0
+	def get_ref_rate(self, item_code, price_list_name, price_list_currency, plc_conv_rate):
+		ref_rate = sql("select ref_rate from `tabRef Rate Detail` where parent = %s and price_list_name = %s and ref_currency = %s", (item_code, price_list_name, price_list_currency))
+		base_ref_rate = ref_rate and flt(ref_rate[0][0]) * flt(plc_conv_rate) or 0
+		return base_ref_rate
 
 		
-	# ****** Re-calculates Basic Rate & amount based on Price List Selected ******
+	# ****** Re-cancellculates Basic Rate & amount based on Price List Selected ******
 	def get_adj_percent(self, obj): 
 		for d in getlist(obj.doclist, obj.fname):
-			ref_rate = self.get_ref_rate(d.item_code,obj.doc.price_list_name,obj.doc.currency)
+			base_ref_rate = self.get_ref_rate(d.item_code, obj.doc.price_list_name, obj.doc.price_list_currency, obj.doc.plc_conversion_rate)
 			d.adj_rate = 0
-			d.ref_rate = flt(ref_rate)
-			d.basic_rate = flt(ref_rate) * flt(obj.doc.conversion_rate)
-			d.base_ref_rate = flt(ref_rate) * flt(obj.doc.conversion_rate)
-			d.export_rate = flt(ref_rate)
+			d.ref_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
+			d.basic_rate = flt(base_ref_rate)
+			d.base_ref_rate = flt(base_ref_rate)
+			d.export_rate = flt(base_ref_rate)/flt(obj.doc.conversion_rate)
+
 
 	# Load Default Taxes
 	# ====================
@@ -268,9 +267,12 @@
 			msgprint('Message: Please enter default currency in Company Master')
 			raise Exception		
 		if (obj.doc.currency == default_currency and flt(obj.doc.conversion_rate) != 1.00) or not obj.doc.conversion_rate or (obj.doc.currency != default_currency and flt(obj.doc.conversion_rate) == 1.00):
-			msgprint("Please Enter Appropriate Conversion Rate.")
-			raise Exception
+			msgprint("Please Enter Appropriate Conversion Rate for Customer's Currency to Base Currency (%s --> %s)" % (obj.doc.currency, default_currency), raise_exception = 1)
 	
+		if (obj.doc.price_list_currency == default_currency and flt(obj.doc.plc_conversion_rate) != 1.00) or not obj.doc.plc_conversion_rate or (obj.doc.price_list_currency != default_currency and flt(obj.doc.plc_conversion_rate) == 1.00):
+			msgprint("Please Enter Appropriate Conversion Rate for Price List Currency to Base Currency ( (%s --> %s)" % (obj.doc.price_list_currency, default_currency), raise_exception = 1)
+	
+
 
 	# Get Tax rate if account type is TAX
 	# =========================================================================
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index e684bed..949abcd 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -16,6 +16,7 @@
 cur_frm.cscript.onload = function(doc, cdt, cdn) {
   if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
   if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
+  if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
   // load default charges
   
   if(doc.__islocal){
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index ca5af7a..72245eb 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -446,7 +446,7 @@
 				if not d[0]:
 					msgprint("Message: Please enter Reserved Warehouse for item %s as it is stock item."% d[1])
 					raise Exception
-				bin = get_obj('Warehouse', d[0]).update_bin( 0, flt(update_stock) * flt(d[2]), 0, 0, 0, d[1], self.doc.transaction_date)
+				bin = get_obj('Warehouse', d[0]).update_bin( 0, flt(update_stock) * flt(d[2]), 0, 0, 0, d[1], self.doc.transaction_date,doc_type=self.doc.doctype,doc_name=self.doc.name, is_amended = (self.doc.amended_from and 'Yes' or 'No'))
 	
 	# Gets Items from packing list
 	#=================================
diff --git a/erpnext/selling/doctype/sales_order/sales_order.txt b/erpnext/selling/doctype/sales_order/sales_order.txt
index 98833d1..d59f236 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.txt
+++ b/erpnext/selling/doctype/sales_order/sales_order.txt
@@ -5,15 +5,17 @@
 	{
 		'creation': '2010-08-08 17:09:21',
 		'docstatus': 0,
-		'modified': '2011-08-09 17:06:09',
+		'modified': '2011-12-20 12:55:02',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1311621379',
+		'_last_update': '1324295218',
+		'allow_attach': 0,
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'document_type': 'Transaction',
 		'is_transaction_doc': 1,
@@ -27,7 +29,7 @@
 		'show_in_menu': 0,
 		'subject': 'From %(customer_name)s on %(transaction_date)s worth %(currency)s %(grand_total_export)s | %(per_delivered)s% delivered | %(per_billed)s% billed',
 		'tag_fields': 'delivery_status,billing_status',
-		'version': 597
+		'version': 608
 	},
 
 	# These values are common for all DocField
@@ -58,7 +60,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'permlevel': 0,
 		'role': 'Production Manager'
 	},
@@ -69,7 +70,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 2,
 		'permlevel': 1,
 		'role': 'Sales Manager',
 		'submit': 0,
@@ -82,7 +82,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 3,
 		'permlevel': 0,
 		'role': 'Sales Manager',
 		'submit': 1,
@@ -95,7 +94,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 4,
 		'permlevel': 0,
 		'role': 'Sales User',
 		'submit': 1,
@@ -108,7 +106,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 5,
 		'permlevel': 1,
 		'role': 'Sales User',
 		'submit': 0,
@@ -118,7 +115,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 6,
 		'match': 'customer_name',
 		'permlevel': 0,
 		'role': 'Customer'
@@ -127,7 +123,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 7,
 		'permlevel': 2,
 		'role': 'Accounts User',
 		'write': 1
@@ -139,7 +134,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 8,
 		'permlevel': 0,
 		'role': 'Maintenance Manager',
 		'submit': 1,
@@ -149,7 +143,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 9,
 		'permlevel': 1,
 		'role': 'Maintenance Manager'
 	},
@@ -160,7 +153,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 10,
 		'permlevel': 0,
 		'role': 'Maintenance User',
 		'submit': 1,
@@ -170,7 +162,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 11,
 		'permlevel': 1,
 		'role': 'Maintenance User'
 	},
@@ -180,7 +171,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Basic Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -191,7 +181,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 2,
 		'in_filter': 0,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
@@ -206,7 +195,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'naming_series',
 		'fieldtype': 'Select',
-		'idx': 3,
 		'label': 'Series',
 		'no_copy': 1,
 		'oldfieldname': 'naming_series',
@@ -224,7 +212,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer',
 		'fieldtype': 'Link',
-		'idx': 4,
 		'in_filter': 1,
 		'label': 'Customer',
 		'oldfieldname': 'customer',
@@ -243,7 +230,6 @@
 		'fieldname': 'customer_address',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 5,
 		'in_filter': 1,
 		'label': 'Customer Address',
 		'options': 'Address',
@@ -256,7 +242,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_person',
 		'fieldtype': 'Link',
-		'idx': 6,
 		'in_filter': 1,
 		'label': 'Contact Person',
 		'options': 'Contact',
@@ -269,7 +254,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_name',
 		'fieldtype': 'Data',
-		'idx': 7,
 		'label': 'Name',
 		'permlevel': 1
 	},
@@ -279,7 +263,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'address_display',
 		'fieldtype': 'Small Text',
-		'idx': 8,
 		'label': 'Address',
 		'permlevel': 1
 	},
@@ -289,7 +272,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_display',
 		'fieldtype': 'Small Text',
-		'idx': 9,
 		'label': 'Contact',
 		'permlevel': 1
 	},
@@ -299,7 +281,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_mobile',
 		'fieldtype': 'Text',
-		'idx': 10,
 		'label': 'Mobile No',
 		'permlevel': 1
 	},
@@ -309,7 +290,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'contact_email',
 		'fieldtype': 'Text',
-		'idx': 11,
 		'label': 'Contact Email',
 		'permlevel': 1,
 		'print_hide': 1
@@ -320,7 +300,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'territory',
 		'fieldtype': 'Link',
-		'idx': 12,
 		'in_filter': 1,
 		'label': 'Territory',
 		'options': 'Territory',
@@ -336,7 +315,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_group',
 		'fieldtype': 'Link',
-		'idx': 13,
 		'in_filter': 1,
 		'label': 'Customer Group',
 		'options': 'Customer Group',
@@ -354,7 +332,6 @@
 		'fieldname': 'po_no',
 		'fieldtype': 'Data',
 		'hidden': 0,
-		'idx': 14,
 		'label': 'P.O. No',
 		'oldfieldname': 'po_no',
 		'oldfieldtype': 'Data',
@@ -370,7 +347,6 @@
 		'fieldname': 'po_date',
 		'fieldtype': 'Date',
 		'hidden': 0,
-		'idx': 15,
 		'label': 'P.O. Date',
 		'oldfieldname': 'po_date',
 		'oldfieldtype': 'Date',
@@ -384,7 +360,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 16,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -397,7 +372,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'transaction_date',
 		'fieldtype': 'Date',
-		'idx': 17,
 		'in_filter': 1,
 		'label': 'Sales Order Date',
 		'no_copy': 1,
@@ -416,7 +390,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'order_type',
 		'fieldtype': 'Select',
-		'idx': 18,
 		'label': 'Order Type',
 		'oldfieldname': 'order_type',
 		'oldfieldtype': 'Select',
@@ -431,7 +404,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'status',
 		'fieldtype': 'Select',
-		'idx': 19,
 		'in_filter': 1,
 		'label': 'Status',
 		'no_copy': 1,
@@ -452,7 +424,6 @@
 		'fieldname': 'delivery_date',
 		'fieldtype': 'Date',
 		'hidden': 0,
-		'idx': 20,
 		'in_filter': 1,
 		'label': 'Expected Delivery Date',
 		'oldfieldname': 'delivery_date',
@@ -471,7 +442,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'project_name',
 		'fieldtype': 'Link',
-		'idx': 21,
 		'in_filter': 1,
 		'label': 'Project Name',
 		'oldfieldname': 'project_name',
@@ -490,7 +460,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'per_delivered',
 		'fieldtype': 'Currency',
-		'idx': 22,
 		'in_filter': 1,
 		'label': '%  Delivered',
 		'no_copy': 1,
@@ -509,7 +478,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'per_billed',
 		'fieldtype': 'Currency',
-		'idx': 23,
 		'in_filter': 1,
 		'label': '% Amount Billed',
 		'no_copy': 1,
@@ -526,7 +494,6 @@
 		'fieldname': 'amended_from',
 		'fieldtype': 'Data',
 		'hidden': 1,
-		'idx': 24,
 		'label': 'Amended From',
 		'no_copy': 1,
 		'oldfieldname': 'amended_from',
@@ -544,7 +511,6 @@
 		'fieldname': 'amendment_date',
 		'fieldtype': 'Date',
 		'hidden': 1,
-		'idx': 25,
 		'label': 'Amendment Date',
 		'no_copy': 1,
 		'oldfieldname': 'amendment_date',
@@ -560,7 +526,6 @@
 		'fieldname': 'shipping_address_name',
 		'fieldtype': 'Data',
 		'hidden': 1,
-		'idx': 26,
 		'in_filter': 1,
 		'label': 'Shipping Address Name',
 		'options': 'Address',
@@ -573,7 +538,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'shipping_address',
 		'fieldtype': 'Small Text',
-		'idx': 27,
 		'in_filter': 0,
 		'label': 'Shipping Address',
 		'permlevel': 1,
@@ -585,7 +549,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 28,
 		'label': 'Items',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -594,72 +557,10 @@
 	# DocField
 	{
 		'colour': 'White:FFF',
-		'description': 'Quotation no against which this Sales Order is made ',
-		'doctype': 'DocField',
-		'fieldname': 'quotation_no',
-		'fieldtype': 'Link',
-		'idx': 29,
-		'in_filter': 1,
-		'label': 'Quotation No',
-		'no_copy': 0,
-		'oldfieldname': 'quotation_no',
-		'oldfieldtype': 'Link',
-		'options': 'Quotation',
-		'permlevel': 0,
-		'print_hide': 1,
-		'search_index': 1,
-		'trigger': 'Client',
-		'width': '150px'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'vehicle_detail',
-		'fieldtype': 'Small Text',
-		'idx': 30,
-		'label': 'Vehicle Detail',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldname': 'quotation_date',
-		'fieldtype': 'Date',
-		'hidden': 1,
-		'idx': 31,
-		'label': 'Quotation Date',
-		'no_copy': 0,
-		'oldfieldname': 'quotation_date',
-		'oldfieldtype': 'Date',
-		'permlevel': 1,
-		'print_hide': 1,
-		'reqd': 0,
-		'width': '100px'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'idx': 32,
-		'label': 'Pull Quotation Details',
-		'oldfieldtype': 'Button',
-		'options': 'pull_quotation_details',
-		'permlevel': 0,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
 		'description': 'Select the price list as entered in "Price List" master. This will pull the reference rates of items against this price list as specified in "Item" master.',
 		'doctype': 'DocField',
 		'fieldname': 'price_list_name',
 		'fieldtype': 'Select',
-		'idx': 33,
 		'label': 'Price List',
 		'oldfieldname': 'price_list_name',
 		'oldfieldtype': 'Select',
@@ -673,9 +574,32 @@
 
 	# DocField
 	{
+		'description': 'Select the currency in which price list is maintained',
+		'doctype': 'DocField',
+		'fieldname': 'price_list_currency',
+		'fieldtype': 'Select',
+		'label': 'Price List Currency',
+		'options': 'link:Currency',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Rate at which Price list currency is converted to your currency',
+		'doctype': 'DocField',
+		'fieldname': 'plc_conversion_rate',
+		'fieldtype': 'Currency',
+		'label': 'Price List Currency Conversion Rate',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 34,
 		'permlevel': 0,
 		'width': '50%'
 	},
@@ -687,8 +611,7 @@
 		'doctype': 'DocField',
 		'fieldname': 'currency',
 		'fieldtype': 'Select',
-		'idx': 35,
-		'label': 'Currency',
+		'label': "Customer's Currency",
 		'oldfieldname': 'currency',
 		'oldfieldtype': 'Select',
 		'options': 'link:Currency',
@@ -706,7 +629,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'conversion_rate',
 		'fieldtype': 'Currency',
-		'idx': 36,
 		'label': 'Conversion Rate',
 		'oldfieldname': 'conversion_rate',
 		'oldfieldtype': 'Currency',
@@ -719,9 +641,56 @@
 
 	# DocField
 	{
+		'colour': 'White:FFF',
+		'description': 'Quotation no against which this Sales Order is made ',
+		'doctype': 'DocField',
+		'fieldname': 'quotation_no',
+		'fieldtype': 'Link',
+		'in_filter': 1,
+		'label': 'Quotation No',
+		'no_copy': 0,
+		'oldfieldname': 'quotation_no',
+		'oldfieldtype': 'Link',
+		'options': 'Quotation',
+		'permlevel': 0,
+		'print_hide': 1,
+		'search_index': 1,
+		'trigger': 'Client',
+		'width': '150px'
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'doctype': 'DocField',
+		'fieldname': 'quotation_date',
+		'fieldtype': 'Date',
+		'hidden': 1,
+		'label': 'Quotation Date',
+		'no_copy': 0,
+		'oldfieldname': 'quotation_date',
+		'oldfieldtype': 'Date',
+		'permlevel': 1,
+		'print_hide': 1,
+		'reqd': 0,
+		'width': '100px'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'label': 'Pull Quotation Details',
+		'oldfieldtype': 'Button',
+		'options': 'pull_quotation_details',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 37,
 		'permlevel': 0
 	},
 
@@ -732,7 +701,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_order_details',
 		'fieldtype': 'Table',
-		'idx': 38,
 		'label': 'Sales Order Details',
 		'oldfieldname': 'sales_order_details',
 		'oldfieldtype': 'Table',
@@ -746,7 +714,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 39,
 		'label': 'Clear Table',
 		'oldfieldtype': 'Button',
 		'options': 'clear_sales_order_details',
@@ -758,7 +725,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 40,
 		'label': 'Re-Calculate Values',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -772,7 +738,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'net_total',
 		'fieldtype': 'Currency',
-		'idx': 41,
 		'label': 'Net Total*',
 		'oldfieldname': 'net_total',
 		'oldfieldtype': 'Currency',
@@ -787,7 +752,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 42,
 		'label': 'Note1',
 		'oldfieldtype': 'HTML',
 		'options': '<b>NOTE :</b> * In Base Currency',
@@ -800,7 +764,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 43,
 		'label': 'Taxes',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -812,7 +775,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'charge',
 		'fieldtype': 'Link',
-		'idx': 44,
 		'label': 'Select Charges Master',
 		'oldfieldname': 'charge',
 		'oldfieldtype': 'Link',
@@ -825,7 +787,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 45,
 		'label': 'Get Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -837,7 +798,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'other_charges',
 		'fieldtype': 'Table',
-		'idx': 46,
 		'label': 'Other Charges',
 		'oldfieldname': 'other_charges',
 		'oldfieldtype': 'Table',
@@ -849,7 +809,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 47,
 		'label': 'Calculate Charges',
 		'oldfieldtype': 'Button',
 		'permlevel': 0,
@@ -862,7 +821,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'other_charges_total',
 		'fieldtype': 'Currency',
-		'idx': 48,
 		'label': 'Charges Total*',
 		'oldfieldname': 'other_charges_total',
 		'oldfieldtype': 'Currency',
@@ -876,7 +834,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total',
 		'fieldtype': 'Currency',
-		'idx': 49,
 		'label': 'Grand Total*',
 		'oldfieldname': 'grand_total',
 		'oldfieldtype': 'Currency',
@@ -890,7 +847,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 50,
 		'label': 'OT Notes',
 		'oldfieldtype': 'HTML',
 		'options': '<b>NOTE :</b> * In Base Currency',
@@ -902,7 +858,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 51,
 		'label': 'Other Charges Calculation',
 		'oldfieldtype': 'HTML',
 		'permlevel': 0,
@@ -914,7 +869,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 52,
 		'label': 'Totals',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -926,7 +880,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total',
 		'fieldtype': 'Currency',
-		'idx': 53,
 		'label': 'Rounded Total',
 		'oldfieldname': 'rounded_total',
 		'oldfieldtype': 'Currency',
@@ -942,7 +895,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words',
 		'fieldtype': 'Data',
-		'idx': 54,
 		'label': 'In Words',
 		'oldfieldname': 'in_words',
 		'oldfieldtype': 'Data',
@@ -955,7 +907,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 55,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -967,7 +918,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'grand_total_export',
 		'fieldtype': 'Currency',
-		'idx': 56,
 		'label': 'Grand Total (Export)',
 		'oldfieldname': 'grand_total_export',
 		'oldfieldtype': 'Currency',
@@ -982,7 +932,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'rounded_total_export',
 		'fieldtype': 'Currency',
-		'idx': 57,
 		'label': 'Rounded Total (Export)',
 		'oldfieldname': 'rounded_total_export',
 		'oldfieldtype': 'Currency',
@@ -998,7 +947,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'in_words_export',
 		'fieldtype': 'Data',
-		'idx': 58,
 		'label': 'In Words (Export)',
 		'oldfieldname': 'in_words_export',
 		'oldfieldtype': 'Data',
@@ -1012,7 +960,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 59,
 		'label': 'Terms',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1024,7 +971,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'tc_name',
 		'fieldtype': 'Link',
-		'idx': 60,
 		'label': 'Select Terms',
 		'oldfieldname': 'tc_name',
 		'oldfieldtype': 'Link',
@@ -1038,7 +984,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 61,
 		'label': 'Get Terms',
 		'oldfieldtype': 'Button',
 		'options': 'get_tc_details',
@@ -1050,7 +995,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 62,
 		'label': 'Terms HTML',
 		'oldfieldtype': 'HTML',
 		'options': 'You can add Terms and Notes that will be printed in the Transaction',
@@ -1063,7 +1007,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'terms',
 		'fieldtype': 'Text Editor',
-		'idx': 63,
 		'label': 'Term Details',
 		'oldfieldname': 'terms',
 		'oldfieldtype': 'Text Editor',
@@ -1077,7 +1020,6 @@
 		'description': 'Filling in additional information about the Sales Order will help you analyze your data better.',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 64,
 		'label': 'More Info',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1088,7 +1030,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 65,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1101,7 +1042,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'letter_head',
 		'fieldtype': 'Select',
-		'idx': 66,
 		'label': 'Letter Head',
 		'oldfieldname': 'letter_head',
 		'oldfieldtype': 'Select',
@@ -1117,7 +1057,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'company',
 		'fieldtype': 'Link',
-		'idx': 67,
 		'in_filter': 1,
 		'label': 'Company',
 		'oldfieldname': 'company',
@@ -1136,7 +1075,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'fiscal_year',
 		'fieldtype': 'Select',
-		'idx': 68,
 		'in_filter': 1,
 		'label': 'Fiscal Year',
 		'oldfieldname': 'fiscal_year',
@@ -1156,7 +1094,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'select_print_heading',
 		'fieldtype': 'Link',
-		'idx': 69,
 		'label': 'Select Print Heading',
 		'no_copy': 1,
 		'oldfieldname': 'select_print_heading',
@@ -1171,7 +1108,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 70,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'print_hide': 1,
@@ -1184,7 +1120,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'source',
 		'fieldtype': 'Select',
-		'idx': 71,
 		'label': 'Source',
 		'oldfieldname': 'source',
 		'oldfieldtype': 'Select',
@@ -1200,7 +1135,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'campaign',
 		'fieldtype': 'Link',
-		'idx': 72,
 		'label': 'Campaign',
 		'oldfieldname': 'campaign',
 		'oldfieldtype': 'Link',
@@ -1215,7 +1149,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'note',
 		'fieldtype': 'Text',
-		'idx': 73,
 		'label': 'Note',
 		'oldfieldname': 'note',
 		'oldfieldtype': 'Text',
@@ -1230,7 +1163,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'cancel_reason',
 		'fieldtype': 'Data',
-		'idx': 74,
 		'label': 'Cancel Reason',
 		'no_column': 0,
 		'no_copy': 1,
@@ -1246,7 +1178,6 @@
 		'fieldname': 'delivery_status',
 		'fieldtype': 'Select',
 		'hidden': 1,
-		'idx': 75,
 		'label': 'Delivery Status',
 		'no_column': 0,
 		'no_copy': 1,
@@ -1261,7 +1192,6 @@
 		'fieldname': 'billing_status',
 		'fieldtype': 'Select',
 		'hidden': 1,
-		'idx': 76,
 		'label': 'Billing Status',
 		'no_column': 0,
 		'no_copy': 1,
@@ -1277,7 +1207,6 @@
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
 		'hidden': 0,
-		'idx': 77,
 		'label': 'Packing List',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1290,7 +1219,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'packing_details',
 		'fieldtype': 'Table',
-		'idx': 78,
 		'label': 'Packing Details',
 		'oldfieldname': 'packing_details',
 		'oldfieldtype': 'Table',
@@ -1303,7 +1231,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 79,
 		'label': 'Sales Team',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0,
@@ -1317,7 +1244,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_partner',
 		'fieldtype': 'Link',
-		'idx': 80,
 		'in_filter': 1,
 		'label': 'Sales Partner',
 		'oldfieldname': 'sales_partner',
@@ -1335,7 +1261,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'commission_rate',
 		'fieldtype': 'Currency',
-		'idx': 81,
 		'label': 'Commission Rate',
 		'oldfieldname': 'commission_rate',
 		'oldfieldtype': 'Currency',
@@ -1350,7 +1275,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'total_commission',
 		'fieldtype': 'Currency',
-		'idx': 82,
 		'label': 'Total Commission',
 		'oldfieldname': 'total_commission',
 		'oldfieldtype': 'Currency',
@@ -1364,7 +1288,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_team',
 		'fieldtype': 'Table',
-		'idx': 83,
 		'label': 'Sales Team1',
 		'oldfieldname': 'sales_team',
 		'oldfieldtype': 'Table',
@@ -1378,7 +1301,6 @@
 		'allow_on_submit': 1,
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 84,
 		'label': 'Repair Sales Order',
 		'oldfieldtype': 'Button',
 		'options': 'repair_sales_order',
diff --git a/erpnext/setup/doctype/customer_group/customer_group.py b/erpnext/setup/doctype/customer_group/customer_group.py
index ae74797..4537876 100644
--- a/erpnext/setup/doctype/customer_group/customer_group.py
+++ b/erpnext/setup/doctype/customer_group/customer_group.py
@@ -39,7 +39,5 @@
 
   def validate(self): 
 
-    r = sql("select name from `tabCustomer Group` where name = '%s' and docstatus = 2"%(self.doc.customer_group_name))
-    if r:
-      msgprint("%s record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.customer_group_name))
-      raise Exception
\ No newline at end of file
+    if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)):
+      msgprint("%s record is trashed. To untrash please go to Setup & click on Trash."%(self.doc.customer_group_name), raise_exception = 1)
diff --git a/erpnext/setup/doctype/manage_account/manage_account.py b/erpnext/setup/doctype/manage_account/manage_account.py
index 651794f..5dd2d06 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.py
+++ b/erpnext/setup/doctype/manage_account/manage_account.py
@@ -43,6 +43,7 @@
                 ['company',self.doc.default_company],
                 ['currency',self.doc.default_currency],
                 ['price_list_name',self.doc.default_price_list],
+				['price_list_currency', self.doc.default_price_list_currency],
                 ['item_group',self.doc.default_item_group],
                 ['customer_group',self.doc.default_customer_group],
                 ['cust_master_name',self.doc.cust_master_name], 
diff --git a/erpnext/setup/doctype/manage_account/manage_account.txt b/erpnext/setup/doctype/manage_account/manage_account.txt
index 21306cf..8a156a0 100644
--- a/erpnext/setup/doctype/manage_account/manage_account.txt
+++ b/erpnext/setup/doctype/manage_account/manage_account.txt
@@ -5,18 +5,20 @@
 	{
 		'creation': '2010-08-08 17:09:09',
 		'docstatus': 0,
-		'modified': '2011-12-14 15:08:22',
+		'modified': '2011-12-21 13:22:33',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1323855454',
+
+		'_last_update': '1323855502',
 		'allow_copy': 1,
 		'allow_email': 1,
 		'allow_print': 1,
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'hide_toolbar': 0,
 		'in_create': 1,
@@ -27,7 +29,7 @@
 		'section_style': 'Tabbed',
 		'server_code_error': ' ',
 		'show_in_menu': 1,
-		'version': 516
+		'version': 515
 	},
 
 	# These values are common for all DocField
@@ -240,6 +242,15 @@
 	# DocField
 	{
 		'doctype': 'DocField',
+		'fieldname': 'auto_indent',
+		'fieldtype': 'Check',
+		'label': 'Raise Indent when stock reaches re-order level'
+	},
+
+	# DocField
+	{
+		'default': '1',
+		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
 		'width': '50%'
 	},
@@ -322,7 +333,7 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'label': 'Acccount Info',
+		'label': 'Account Info',
 		'options': '<div class="help-box">For more accounting defaults, Open <a href="#!List/Company">Company</a></div>'
 	},
 
@@ -381,6 +392,13 @@
 	# DocField
 	{
 		'doctype': 'DocField',
+		'fieldtype': 'Column Break',
+		'width': '50%'
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
 		'fieldname': 'default_price_list',
 		'fieldtype': 'Link',
 		'label': 'Default Price List',
@@ -390,8 +408,10 @@
 	# DocField
 	{
 		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'width': '50%'
+		'fieldname': 'default_price_list_currency',
+		'fieldtype': 'Link',
+		'label': 'Default Price List Currency',
+		'options': 'Currency'
 	},
 
 	# DocField
@@ -490,4 +510,4 @@
 		'label': 'Employee Records to be created by ',
 		'options': '\nNaming Series\nEmployee Number'
 	}
-]
\ No newline at end of file
+]
diff --git a/erpnext/setup/doctype/other_charges/other_charges.js b/erpnext/setup/doctype/other_charges/other_charges.js
index 3d0b324..4c154f5 100644
--- a/erpnext/setup/doctype/other_charges/other_charges.js
+++ b/erpnext/setup/doctype/other_charges/other_charges.js
@@ -93,12 +93,10 @@
   return 'SELECT tabAccount.name FROM tabAccount WHERE tabAccount.group_or_ledger="Ledger" AND tabAccount.docstatus != 2 AND (tabAccount.account_type = "Tax" OR tabAccount.account_type = "Chargeable") AND tabAccount.company = "'+doc.company+'" AND  tabAccount.name LIKE "%s"'
 }
 
-//--------------------filter other charges master company-wise-----------------------------------------
-/*
-cur_frm.fields_dict.charge.get_query = function(doc) {
-  return 'SELECT DISTINCT `tabOther Charges`.name FROM `tabOther Charges` WHERE `tabOther Charges`.company = "'+doc.company+'" AND `tabOther Charges`.company is not NULL AND `tabOther Charges`.name LIKE "%s" ORDER BY `tabOther Charges`.name LIMIT 50';
+cur_frm.fields_dict['other_charges'].grid.get_field("cost_center_other_charges").get_query = function(doc) {
+	return 'SELECT `tabCost Center`.`name` FROM `tabCost Center` WHERE `tabCost Center`.`company_name` = "' +doc.company+'" AND `tabCost Center`.%(key)s LIKE "%s" AND `tabCost Center`.`group_or_ledger` = "Ledger" AND `tabCost Center`.`docstatus`!= 2 ORDER BY	`tabCost Center`.`name` ASC LIMIT 50';
 }
-*/
+
 
 cur_frm.cscript.account_head = function(doc, cdt, cdn) {
   var d = locals[cdt][cdn];
diff --git a/erpnext/stock/doctype/bin/bin.py b/erpnext/stock/doctype/bin/bin.py
index bb1101e..881a176 100644
--- a/erpnext/stock/doctype/bin/bin.py
+++ b/erpnext/stock/doctype/bin/bin.py
@@ -1,11 +1,18 @@
 # Please edit this list and import only required elements
 import webnotes
 
-from webnotes.utils import cint, cstr, flt, nowdate
-from webnotes.model.code import get_obj
-from webnotes import msgprint
+from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
+from webnotes.model import db_exists
+from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
+from webnotes.model.doclist import getlist, copy_doclist
+from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
+from webnotes import session, form, is_testing, msgprint, errprint
 
+set = webnotes.conn.set
 sql = webnotes.conn.sql
+get_value = webnotes.conn.get_value
+
+
 
 # -----------------------------------------------------------------------------------------
 
@@ -18,9 +25,9 @@
 	# -------------
 	# stock update
 	# -------------
-	def update_stock(self, actual_qty=0, reserved_qty=0, ordered_qty=0, indented_qty=0, planned_qty=0, dt=None, sle_id='', posting_time='', serial_no = '', is_cancelled = 'No'):
-
-		if not dt: dt = nowdate()
+	def update_stock(self, actual_qty=0, reserved_qty=0, ordered_qty=0, indented_qty=0, planned_qty=0, dt=None, sle_id='', posting_time='', serial_no = '', is_cancelled = 'No',doc_type='',doc_name='',is_amended='No'):
+		if not dt: 
+			dt = nowdate()
 		# update the stock values (for current quantities)
 		self.doc.actual_qty = flt(self.doc.actual_qty) + flt(actual_qty)
 		self.doc.ordered_qty = flt(self.doc.ordered_qty) + flt(ordered_qty)
@@ -28,9 +35,9 @@
 		self.doc.indented_qty = flt(self.doc.indented_qty) + flt(indented_qty)
 		self.doc.planned_qty = flt(self.doc.planned_qty) + flt(planned_qty)
 		self.doc.projected_qty = flt(self.doc.actual_qty) + flt(self.doc.ordered_qty) + flt(self.doc.indented_qty) + flt(self.doc.planned_qty) - flt(self.doc.reserved_qty)
-
 		self.doc.save()
-			
+		if(( flt(actual_qty)<0 or flt(reserved_qty)>0 )and is_cancelled == 'No' and is_amended=='No'):
+			self.reorder_item(doc_type,doc_name)	
 		
 		if actual_qty:
 			# check actual qty with total number of serial no
@@ -299,13 +306,54 @@
 
 	# item re-order
 	# -------------
-	def reorder_item(self):
-		#check if re-order is required
-		projected_qty = flt(self.doc.actual_qty) + flt(self.doc.indented_qty) + flt(self.doc.ordered_qty)
-		item_reorder_level = sql("select reorder_level from `%sItem` where name = '%s'" % (self.prefix, self.doc.item_code))[0][0] or 0
-		if flt(item_reorder_level) > flt(projected_qty):
-			msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Indent raised (Not Implemented).")
-	
+	def reorder_item(self,doc_type,doc_name):
+		msgprint(get_value('Manage Account', None, 'auto_indent'))
+		if get_value('Manage Account', None, 'auto_indent'):
+			#check if re-order is required
+			indent_detail_fields = sql("select re_order_level,item_name,description,brand,item_group,lead_time_days,min_order_qty,email_notify from tabItem where item_code = %s",(self.doc.item_code),as_dict=1)
+			i =	indent_detail_fields[0] 
+			item_reorder_level = i['re_order_level'] or 0	 
+			if ((flt(item_reorder_level) > flt(self.doc.projected_qty)) and item_reorder_level) :
+				self.reorder_indent(i,item_reorder_level,doc_type,doc_name,email_notify=i['email_notify'])
+
+		
+	# Re order Auto Intent Generation
+	def reorder_indent(self,i,item_reorder_level,doc_type,doc_name,email_notify=1):
+		indent = Document('Indent')
+		indent.transaction_date = nowdate()
+		indent.naming_series = 'IDT'
+		indent.company = get_defaults()['company']
+		indent.fiscal_year = get_defaults()['fiscal_year']
+		indent.remark = "This is an auto generated Indent. It was raised because the projected quantity has fallen below the minimum re-order level when %s %s was created"%(doc_type,doc_name)
+		indent.save(1)
+		indent_obj = get_obj('Indent',indent.name,with_children=1)
+		indent_details_child = addchild(indent_obj.doc,'indent_details','Indent Detail',0)
+		indent_details_child.item_code = self.doc.item_code
+		indent_details_child.uom = self.doc.stock_uom
+		indent_details_child.warehouse = self.doc.warehouse
+		indent_details_child.schedule_date= add_days(nowdate(),i['lead_time_days'])
+		indent_details_child.item_name = i['item_name']
+		indent_details_child.description = i['description']
+		indent_details_child.item_group = i['item_group']
+		if (i['min_order_qty'] < ( flt(item_reorder_level)-flt(self.doc.projected_qty) )):
+			indent_details_child.qty =flt(flt(item_reorder_level)-flt(self.doc.projected_qty))
+		else:
+			indent_details_child.qty = i['min_order_qty']
+		indent_details_child.brand = i['brand']
+		indent_details_child.save()
+		indent_obj = get_obj('Indent',indent.name,with_children=1)
+		indent_obj.validate()
+		set(indent_obj.doc,'docstatus',1)
+		indent_obj.on_submit()
+		msgprint("Item: " + self.doc.item_code + " is to be re-ordered. Indent %s raised.Was generated from %s %s"%(indent.name,doc_type, doc_name ))
+		if(email_notify):
+			send_email_notification(doc_type,doc_name)
+			
+	def send_email_notification(self,doc_type,doc_name):
+		email_list=[d for d in sql("select parent from tabUserRole where role in ('Purchase Manager','Material Manager') ")]
+		msg1='An Indent has been raised for item %s: %s on %s '%(doc_type, doc_name, nowdate())
+		sendmail(email_list, sender='automail@webnotestech.com', \
+		subject='Auto Indent Generation Notification', parts=[['text/plain',msg1]])	
 	# validate
 	def validate(self):
 		self.validate_mandatory()
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 823eca4..8f9fa6d 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -15,6 +15,7 @@
   if(!doc.transaction_date) set_multiple(dt,dn,{transaction_date:get_today()});
   if(!doc.posting_date) set_multiple(dt,dn,{posting_date:get_today()});
   if(doc.__islocal && doc.customer) cur_frm.cscript.pull_item_details_onload(doc,dt,dn);
+  if(!doc.price_list_currency) set_multiple(cdt, cdn, {price_list_currency: doc.currency, plc_conversion_rate: 1});
 
   if(!doc.posting_time) doc.posting_time = wn.datetime.get_cur_time()
     
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index ea8c648..93f72df 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -374,8 +374,7 @@
 				# if prevdoc_doctype = "Sales Order"
 				if d[3] < 0 :
 					# Reduce Reserved Qty from warehouse
-					bin = get_obj('Warehouse', d[0]).update_bin(0, flt(update_stock) * flt(d[3]), 0, 0, 0, d[1], self.doc.transaction_date)
-
+					bin = get_obj('Warehouse', d[0]).update_bin(0, flt(update_stock) * flt(d[3]), 0, 0, 0, d[1], self.doc.transaction_date,doc_type=self.doc.doctype,doc_name=self.doc.name, is_amended = (self.doc.amended_from and 'Yes' or 'No'))
 				# Reduce actual qty from warehouse
 				self.make_sl_entry(d, d[0], - flt(d[2]) , 0, update_stock)
 		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.txt b/erpnext/stock/doctype/delivery_note/delivery_note.txt
index 8109af5..dc905f5 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.txt
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.txt
@@ -5,7 +5,7 @@
 	{
 		'creation': '2011-04-18 15:58:20',
 		'docstatus': 0,
-		'modified': '2011-10-18 13:57:23',
+		'modified': '2011-12-20 13:23:33',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
@@ -21,7 +21,7 @@
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1318321312',
+		'_last_update': '1324367019',
 		'colour': 'White:FFF',
 		'default_print_format': 'Standard',
 		'doctype': 'DocType',
@@ -37,7 +37,7 @@
 		'show_in_menu': 0,
 		'subject': 'To %(customer_name)s on %(transaction_date)s | %(per_billed)s% billed',
 		'tag_fields': 'billing_status',
-		'version': 454
+		'version': 459
 	},
 
 	# These values are common for all DocFormat
@@ -130,7 +130,8 @@
 	{
 		'doctype': 'DocPerm',
 		'permlevel': 1,
-		'role': 'All'
+		'role': 'All',
+		'write': 0
 	},
 
 	# DocPerm
@@ -542,34 +543,6 @@
 	# DocField
 	{
 		'colour': 'White:FFF',
-		'description': 'You can make a delivery note from multiple sales orders. Select sales orders one by one and click on the button below.',
-		'doctype': 'DocField',
-		'fieldname': 'sales_order_no',
-		'fieldtype': 'Link',
-		'label': 'Sales Order No',
-		'no_copy': 0,
-		'oldfieldname': 'sales_order_no',
-		'oldfieldtype': 'Link',
-		'options': 'Sales Order',
-		'permlevel': 0,
-		'print_hide': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Button',
-		'hidden': 0,
-		'label': 'Get Items',
-		'oldfieldtype': 'Button',
-		'options': 'pull_sales_order_details',
-		'permlevel': 0,
-		'print_hide': 1
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
 		'description': 'Select the price list as entered in "Price List" master. This will pull the reference rates of items against this price list as specified in "Item" master.',
 		'doctype': 'DocField',
 		'fieldname': 'price_list_name',
@@ -586,6 +559,31 @@
 
 	# DocField
 	{
+		'colour': 'White:FFF',
+		'description': 'Select the currency in which price list is maintained',
+		'doctype': 'DocField',
+		'fieldname': 'price_list_currency',
+		'fieldtype': 'Select',
+		'label': 'Price List Currency',
+		'options': 'link:Currency',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
+		'colour': 'White:FFF',
+		'description': 'Rate at which Price list currency is converted to your currency',
+		'doctype': 'DocField',
+		'fieldname': 'plc_conversion_rate',
+		'fieldtype': 'Currency',
+		'label': 'Price List Currency Conversion Rate',
+		'permlevel': 0,
+		'reqd': 1
+	},
+
+	# DocField
+	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
 		'permlevel': 0,
@@ -627,6 +625,34 @@
 
 	# DocField
 	{
+		'colour': 'White:FFF',
+		'description': 'You can make a delivery note from multiple sales orders. Select sales orders one by one and click on the button below.',
+		'doctype': 'DocField',
+		'fieldname': 'sales_order_no',
+		'fieldtype': 'Link',
+		'label': 'Sales Order No',
+		'no_copy': 0,
+		'oldfieldname': 'sales_order_no',
+		'oldfieldtype': 'Link',
+		'options': 'Sales Order',
+		'permlevel': 0,
+		'print_hide': 0
+	},
+
+	# DocField
+	{
+		'doctype': 'DocField',
+		'fieldtype': 'Button',
+		'hidden': 0,
+		'label': 'Get Items',
+		'oldfieldtype': 'Button',
+		'options': 'pull_sales_order_details',
+		'permlevel': 0,
+		'print_hide': 1
+	},
+
+	# DocField
+	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
 		'permlevel': 0
diff --git a/erpnext/stock/doctype/item/item.txt b/erpnext/stock/doctype/item/item.txt
index 0d20f7b..c670700 100644
--- a/erpnext/stock/doctype/item/item.txt
+++ b/erpnext/stock/doctype/item/item.txt
@@ -5,18 +5,19 @@
 	{
 		'creation': '2010-08-08 17:09:05',
 		'docstatus': 0,
-		'modified': '2011-08-18 13:03:31',
+		'modified': '2011-12-20 11:15:42',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1313651083',
+		'_last_update': '1323333040',
 		'allow_attach': 1,
 		'allow_trash': 1,
 		'autoname': 'field:item_code',
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'document_type': 'Master',
 		'max_attachments': 1,
@@ -28,7 +29,7 @@
 		'show_in_menu': 0,
 		'subject': '%(item_name)s',
 		'tag_fields': 'item_group',
-		'version': 161
+		'version': 162
 	},
 
 	# These values are common for all DocField
@@ -62,7 +63,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'permlevel': 1,
 		'role': 'Material Manager',
 		'submit': 0,
@@ -75,7 +75,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 2,
 		'permlevel': 0,
 		'role': 'Material Manager',
 		'submit': 0,
@@ -88,7 +87,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 3,
 		'permlevel': 1,
 		'role': 'Material User',
 		'submit': 0,
@@ -101,7 +99,6 @@
 		'cancel': 0,
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 4,
 		'permlevel': 0,
 		'role': 'Material User',
 		'submit': 0,
@@ -113,7 +110,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 5,
 		'permlevel': 0,
 		'role': 'Material Master Manager',
 		'write': 1
@@ -123,7 +119,6 @@
 	{
 		'create': 0,
 		'doctype': 'DocPerm',
-		'idx': 6,
 		'permlevel': 1,
 		'role': 'Material Master Manager',
 		'write': 0
@@ -134,7 +129,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 7,
 		'permlevel': 0,
 		'role': 'System Manager',
 		'write': 1
@@ -143,7 +137,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 8,
 		'permlevel': 1,
 		'role': 'System Manager'
 	},
@@ -152,7 +145,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Item',
 		'no_copy': 0,
 		'oldfieldtype': 'Section Break',
@@ -164,7 +156,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'trash_reason',
 		'fieldtype': 'Small Text',
-		'idx': 2,
 		'label': 'Trash Reason',
 		'oldfieldname': 'trash_reason',
 		'oldfieldtype': 'Small Text',
@@ -178,7 +169,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'item_code',
 		'fieldtype': 'Data',
-		'idx': 3,
 		'in_filter': 0,
 		'label': 'Item Code',
 		'oldfieldname': 'item_code',
@@ -193,7 +183,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'item_name',
 		'fieldtype': 'Data',
-		'idx': 4,
 		'in_filter': 1,
 		'label': 'Item Name',
 		'oldfieldname': 'item_name',
@@ -210,7 +199,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'item_group',
 		'fieldtype': 'Link',
-		'idx': 5,
 		'in_filter': 1,
 		'label': 'Item Group',
 		'oldfieldname': 'item_group',
@@ -224,7 +212,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'HTML',
-		'idx': 6,
 		'label': 'IGHelp',
 		'oldfieldtype': 'HTML',
 		'options': '<a href="javascript:cur_frm.cscript.IGHelp();">To manage Item Group, click here</a>',
@@ -237,7 +224,6 @@
 		'fieldname': 'brand',
 		'fieldtype': 'Link',
 		'hidden': 0,
-		'idx': 7,
 		'label': 'Brand',
 		'oldfieldname': 'brand',
 		'oldfieldtype': 'Link',
@@ -251,7 +237,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 8,
 		'permlevel': 0
 	},
 
@@ -260,7 +245,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'description',
 		'fieldtype': 'Text',
-		'idx': 9,
 		'in_filter': 0,
 		'label': 'Description',
 		'oldfieldname': 'description',
@@ -276,7 +260,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'description_html',
 		'fieldtype': 'Text',
-		'idx': 10,
 		'label': 'Description HTML',
 		'permlevel': 0
 	},
@@ -287,7 +270,6 @@
 		'description': 'Generates HTML to include image (1st attachment) in the description',
 		'doctype': 'DocField',
 		'fieldtype': 'Button',
-		'idx': 11,
 		'label': 'Add Image',
 		'permlevel': 0
 	},
@@ -296,7 +278,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 12,
 		'label': 'Inventory',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -309,7 +290,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'stock_uom',
 		'fieldtype': 'Link',
-		'idx': 13,
 		'label': 'Default UoM',
 		'oldfieldname': 'stock_uom',
 		'oldfieldtype': 'Link',
@@ -326,7 +306,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_stock_item',
 		'fieldtype': 'Select',
-		'idx': 14,
 		'label': 'Is Stock Item',
 		'oldfieldname': 'is_stock_item',
 		'oldfieldtype': 'Select',
@@ -340,7 +319,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'valuation_method',
 		'fieldtype': 'Select',
-		'idx': 15,
 		'label': 'Valuation Method',
 		'oldfieldname': 'valuation_method',
 		'oldfieldtype': 'Select',
@@ -353,7 +331,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'default_warehouse',
 		'fieldtype': 'Link',
-		'idx': 16,
 		'label': 'Default Warehouse',
 		'oldfieldname': 'default_warehouse',
 		'oldfieldtype': 'Link',
@@ -368,7 +345,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'tolerance',
 		'fieldtype': 'Currency',
-		'idx': 17,
 		'label': 'Allowance Percent',
 		'oldfieldname': 'tolerance',
 		'oldfieldtype': 'Currency',
@@ -380,7 +356,6 @@
 		'doctype': 'DocField',
 		'fieldname': 're_order_level',
 		'fieldtype': 'Currency',
-		'idx': 18,
 		'label': 'Re-Order Level',
 		'oldfieldname': 're_order_level',
 		'oldfieldtype': 'Currency',
@@ -389,18 +364,11 @@
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'default': '0.00',
-		'description': 'If stock level for this item has reached the minimum inventory level, system will prompt you to raise an Indent (Purchase Requisition).',
 		'doctype': 'DocField',
-		'fieldname': 'minimum_inventory_level',
-		'fieldtype': 'Currency',
-		'idx': 19,
-		'label': 'Minimum Inventory Level',
-		'oldfieldname': 'minimum_inventory_level',
-		'oldfieldtype': 'Currency',
-		'permlevel': 0,
-		'reqd': 0
+		'fieldname': 'email_notify',
+		'fieldtype': 'Check',
+		'label': 'Send Email Notification when stock reaches re-order level',
+		'permlevel': 0
 	},
 
 	# DocField
@@ -412,7 +380,6 @@
 		'fieldname': 'min_order_qty',
 		'fieldtype': 'Currency',
 		'hidden': 0,
-		'idx': 20,
 		'label': 'Minimum Order Qty',
 		'oldfieldname': 'min_order_qty',
 		'oldfieldtype': 'Currency',
@@ -423,7 +390,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 21,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -437,7 +403,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_asset_item',
 		'fieldtype': 'Select',
-		'idx': 22,
 		'label': 'Is Asset Item',
 		'oldfieldname': 'is_asset_item',
 		'oldfieldtype': 'Select',
@@ -453,7 +418,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'has_batch_no',
 		'fieldtype': 'Select',
-		'idx': 23,
 		'label': 'Has Batch No',
 		'oldfieldname': 'has_batch_no',
 		'oldfieldtype': 'Select',
@@ -470,7 +434,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'has_serial_no',
 		'fieldtype': 'Select',
-		'idx': 24,
 		'in_filter': 1,
 		'label': 'Has Serial No',
 		'oldfieldname': 'has_serial_no',
@@ -485,7 +448,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'warranty_period',
 		'fieldtype': 'Data',
-		'idx': 25,
 		'label': 'Warranty Period (in days)',
 		'oldfieldname': 'warranty_period',
 		'oldfieldtype': 'Data',
@@ -497,7 +459,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'end_of_life',
 		'fieldtype': 'Date',
-		'idx': 26,
 		'label': 'End of Life',
 		'oldfieldname': 'end_of_life',
 		'oldfieldtype': 'Date',
@@ -509,7 +470,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'nett_weight',
 		'fieldtype': 'Float',
-		'idx': 27,
 		'label': 'Nett Weight',
 		'permlevel': 0
 	},
@@ -519,7 +479,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'gross_weight',
 		'fieldtype': 'Float',
-		'idx': 28,
 		'label': 'Gross Weight',
 		'permlevel': 0
 	},
@@ -529,7 +488,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'weight_uom',
 		'fieldtype': 'Link',
-		'idx': 29,
 		'label': 'Weight UOM',
 		'options': 'UOM',
 		'permlevel': 0
@@ -540,7 +498,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 30,
 		'label': 'Purchase Details',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -554,7 +511,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_purchase_item',
 		'fieldtype': 'Select',
-		'idx': 31,
 		'label': 'Is Purchase Item',
 		'oldfieldname': 'is_purchase_item',
 		'oldfieldtype': 'Select',
@@ -570,7 +526,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'lead_time_days',
 		'fieldtype': 'Int',
-		'idx': 32,
 		'label': 'Lead Time Days',
 		'no_copy': 1,
 		'oldfieldname': 'lead_time_days',
@@ -585,7 +540,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'purchase_account',
 		'fieldtype': 'Link',
-		'idx': 33,
 		'label': 'Default Expense Account',
 		'oldfieldname': 'purchase_account',
 		'oldfieldtype': 'Link',
@@ -601,7 +555,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'cost_center',
 		'fieldtype': 'Link',
-		'idx': 34,
 		'label': 'Default Cost Center',
 		'oldfieldname': 'cost_center',
 		'oldfieldtype': 'Link',
@@ -616,7 +569,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'buying_cost',
 		'fieldtype': 'Currency',
-		'idx': 35,
 		'label': 'Buying Cost',
 		'no_copy': 1,
 		'oldfieldname': 'buying_cost',
@@ -630,7 +582,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'last_purchase_rate',
 		'fieldtype': 'Currency',
-		'idx': 36,
 		'label': 'Last Purchase Rate',
 		'no_copy': 1,
 		'oldfieldname': 'last_purchase_rate',
@@ -643,7 +594,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'standard_rate',
 		'fieldtype': 'Currency',
-		'idx': 37,
 		'label': 'Standard Rate',
 		'oldfieldname': 'standard_rate',
 		'oldfieldtype': 'Currency',
@@ -654,7 +604,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 38,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -665,7 +614,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'uom_conversion_details',
 		'fieldtype': 'Table',
-		'idx': 39,
 		'label': 'UOM Conversion Details',
 		'oldfieldname': 'uom_conversion_details',
 		'oldfieldtype': 'Table',
@@ -677,7 +625,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 40,
 		'label': 'Sales Details',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -691,7 +638,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_sales_item',
 		'fieldtype': 'Select',
-		'idx': 41,
 		'in_filter': 1,
 		'label': 'Is Sales Item',
 		'oldfieldname': 'is_sales_item',
@@ -709,7 +655,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_service_item',
 		'fieldtype': 'Select',
-		'idx': 42,
 		'in_filter': 1,
 		'label': 'Is Service Item',
 		'oldfieldname': 'is_service_item',
@@ -727,7 +672,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_sample_item',
 		'fieldtype': 'Select',
-		'idx': 43,
 		'label': 'Allow Samples',
 		'oldfieldname': 'is_sample_item',
 		'oldfieldtype': 'Select',
@@ -741,7 +685,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'max_discount',
 		'fieldtype': 'Currency',
-		'idx': 44,
 		'label': 'Max Discount (%)',
 		'oldfieldname': 'max_discount',
 		'oldfieldtype': 'Currency',
@@ -753,7 +696,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'default_income_account',
 		'fieldtype': 'Link',
-		'idx': 45,
 		'label': 'Default Income Account',
 		'options': 'Account',
 		'permlevel': 0
@@ -764,7 +706,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'default_sales_cost_center',
 		'fieldtype': 'Link',
-		'idx': 46,
 		'label': 'Cost Center',
 		'options': 'Cost Center',
 		'permlevel': 0
@@ -776,7 +717,6 @@
 		'fieldname': 'sales_rate',
 		'fieldtype': 'Currency',
 		'hidden': 1,
-		'idx': 47,
 		'label': 'Sales Rate',
 		'oldfieldname': 'sales_rate',
 		'oldfieldtype': 'Currency',
@@ -787,7 +727,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 48,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -800,7 +739,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'ref_rate_details',
 		'fieldtype': 'Table',
-		'idx': 49,
 		'label': 'Ref Rate Details',
 		'oldfieldname': 'ref_rate_details',
 		'oldfieldtype': 'Table',
@@ -814,7 +752,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'item_customer_details',
 		'fieldtype': 'Table',
-		'idx': 50,
 		'label': 'Customer Codes',
 		'options': 'Item Customer Detail',
 		'permlevel': 0
@@ -824,7 +761,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 51,
 		'label': 'Item Tax',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -835,7 +771,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'item_tax',
 		'fieldtype': 'Table',
-		'idx': 52,
 		'label': 'Item Tax1',
 		'oldfieldname': 'item_tax',
 		'oldfieldtype': 'Table',
@@ -847,7 +782,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 53,
 		'label': 'Inspection Criteria',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -859,7 +793,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'inspection_required',
 		'fieldtype': 'Select',
-		'idx': 54,
 		'label': 'Inspection Required',
 		'no_copy': 0,
 		'oldfieldname': 'inspection_required',
@@ -874,7 +807,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'item_specification_details',
 		'fieldtype': 'Table',
-		'idx': 55,
 		'label': 'Item Specification Detail',
 		'oldfieldname': 'item_specification_details',
 		'oldfieldtype': 'Table',
@@ -886,7 +818,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 56,
 		'label': 'Manufacturing',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -900,7 +831,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_manufactured_item',
 		'fieldtype': 'Select',
-		'idx': 57,
 		'label': 'Allow Bill of Materials',
 		'oldfieldname': 'is_manufactured_item',
 		'oldfieldtype': 'Select',
@@ -915,7 +845,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'default_bom',
 		'fieldtype': 'Link',
-		'idx': 58,
 		'label': 'Default BOM',
 		'no_copy': 1,
 		'oldfieldname': 'default_bom',
@@ -932,7 +861,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_pro_applicable',
 		'fieldtype': 'Select',
-		'idx': 59,
 		'label': 'Allow Production Order',
 		'oldfieldname': 'is_pro_applicable',
 		'oldfieldtype': 'Select',
@@ -949,7 +877,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_sub_contracted_item',
 		'fieldtype': 'Select',
-		'idx': 60,
 		'label': 'Is Sub Contracted Item',
 		'oldfieldname': 'is_sub_contracted_item',
 		'oldfieldtype': 'Select',
@@ -964,8 +891,8 @@
 		'fieldname': 'file_list',
 		'fieldtype': 'Text',
 		'hidden': 1,
-		'idx': 61,
 		'label': 'File List',
+		'no_copy': 1,
 		'permlevel': 0,
 		'print_hide': 1
 	},
@@ -976,7 +903,6 @@
 		'fieldname': 'customer_code',
 		'fieldtype': 'Data',
 		'hidden': 1,
-		'idx': 62,
 		'in_filter': 1,
 		'label': 'Customer Code',
 		'no_copy': 1,
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py
index 208dd28..9eeb11f 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.py
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.py
@@ -245,7 +245,7 @@
 				self.add_to_values(d, cstr(d.s_warehouse), -flt(d.transfer_qty), is_cancelled)
 			if cstr(d.t_warehouse):
 				self.add_to_values(d, cstr(d.t_warehouse), flt(d.transfer_qty), is_cancelled)
-		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values)
+		get_obj('Stock Ledger', 'Stock Ledger').update_stock(self.values, self.doc.amended_from and 'Yes' or 'No')
 
 	
 	def validate_for_production_order(self, pro_obj):
diff --git a/erpnext/stock/doctype/stock_ledger/stock_ledger.py b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
index 0970b78..f22d2c2 100644
--- a/erpnext/stock/doctype/stock_ledger/stock_ledger.py
+++ b/erpnext/stock/doctype/stock_ledger/stock_ledger.py
@@ -207,7 +207,7 @@
 	# -------------
 	# update stock
 	# -------------
-	def update_stock(self, values):
+	def update_stock(self, values, is_amended = 'No'):
 		for v in values:
 			sle_id, serial_nos = '', ''
 
@@ -224,7 +224,7 @@
 			if v["actual_qty"]:
 				sle_id = self.make_entry(v)
 
-			get_obj('Warehouse', v["warehouse"]).update_bin(flt(v["actual_qty"]), 0, 0, 0, 0, v["item_code"], v["posting_date"], sle_id, v["posting_time"], '', v["is_cancelled"])
+			get_obj('Warehouse', v["warehouse"]).update_bin(flt(v["actual_qty"]), 0, 0, 0, 0, v["item_code"], v["posting_date"], sle_id, v["posting_time"], '', v["is_cancelled"],v["voucher_type"],v["voucher_no"], is_amended)
 
 
 	# -----------
diff --git a/erpnext/stock/doctype/warehouse/warehouse.py b/erpnext/stock/doctype/warehouse/warehouse.py
index 0b099fd..b9d560a 100644
--- a/erpnext/stock/doctype/warehouse/warehouse.py
+++ b/erpnext/stock/doctype/warehouse/warehouse.py
@@ -52,12 +52,12 @@
 
 	# update bin
 	# ----------
-	def update_bin(self, actual_qty, reserved_qty, ordered_qty, indented_qty, planned_qty, item_code, dt, sle_id = '',posting_time = '', serial_no = '', is_cancelled = 'No'):
+	def update_bin(self, actual_qty, reserved_qty, ordered_qty, indented_qty, planned_qty, item_code, dt, sle_id = '',posting_time = '', serial_no = '', is_cancelled = 'No',doc_type='',doc_name='',is_amended='No'):
 		self.validate_asset(item_code)
 		it_det = get_value('Item', item_code, 'is_stock_item')
 		if it_det and it_det == 'Yes':
 			bin = self.get_bin(item_code)
-			bin.update_stock(actual_qty, reserved_qty, ordered_qty, indented_qty, planned_qty, dt, sle_id, posting_time, serial_no, is_cancelled)
+			bin.update_stock(actual_qty, reserved_qty, ordered_qty, indented_qty, planned_qty, dt, sle_id, posting_time, serial_no, is_cancelled,doc_type,doc_name,is_amended)
 			return bin
 		else:
 			msgprint("[Stock Update] Ignored %s since it is not a stock item" % item_code)
diff --git a/erpnext/utilities/doctype/contact/contact.txt b/erpnext/utilities/doctype/contact/contact.txt
index 43fa4d7..e5a6757 100644
--- a/erpnext/utilities/doctype/contact/contact.txt
+++ b/erpnext/utilities/doctype/contact/contact.txt
@@ -5,16 +5,17 @@
 	{
 		'creation': '2010-08-08 17:08:55',
 		'docstatus': 0,
-		'modified': '2011-05-26 11:00:36',
+		'modified': '2011-12-19 14:11:08',
 		'modified_by': 'Administrator',
 		'owner': 'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1306307671',
+		'_last_update': '1316075905',
 		'allow_trash': 1,
 		'colour': 'White:FFF',
+		'default_print_format': 'Standard',
 		'doctype': 'DocType',
 		'document_type': 'Master',
 		'in_create': 0,
@@ -25,7 +26,7 @@
 		'server_code_error': ' ',
 		'show_in_menu': 0,
 		'subject': '%(first_name)s %(last_name)s - Email: %(email_id)s | Contact: %(phone)s | Mobile: %(mobile_no)s',
-		'version': 242
+		'version': 243
 	},
 
 	# These values are common for all DocField
@@ -56,7 +57,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 1,
 		'permlevel': 0,
 		'role': 'Sales User'
 	},
@@ -64,7 +64,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 2,
 		'permlevel': 0,
 		'role': 'Purchase User'
 	},
@@ -75,7 +74,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 3,
 		'permlevel': 0,
 		'role': 'Sales Master Manager',
 		'submit': 0,
@@ -85,7 +83,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 4,
 		'permlevel': 1,
 		'role': 'All',
 		'write': 1
@@ -94,7 +91,6 @@
 	# DocPerm
 	{
 		'doctype': 'DocPerm',
-		'idx': 5,
 		'permlevel': 2,
 		'role': 'All'
 	},
@@ -104,7 +100,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 6,
 		'permlevel': 0,
 		'role': 'Purchase Master Manager',
 		'write': 1
@@ -115,7 +110,6 @@
 		'cancel': 1,
 		'create': 1,
 		'doctype': 'DocPerm',
-		'idx': 7,
 		'permlevel': 0,
 		'role': 'System Manager',
 		'write': 1
@@ -126,7 +120,6 @@
 		'colour': 'White:FFF',
 		'doctype': 'DocField',
 		'fieldtype': 'Section Break',
-		'idx': 1,
 		'label': 'Contact Details',
 		'oldfieldtype': 'Section Break',
 		'permlevel': 0
@@ -136,7 +129,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 2,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -147,7 +139,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'first_name',
 		'fieldtype': 'Data',
-		'idx': 3,
 		'label': 'First Name',
 		'oldfieldname': 'first_name',
 		'oldfieldtype': 'Data',
@@ -160,7 +151,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'last_name',
 		'fieldtype': 'Data',
-		'idx': 4,
 		'label': 'Last Name',
 		'oldfieldname': 'last_name',
 		'oldfieldtype': 'Data',
@@ -174,7 +164,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer',
 		'fieldtype': 'Link',
-		'idx': 5,
 		'label': 'Customer',
 		'oldfieldname': 'customer',
 		'oldfieldtype': 'Link',
@@ -191,7 +180,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'customer_name',
 		'fieldtype': 'Data',
-		'idx': 6,
 		'label': 'Customer Name',
 		'permlevel': 1
 	},
@@ -203,7 +191,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'supplier',
 		'fieldtype': 'Link',
-		'idx': 7,
 		'label': 'Supplier',
 		'options': 'Supplier',
 		'permlevel': 0,
@@ -218,7 +205,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'supplier_name',
 		'fieldtype': 'Data',
-		'idx': 8,
 		'label': 'Supplier Name',
 		'permlevel': 1
 	},
@@ -230,7 +216,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'sales_partner',
 		'fieldtype': 'Link',
-		'idx': 9,
 		'label': 'Sales Partner',
 		'options': 'Sales Partner',
 		'permlevel': 0
@@ -244,7 +229,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'is_primary_contact',
 		'fieldtype': 'Check',
-		'idx': 10,
 		'label': 'Is Primary Contact',
 		'oldfieldname': 'is_primary_contact',
 		'oldfieldtype': 'Select',
@@ -255,7 +239,6 @@
 	{
 		'doctype': 'DocField',
 		'fieldtype': 'Column Break',
-		'idx': 11,
 		'oldfieldtype': 'Column Break',
 		'permlevel': 0,
 		'width': '50%'
@@ -266,7 +249,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'email_id',
 		'fieldtype': 'Data',
-		'idx': 12,
 		'label': 'Email Id',
 		'oldfieldname': 'email_id',
 		'oldfieldtype': 'Data',
@@ -279,7 +261,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'phone',
 		'fieldtype': 'Data',
-		'idx': 13,
 		'label': 'Phone',
 		'oldfieldname': 'contact_no',
 		'oldfieldtype': 'Data',
@@ -292,7 +273,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'mobile_no',
 		'fieldtype': 'Data',
-		'idx': 14,
 		'label': 'Mobile No',
 		'oldfieldname': 'mobile_no',
 		'oldfieldtype': 'Data',
@@ -306,7 +286,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'department',
 		'fieldtype': 'Data',
-		'idx': 15,
 		'label': 'Department',
 		'options': 'Suggest',
 		'permlevel': 0
@@ -319,7 +298,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'designation',
 		'fieldtype': 'Data',
-		'idx': 16,
 		'label': 'Designation',
 		'options': 'Suggest',
 		'permlevel': 0
@@ -330,7 +308,6 @@
 		'doctype': 'DocField',
 		'fieldname': 'trash_reason',
 		'fieldtype': 'Small Text',
-		'idx': 17,
 		'label': 'Trash Reason',
 		'oldfieldname': 'trash_reason',
 		'oldfieldtype': 'Small Text',