Merge branch 'master' into sync
diff --git a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
index a3412dd..446a116 100644
--- a/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
+++ b/erpnext/accounts/doctype/receivable_voucher/receivable_voucher.py
@@ -106,8 +106,8 @@
 
 	def get_debit_to(self):
 		acc_head = self.get_customer_account()
-		if acc_head:
-			return { 'debit_to' : acc_head }
+		return acc_head and {'debit_to' : acc_head} or {}
+
 
 
 	# Set Due Date = Posting Date + Credit Days
@@ -146,8 +146,7 @@
 			self.get_income_account('entries')
 			
 		ret = self.get_debit_to()
-		if ret.has_key('debit_to'):
-			self.doc.debit_to = ret['debit_to']
+		self.doc.debit_to = ret.get('debit_to')
 					
 	# onload pull income account
 	# --------------------------
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 9a414a3..f0f24a0 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -162,7 +162,7 @@
 //==================== Item Code Get Query =======================================================
 // Only Is Purchase Item = 'Yes' and Items not moved to trash are allowed.
 cur_frm.fields_dict[fname].grid.get_field("item_code").get_query = function(doc, cdt, cdn) {
-	return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE tabItem.is_purchase_item="Yes" AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.%(key)s LIKE "%s" LIMIT 50'
+	return 'SELECT tabItem.name, tabItem.description FROM tabItem WHERE (ifnull(tabItem.is_purchase_item, "No")="Yes" or ifnull(tabItem.is_sub_contracted_item, "No")="Yes") AND (IFNULL(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` ="0000-00-00" OR `tabItem`.`end_of_life` > NOW()) AND tabItem.%(key)s LIKE "%s" LIMIT 50'
 }
 
 //==================== Get Item Code Details =====================================================
@@ -358,17 +358,17 @@
 			set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
 			set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) *	flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname);
 
-		}else if( n==4){		
+		}else if( n==4){
 
 		set_multiple(tname, cl[i].name, {'import_ref_rate': flt(flt(cl[i].purchase_ref_rate) / flt(doc.conversion_rate))}, fname);
 
 			tmp[rate_fld] = flt( flt(cl[i].purchase_ref_rate) - flt(flt(cl[i].purchase_ref_rate)*flt(cl[i].discount_rate)/100) )
 		set_multiple(tname, cl[i].name, tmp, fname);
-
+		msgprint(cl[i][rate_fld])
 		set_multiple(tname, cl[i].name, {'import_rate': flt(flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
 		set_multiple(tname, cl[i].name, {'amount':flt(flt(cl[i].qty) * flt(cl[i][rate_fld]))}, fname);
 		set_multiple(tname, cl[i].name, {'import_amount': flt(flt(cl[i].qty) *	flt(cl[i][rate_fld]) / flt(doc.conversion_rate))}, fname); 
-
+		msgprint(cl[i]['amount'])
 	}else if( n==5){	
 		tmp[rate_fld] = flt( flt(cl[i].import_ref_rate) - flt(flt(cl[i].import_ref_rate)*flt(cl[i].discount_rate)/100) ) * flt(doc.conversion_rate);
 		set_multiple(tname, cl[i].name, {'purchase_ref_rate': flt(flt(cl[i].import_ref_rate) * flt(doc.conversion_rate))}, fname);
diff --git a/erpnext/production/doctype/bill_of_materials/bill_of_materials.py b/erpnext/production/doctype/bill_of_materials/bill_of_materials.py
index 3f0bb9e..dfbc998 100644
--- a/erpnext/production/doctype/bill_of_materials/bill_of_materials.py
+++ b/erpnext/production/doctype/bill_of_materials/bill_of_materials.py
@@ -91,14 +91,12 @@
 
 		arg = eval(arg)
 		item = self.get_item_det(arg['item_code'])
-
 		self.validate_rm_item(item)
 		
 		arg['bom_no'] = arg['bom_no'] or item and cstr(item[0]['default_bom']) or ''
 		arg.update(item[0])
 
 		rate = self.get_rm_rate(arg)
-
 		ret_item = {
 					 'description'  : item and arg['description'] or '',
 					 'stock_uom'	: item and arg['stock_uom'] or '',
@@ -209,11 +207,11 @@
 		"""Fetch RM rate as per today's valuation rate and calculate totals"""
 		total_rm_cost = 0
 		for d in getlist(self.doclist, 'bom_materials'):
-			if self.doc.rm_cost_as_per == 'Valuation Rate':
-				arg = {'item_code': d.item_code, 'qty': d.qty, 'bom_no': d.bom_no}
-				ret = self.get_bom_material_detail(cstr(arg))
-				for k in ret:
-					d.fields[k] = ret[k]
+			#if self.doc.rm_cost_as_per == 'Valuation Rate':
+			arg = {'item_code': d.item_code, 'qty': d.qty, 'bom_no': d.bom_no}
+			ret = self.get_bom_material_detail(cstr(arg))
+			for k in ret:
+				d.fields[k] = ret[k]
 
 			d.amount = flt(d.rate) * flt(d.qty)
 			total_rm_cost += d.amount
diff --git a/erpnext/selling/doctype/enquiry/enquiry.py b/erpnext/selling/doctype/enquiry/enquiry.py
index 6d655fb..debc3d7 100644
--- a/erpnext/selling/doctype/enquiry/enquiry.py
+++ b/erpnext/selling/doctype/enquiry/enquiry.py
@@ -8,11 +8,11 @@
 # 
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
 # GNU General Public License for more details.
 # 
 # You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# along with this program.	If not, see <http://www.gnu.org/licenses/>.
 
 # Please edit this list and import only required elements
 import webnotes
@@ -35,305 +35,313 @@
 from utilities.transaction_base import TransactionBase
 
 class DocType(TransactionBase):
-  def __init__(self,doc,doclist=[]):
-    self.doc = doc
-    self.doclist = doclist
-    self.fname = 'enq_details'
-    self.tname = 'Enquiry Detail'
+	def __init__(self,doc,doclist=[]):
+		self.doc = doc
+		self.doclist = doclist
+		self.fname = 'enq_details'
+		self.tname = 'Enquiry Detail'
 
-  # Autoname
-  # ====================================================================================================================
-  def autoname(self):
-    self.doc.name = make_autoname(self.doc.naming_series+'.####')
+	# Autoname
+	# ====================================================================================================================
+	def autoname(self):
+		self.doc.name = make_autoname(self.doc.naming_series+'.####')
 
-  #--------Get customer address-------
-  # ====================================================================================================================
-  def get_cust_address(self,name):
-    details = sql("select customer_name, address, territory, customer_group from `tabCustomer` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
-    if details:
-      ret = {
-        'customer_name':  details and details[0]['customer_name'] or '',
-        'address'  :  details and details[0]['address'] or '',
-        'territory'       :  details and details[0]['territory'] or '',
-        'customer_group'    :  details and details[0]['customer_group'] or ''
-      }
-      # ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
+	#--------Get customer address-------
+	# ====================================================================================================================
+	def get_cust_address(self,name):
+		details = sql("select customer_name, address, territory, customer_group from `tabCustomer` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
+		if details:
+			ret = {
+				'customer_name':	details and details[0]['customer_name'] or '',
+				'address'	:	details and details[0]['address'] or '',
+				'territory'			 :	details and details[0]['territory'] or '',
+				'customer_group'		:	details and details[0]['customer_group'] or ''
+			}
+			# ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
 
-      contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer = '%s' and is_customer = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
+			contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer = '%s' and is_customer = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
 
-      
-      ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
-      ret['contact_no']     = contact_det and contact_det[0]['contact_no'] or ''
-      ret['email_id']       = contact_det and contact_det[0]['email_id'] or ''
-    
-      return ret
-    else:
-      msgprint("Customer : %s does not exist in system." % (name))
-      raise Exception
-    
+			
+			ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
+			ret['contact_no']		 = contact_det and contact_det[0]['contact_no'] or ''
+			ret['email_id']			 = contact_det and contact_det[0]['email_id'] or ''
+		
+			return ret
+		else:
+			msgprint("Customer : %s does not exist in system." % (name))
+			raise Exception
+		
 
-  # ====================================================================================================================    
-  def get_contact_details(self, arg):
-    arg = eval(arg)
-    contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s'" %(arg['contact_person'],arg['customer']), as_dict = 1)
-    ret = {
-      'contact_no' : contact and contact[0]['contact_no'] or '',
-      'email_id' : contact and contact[0]['email_id'] or ''
-    }
-    return ret
-    
-  # ====================================================================================================================
-  def on_update(self):
-    # Add to calendar
-    #if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date:
-    if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
-      if self.doc.contact_by:
-        self.add_calendar_event()
-      set(self.doc, 'contact_date_ref',self.doc.contact_date)
-    set(self.doc, 'status', 'Draft')
-  
-  # Add to Calendar
-  # ====================================================================================================================
-  def add_calendar_event(self):
-    desc=''
-    user_lst =[]
-    if self.doc.customer:
-      if self.doc.contact_person:
-        desc = 'Contact '+cstr(self.doc.contact_person)
-      else:
-        desc = 'Contact customer '+cstr(self.doc.customer)
-    elif self.doc.lead:
-      if self.doc.lead_name:
-        desc = 'Contact '+cstr(self.doc.lead_name)
-      else:
-        desc = 'Contact lead '+cstr(self.doc.lead)
-    desc = desc+ '. By : ' + cstr(self.doc.contact_by)
-    
-    if self.doc.to_discuss:
-      desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
-    
-    ev = Document('Event')
-    ev.description = desc
-    ev.event_date = self.doc.contact_date
-    ev.event_hour = '10:00'
-    ev.event_type = 'Private'
-    ev.ref_type = 'Enquiry'
-    ev.ref_name = self.doc.name
-    ev.save(1)
-    
-    user_lst.append(self.doc.owner)
-    
-    chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
-    if chk:
-      user_lst.append(chk[0][0])
-    
-    for d in user_lst:
-      ch = addchild(ev, 'event_individuals', 'Event User', 0)
-      ch.person = d
-      ch.save(1)
+	# ====================================================================================================================		
+	def get_contact_details(self, arg):
+		arg = eval(arg)
+		contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s'" %(arg['contact_person'],arg['customer']), as_dict = 1)
+		ret = {
+			'contact_no' : contact and contact[0]['contact_no'] or '',
+			'email_id' : contact and contact[0]['email_id'] or ''
+		}
+		return ret
+		
+	# ====================================================================================================================
+	def on_update(self):
+		# Add to calendar
+		#if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date:
+		if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
+			if self.doc.contact_by:
+				self.add_calendar_event()
+			set(self.doc, 'contact_date_ref',self.doc.contact_date)
+		set(self.doc, 'status', 'Draft')
+	
+	# Add to Calendar
+	# ====================================================================================================================
+	def add_calendar_event(self):
+		desc=''
+		user_lst =[]
+		if self.doc.customer:
+			if self.doc.contact_person:
+				desc = 'Contact '+cstr(self.doc.contact_person)
+			else:
+				desc = 'Contact customer '+cstr(self.doc.customer)
+		elif self.doc.lead:
+			if self.doc.lead_name:
+				desc = 'Contact '+cstr(self.doc.lead_name)
+			else:
+				desc = 'Contact lead '+cstr(self.doc.lead)
+		desc = desc+ '. By : ' + cstr(self.doc.contact_by)
+		
+		if self.doc.to_discuss:
+			desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
+		
+		ev = Document('Event')
+		ev.description = desc
+		ev.event_date = self.doc.contact_date
+		ev.event_hour = '10:00'
+		ev.event_type = 'Private'
+		ev.ref_type = 'Enquiry'
+		ev.ref_name = self.doc.name
+		ev.save(1)
+		
+		user_lst.append(self.doc.owner)
+		
+		chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
+		if chk:
+			user_lst.append(chk[0][0])
+		
+		for d in user_lst:
+			ch = addchild(ev, 'event_individuals', 'Event User', 0)
+			ch.person = d
+			ch.save(1)
 
-  #--------------Validation For Last Contact Date-----------------
-  # ====================================================================================================================
-  def set_last_contact_date(self):
-    if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
-      if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
-        self.doc.last_contact_date=self.doc.contact_date_ref
-      else:
-        msgprint("Contact Date Cannot be before Last Contact Date")
-        raise Exception
-  
-  # check if item present in item table
-  # ====================================================================================================================
-  def validate_item_details(self):
-    if not getlist(self.doclist, 'enquiry_details'):
-      msgprint("Please select items for which enquiry needs to be made")
-      raise Exception
-  
-  #check if enquiry date in the range of fiscal year selected
-  #=====================================================
-  def validate_fiscal_year(self):
-    fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
-    ysd=fy and fy[0][0] or ""
-    yed=add_days(str(ysd),365)
-    if str(self.doc.transaction_date) < str(ysd) or str(self.doc.transaction_date) > str(yed):
-      msgprint("Enquiry Date is not within the Fiscal Year selected")
-      raise Exception    
-  
-  def validate(self):
-    self.validate_fiscal_year()
-    self.set_last_contact_date()
-    self.validate_item_details()
-    
-  # On Submit Functions
-  # ====================================================================================================================
-  def on_submit(self):
-    set(self.doc, 'status', 'Submitted')
-    
-  # ====================================================================================================================  
-  def on_cancel(self):
-    chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
-    if chk:
-      msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus can not be cancelled.")
-      raise Exception
-    else:
-      set(self.doc, 'status', 'Cancelled')
-    
-  # declare as enquiry lost
-  #---------------------------
-  def declare_enquiry_lost(self,arg):
-    chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
-    if chk:
-      msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus 'Enquiry Lost' can not be declared against it.")
-      raise Exception
-    else:
-      set(self.doc, 'status', 'Enquiry Lost')
-      set(self.doc, 'order_lost_reason', arg)
-      return 'true'
-    
-  # ====================================================================================================================  
-  def update_follow_up(self):
-    
-    sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name);
-    for d in getlist(self.doclist, 'follow_up'):    
-      d.save()
-    self.doc.save()
-    
-    
-  # On Send Email
-  # ====================================================================================================================
-  #def send_emails(self,email,sender,subject,message):
-  #  if email:
-  #    sendmail(email,sender,subject=subject or 'Enquiry',parts=[['text/plain',message or self.get_enq_summary()]])
+	#--------------Validation For Last Contact Date-----------------
+	# ====================================================================================================================
+	def set_last_contact_date(self):
+		if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
+			if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
+				self.doc.last_contact_date=self.doc.contact_date_ref
+			else:
+				msgprint("Contact Date Cannot be before Last Contact Date")
+				raise Exception
+	
+	# check if item present in item table
+	# ====================================================================================================================
+	def validate_item_details(self):
+		if not getlist(self.doclist, 'enquiry_details'):
+			msgprint("Please select items for which enquiry needs to be made")
+			raise Exception
+	
+	#check if enquiry date in the range of fiscal year selected
+	#=====================================================
+	def validate_fiscal_year(self):
+		fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
+		ysd=fy and fy[0][0] or ""
+		yed=add_days(str(ysd),365)
+		if str(self.doc.transaction_date) < str(ysd) or str(self.doc.transaction_date) > str(yed):
+			msgprint("Enquiry Date is not within the Fiscal Year selected")
+			raise Exception		
 
-  # Prepare HTML Table and Enter Enquiry Details in it, which will be added in enq summary
-  # ====================================================================================================================
-  def quote_table(self):
-    if getlist(self.doclist,'enq_details'):
-      header_lbl = ['Item Code','Item Name','Description','Reqd Qty','UOM']
-      item_tbl = '''<table style="width:90%%; border:1px solid #AAA; border-collapse:collapse"><tr>'''
-      for i in header_lbl:
-        item_header = '''<td style="width=20%%; border:1px solid #AAA; border-collapse:collapse;"><b>%s</b></td>''' % i
-        item_tbl += item_header
-      item_tbl += '''</tr>'''
-      
-      for d in getlist(self.doclist,'enq_details'):
-        item_det = '''
-          <tr><td style="width:20%%; border:1px solid #AAA; border-collpase:collapse">%s</td>
-          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
-          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
-          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
-          <td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td></tr>
-        ''' % (d.item_code,d.item_name,d.description,d.reqd_qty,d.uom)
-        item_tbl += item_det
-      item_tbl += '''</table>'''
-      return item_tbl
-      
-  # Prepare HTML Page containing summary of Enquiry, which will be sent as message in E-mail
-  # ====================================================================================================================
-  def get_enq_summary(self):
+	def validate_lead_cust(self):
+		if self.doc.enquiry_from == 'Lead' and not self.doc.lead:
+			msgprint("Lead Id is mandatory if 'Enquiry From' is selected as Lead", raise_exception=1)
+		elif self.doc.enquiry_from == 'Customer' and not self.doc.customer:
+			msgprint("Customer is mandatory if 'Enquiry From' is selected as Customer", raise_exception=1)
 
-    t = """
-        <html><head></head>
-        <body>
-          <div style="border:1px solid #AAA; padding:20px; width:100%%">
-            <div style="text-align:center;font-size:14px"><b>Request For Quotation</b><br></div>
-            <div style="text-align:center;font-size:12px"> %(from_company)s</div>
-            <div style="text-align:center; font-size:10px"> %(company_address)s</div>
-            <div style="border-bottom:1px solid #AAA; padding:10px"></div> 
-            
-            <div style="padding-top:10px"><b>Quotation Details</b></div>
-            <div><table style="width:100%%">
-            <tr><td style="width:40%%">Enquiry No:</td> <td style="width:60%%"> %(name)s</td></tr>
-            <tr><td style="width:40%%">Opening Date:</td> <td style="width:60%%"> %(transaction_date)s</td></tr>
-            <tr><td style="width:40%%">Expected By Date:</td> <td style="width:60%%"> %(expected_date)s</td></tr>
-            </table>
-            </div>
-            
-            <div style="padding-top:10px"><b>Terms and Conditions</b></div>
-            <div> %(terms_and_conditions)s</div>
-            
-            <div style="padding-top:10px"><b>Contact Details</b></div>
-            <div><table style="width:100%%">
-            <tr><td style="width=40%%">Contact Person:</td><td style="width:60%%"> %(contact_person)s</td></tr>
-            <tr><td style="width=40%%">Contact No:</td><td style="width:60%%"> %(contact_no)s</td></tr>
-            <tr><td style="width=40%%">Email:</td><td style="width:60%%"> %(email)s</td></tr>
-            </table></div>
-            """ % (self.doc.fields)
-    
-    t += """<br><div><b>Quotation Items</b><br></div><div style="width:100%%">%s</div>
-            <br>
+	
+	def validate(self):
+		self.validate_fiscal_year()
+		self.set_last_contact_date()
+		self.validate_item_details()
+		self.validate_lead_cust()
+		
+	# On Submit Functions
+	# ====================================================================================================================
+	def on_submit(self):
+		set(self.doc, 'status', 'Submitted')
+		
+	# ====================================================================================================================	
+	def on_cancel(self):
+		chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
+		if chk:
+			msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus can not be cancelled.")
+			raise Exception
+		else:
+			set(self.doc, 'status', 'Cancelled')
+		
+	# declare as enquiry lost
+	#---------------------------
+	def declare_enquiry_lost(self,arg):
+		chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
+		if chk:
+			msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus 'Enquiry Lost' can not be declared against it.")
+			raise Exception
+		else:
+			set(self.doc, 'status', 'Enquiry Lost')
+			set(self.doc, 'order_lost_reason', arg)
+			return 'true'
+		
+	# ====================================================================================================================	
+	def update_follow_up(self):
+		
+		sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name);
+		for d in getlist(self.doclist, 'follow_up'):		
+			d.save()
+		self.doc.save()
+		
+		
+	# On Send Email
+	# ====================================================================================================================
+	#def send_emails(self,email,sender,subject,message):
+	#	if email:
+	#		sendmail(email,sender,subject=subject or 'Enquiry',parts=[['text/plain',message or self.get_enq_summary()]])
+
+	# Prepare HTML Table and Enter Enquiry Details in it, which will be added in enq summary
+	# ====================================================================================================================
+	def quote_table(self):
+		if getlist(self.doclist,'enq_details'):
+			header_lbl = ['Item Code','Item Name','Description','Reqd Qty','UOM']
+			item_tbl = '''<table style="width:90%%; border:1px solid #AAA; border-collapse:collapse"><tr>'''
+			for i in header_lbl:
+				item_header = '''<td style="width=20%%; border:1px solid #AAA; border-collapse:collapse;"><b>%s</b></td>''' % i
+				item_tbl += item_header
+			item_tbl += '''</tr>'''
+			
+			for d in getlist(self.doclist,'enq_details'):
+				item_det = '''
+					<tr><td style="width:20%%; border:1px solid #AAA; border-collpase:collapse">%s</td>
+					<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
+					<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
+					<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
+					<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td></tr>
+				''' % (d.item_code,d.item_name,d.description,d.reqd_qty,d.uom)
+				item_tbl += item_det
+			item_tbl += '''</table>'''
+			return item_tbl
+			
+	# Prepare HTML Page containing summary of Enquiry, which will be sent as message in E-mail
+	# ====================================================================================================================
+	def get_enq_summary(self):
+
+		t = """
+				<html><head></head>
+				<body>
+					<div style="border:1px solid #AAA; padding:20px; width:100%%">
+						<div style="text-align:center;font-size:14px"><b>Request For Quotation</b><br></div>
+						<div style="text-align:center;font-size:12px"> %(from_company)s</div>
+						<div style="text-align:center; font-size:10px"> %(company_address)s</div>
+						<div style="border-bottom:1px solid #AAA; padding:10px"></div> 
+						
+						<div style="padding-top:10px"><b>Quotation Details</b></div>
+						<div><table style="width:100%%">
+						<tr><td style="width:40%%">Enquiry No:</td> <td style="width:60%%"> %(name)s</td></tr>
+						<tr><td style="width:40%%">Opening Date:</td> <td style="width:60%%"> %(transaction_date)s</td></tr>
+						<tr><td style="width:40%%">Expected By Date:</td> <td style="width:60%%"> %(expected_date)s</td></tr>
+						</table>
+						</div>
+						
+						<div style="padding-top:10px"><b>Terms and Conditions</b></div>
+						<div> %(terms_and_conditions)s</div>
+						
+						<div style="padding-top:10px"><b>Contact Details</b></div>
+						<div><table style="width:100%%">
+						<tr><td style="width=40%%">Contact Person:</td><td style="width:60%%"> %(contact_person)s</td></tr>
+						<tr><td style="width=40%%">Contact No:</td><td style="width:60%%"> %(contact_no)s</td></tr>
+						<tr><td style="width=40%%">Email:</td><td style="width:60%%"> %(email)s</td></tr>
+						</table></div>
+						""" % (self.doc.fields)
+		
+		t += """<br><div><b>Quotation Items</b><br></div><div style="width:100%%">%s</div>
+						<br>
 To login into the system, use link : <div><a href='http://67.205.111.118/v160/login.html' target='_blank'>http://67.205.111.118/v160/login.html</a></div><br><br>
-            </div>
-          </body>
-          </html>
-          """ % (self.quote_table())
-    return t
-      
-  #-----------------Email-------------------------------------------- 
-  # ====================================================================================================================
-  def send_emails(self, email=[], subject='', message=''):
-    if email:
-      sender_email= sql("Select email from `tabProfile` where name='%s'"%session['user'])
-      if sender_email and sender_email[0][0]:
-        attach_list=[]
-        for at in getlist(self.doclist,'enquiry_attachment_detail'):
-          if at.select_file:
-            attach_list.append(at.select_file)
-        cc_list=[]
-        if self.doc.cc_to:
-          for cl in (self.doc.cc_to.split(',')):
-            if not validate_email_add(cl.strip(' ')):
-              msgprint('error:%s is not a valid email id' % cl.strip(' '))
-              raise Exception
-            cc_list.append(cl.strip(' ')) 
-            sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list)           
-        sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list)
-        #sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
-        msgprint("Mail has been sent")
-        self.add_in_follow_up(message,'Email')
-      else:
-        msgprint("Please enter your mail id in Profile")
-        raise Exception
-  
-  #-------------------------Checking Sent Mails Details----------------------------------------------
-  # ====================================================================================================================
-  def sent_mail(self):
-    if not self.doc.subject or not self.doc.message:
-      msgprint("Please enter subject & message in their respective fields.")
-    elif not self.doc.email_id1:
-      msgprint("Recipient not specified. Please add email id in 'Send To'.")
-      raise Exception
-    else :
-      if not validate_email_add(self.doc.email_id1.strip(' ')):
-        msgprint('error:%s is not a valid email id' % self.doc.email_id1)
-      else:
-        self.send_emails([self.doc.email_id1.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
+						</div>
+					</body>
+					</html>
+					""" % (self.quote_table())
+		return t
+			
+	#-----------------Email-------------------------------------------- 
+	# ====================================================================================================================
+	def send_emails(self, email=[], subject='', message=''):
+		if email:
+			sender_email= sql("Select email from `tabProfile` where name='%s'"%session['user'])
+			if sender_email and sender_email[0][0]:
+				attach_list=[]
+				for at in getlist(self.doclist,'enquiry_attachment_detail'):
+					if at.select_file:
+						attach_list.append(at.select_file)
+				cc_list=[]
+				if self.doc.cc_to:
+					for cl in (self.doc.cc_to.split(',')):
+						if not validate_email_add(cl.strip(' ')):
+							msgprint('error:%s is not a valid email id' % cl.strip(' '))
+							raise Exception
+						cc_list.append(cl.strip(' ')) 
+						sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list)					 
+				sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list)
+				#sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
+				msgprint("Mail has been sent")
+				self.add_in_follow_up(message,'Email')
+			else:
+				msgprint("Please enter your mail id in Profile")
+				raise Exception
+	
+	#-------------------------Checking Sent Mails Details----------------------------------------------
+	# ====================================================================================================================
+	def sent_mail(self):
+		if not self.doc.subject or not self.doc.message:
+			msgprint("Please enter subject & message in their respective fields.")
+		elif not self.doc.email_id1:
+			msgprint("Recipient not specified. Please add email id in 'Send To'.")
+			raise Exception
+		else :
+			if not validate_email_add(self.doc.email_id1.strip(' ')):
+				msgprint('error:%s is not a valid email id' % self.doc.email_id1)
+			else:
+				self.send_emails([self.doc.email_id1.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
 
-  #---------------------- Add details in follow up table----------------
-  # ====================================================================================================================
-  def add_in_follow_up(self,message,type):
-    import datetime
-    child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
-    child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
-    child.notes = message
-    child.follow_up_type = type
-    child.save()
+	#---------------------- Add details in follow up table----------------
+	# ====================================================================================================================
+	def add_in_follow_up(self,message,type):
+		import datetime
+		child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
+		child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
+		child.notes = message
+		child.follow_up_type = type
+		child.save()
 
-  #-------------------SMS----------------------------------------------
-  # ====================================================================================================================
-  def send_sms(self):
-    if not self.doc.sms_message:
-      msgprint("Please enter message in SMS Section ")
-      raise Exception
-    elif not getlist(self.doclist, 'enquiry_sms_detail'):
-      msgprint("Please mention mobile no. to which sms needs to be sent")
-      raise Exception
-    else:
-      receiver_list = []
-      for d in getlist(self.doclist,'enquiry_sms_detail'):
-        if d.other_mobile_no:
-          receiver_list.append(d.other_mobile_no)
-    
-    if receiver_list:
-      msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
-      self.add_in_follow_up(self.doc.sms_message,'SMS')
+	#-------------------SMS----------------------------------------------
+	# ====================================================================================================================
+	def send_sms(self):
+		if not self.doc.sms_message:
+			msgprint("Please enter message in SMS Section ")
+			raise Exception
+		elif not getlist(self.doclist, 'enquiry_sms_detail'):
+			msgprint("Please mention mobile no. to which sms needs to be sent")
+			raise Exception
+		else:
+			receiver_list = []
+			for d in getlist(self.doclist,'enquiry_sms_detail'):
+				if d.other_mobile_no:
+					receiver_list.append(d.other_mobile_no)
+		
+		if receiver_list:
+			msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
+			self.add_in_follow_up(self.doc.sms_message,'SMS')
diff --git a/erpnext/selling/doctype/enquiry/enquiry.txt b/erpnext/selling/doctype/enquiry/enquiry.txt
index 0bf3b7f..0a21d8a 100644
--- a/erpnext/selling/doctype/enquiry/enquiry.txt
+++ b/erpnext/selling/doctype/enquiry/enquiry.txt
@@ -5,51 +5,51 @@
 	{
 		'creation': '2010-08-08 17:09:00',
 		'docstatus': 0,
-		'modified': '2011-12-19 14:11:27',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
+		'modified': '2012-03-07 13:10:00',
+		'modified_by': u'Administrator',
+		'owner': u'Administrator'
 	},
 
 	# These values are common for all DocType
 	{
-		'_last_update': '1316075905',
-		'colour': 'White:FFF',
-		'default_print_format': 'Standard',
+		'_last_update': u'1324284087',
+		'colour': u'White:FFF',
+		'default_print_format': u'Standard',
 		'doctype': 'DocType',
-		'document_type': 'Transaction',
-		'module': 'Selling',
+		'document_type': u'Transaction',
+		'module': u'Selling',
 		'name': '__common__',
-		'search_fields': 'status,transaction_date,customer,lead,enquiry_type,territory,company',
-		'section_style': 'Tabbed',
-		'server_code_error': ' ',
+		'search_fields': u'status,transaction_date,customer,lead,enquiry_type,territory,company',
+		'section_style': u'Tabbed',
+		'server_code_error': u' ',
 		'show_in_menu': 0,
-		'subject': 'To %(customer_name)s%(lead_name)s on %(transaction_date)s',
-		'version': 587
+		'subject': u'To %(customer_name)s%(lead_name)s on %(transaction_date)s',
+		'version': 588
 	},
 
 	# These values are common for all DocField
 	{
-		'doctype': 'DocField',
+		'doctype': u'DocField',
 		'name': '__common__',
-		'parent': 'Enquiry',
-		'parentfield': 'fields',
-		'parenttype': 'DocType'
+		'parent': u'Enquiry',
+		'parentfield': u'fields',
+		'parenttype': u'DocType'
 	},
 
 	# These values are common for all DocPerm
 	{
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'name': '__common__',
-		'parent': 'Enquiry',
-		'parentfield': 'permissions',
-		'parenttype': 'DocType',
+		'parent': u'Enquiry',
+		'parentfield': u'permissions',
+		'parenttype': u'DocType',
 		'read': 1
 	},
 
 	# DocType, Enquiry
 	{
 		'doctype': 'DocType',
-		'name': 'Enquiry'
+		'name': u'Enquiry'
 	},
 
 	# DocPerm
@@ -57,9 +57,9 @@
 		'amend': 0,
 		'cancel': 0,
 		'create': 0,
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': 'Sales Manager',
+		'role': u'Sales Manager',
 		'submit': 0,
 		'write': 0
 	},
@@ -69,18 +69,18 @@
 		'amend': 1,
 		'cancel': 1,
 		'create': 1,
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': 'System Manager',
+		'role': u'System Manager',
 		'submit': 1,
 		'write': 1
 	},
 
 	# DocPerm
 	{
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': 'System Manager'
+		'role': u'System Manager'
 	},
 
 	# DocPerm
@@ -88,9 +88,9 @@
 		'amend': 1,
 		'cancel': 1,
 		'create': 1,
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': 'Sales User',
+		'role': u'Sales User',
 		'submit': 1,
 		'write': 1
 	},
@@ -100,9 +100,9 @@
 		'amend': 0,
 		'cancel': 0,
 		'create': 0,
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'permlevel': 1,
-		'role': 'Sales User',
+		'role': u'Sales User',
 		'submit': 0,
 		'write': 0
 	},
@@ -112,353 +112,353 @@
 		'amend': 1,
 		'cancel': 1,
 		'create': 1,
-		'doctype': 'DocPerm',
+		'doctype': u'DocPerm',
 		'permlevel': 0,
-		'role': 'Sales Manager',
+		'role': u'Sales Manager',
 		'submit': 1,
 		'write': 1
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'Enter customer enquiry for which you might raise a quotation in future',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'label': 'Basic Info',
-		'oldfieldtype': 'Section Break',
+		'colour': u'White:FFF',
+		'description': u'Enter customer enquiry for which you might raise a quotation in future',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'Basic Info',
+		'oldfieldtype': u'Section Break',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'To manage multiple series please go to Setup > Manage Series',
-		'doctype': 'DocField',
-		'fieldname': 'naming_series',
-		'fieldtype': 'Select',
-		'label': 'Series',
+		'colour': u'White:FFF',
+		'description': u'To manage multiple series please go to Setup > Manage Series',
+		'doctype': u'DocField',
+		'fieldname': u'naming_series',
+		'fieldtype': u'Select',
+		'label': u'Series',
 		'no_copy': 1,
-		'oldfieldname': 'naming_series',
-		'oldfieldtype': 'Select',
-		'options': 'ENQUIRY\nENQ',
+		'oldfieldname': u'naming_series',
+		'oldfieldtype': u'Select',
+		'options': u'ENQUIRY\nENQ',
 		'permlevel': 0,
 		'reqd': 1
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldname': 'enquiry_from',
-		'fieldtype': 'Select',
-		'label': 'Enquiry From',
-		'oldfieldname': 'enquiry_from',
-		'oldfieldtype': 'Select',
-		'options': '\nLead\nCustomer',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldname': u'enquiry_from',
+		'fieldtype': u'Select',
+		'label': u'Enquiry From',
+		'oldfieldname': u'enquiry_from',
+		'oldfieldtype': u'Select',
+		'options': u'\nLead\nCustomer',
 		'permlevel': 0,
 		'print_hide': 1,
 		'report_hide': 0,
 		'reqd': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldname': 'customer',
-		'fieldtype': 'Link',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldname': u'customer',
+		'fieldtype': u'Link',
 		'hidden': 0,
 		'in_filter': 1,
-		'label': 'Customer',
-		'oldfieldname': 'customer',
-		'oldfieldtype': 'Link',
-		'options': 'Customer',
+		'label': u'Customer',
+		'oldfieldname': u'customer',
+		'oldfieldtype': u'Link',
+		'options': u'Customer',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 0,
 		'search_index': 0,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'customer_address',
-		'fieldtype': 'Link',
+		'doctype': u'DocField',
+		'fieldname': u'customer_address',
+		'fieldtype': u'Link',
 		'in_filter': 1,
-		'label': 'Customer Address',
-		'options': 'Address',
+		'label': u'Customer Address',
+		'options': u'Address',
 		'permlevel': 0,
 		'print_hide': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'contact_person',
-		'fieldtype': 'Link',
+		'doctype': u'DocField',
+		'fieldname': u'contact_person',
+		'fieldtype': u'Link',
 		'in_filter': 1,
-		'label': 'Contact Person',
-		'options': 'Contact',
+		'label': u'Contact Person',
+		'options': u'Contact',
 		'permlevel': 0,
 		'print_hide': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'customer_name',
-		'fieldtype': 'Data',
-		'label': 'Customer Name',
+		'doctype': u'DocField',
+		'fieldname': u'customer_name',
+		'fieldtype': u'Data',
+		'label': u'Customer Name',
 		'permlevel': 1,
 		'print_hide': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'lead',
-		'fieldtype': 'Link',
+		'doctype': u'DocField',
+		'fieldname': u'lead',
+		'fieldtype': u'Link',
 		'hidden': 0,
 		'in_filter': 1,
-		'label': 'Lead',
-		'oldfieldname': 'lead',
-		'oldfieldtype': 'Link',
-		'options': 'Lead',
+		'label': u'Lead',
+		'oldfieldname': u'lead',
+		'oldfieldtype': u'Link',
+		'options': u'Lead',
 		'permlevel': 0,
 		'print_hide': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'lead_name',
-		'fieldtype': 'Data',
+		'doctype': u'DocField',
+		'fieldname': u'lead_name',
+		'fieldtype': u'Data',
 		'hidden': 0,
-		'label': 'Name',
-		'oldfieldname': 'lead_name',
-		'oldfieldtype': 'Data',
+		'label': u'Name',
+		'oldfieldname': u'lead_name',
+		'oldfieldtype': u'Data',
 		'permlevel': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'address_display',
-		'fieldtype': 'Small Text',
+		'doctype': u'DocField',
+		'fieldname': u'address_display',
+		'fieldtype': u'Small Text',
 		'hidden': 0,
-		'label': 'Address',
-		'oldfieldname': 'address',
-		'oldfieldtype': 'Small Text',
+		'label': u'Address',
+		'oldfieldname': u'address',
+		'oldfieldtype': u'Small Text',
 		'permlevel': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'contact_display',
-		'fieldtype': 'Small Text',
-		'label': 'Contact',
+		'doctype': u'DocField',
+		'fieldname': u'contact_display',
+		'fieldtype': u'Small Text',
+		'label': u'Contact',
 		'permlevel': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'contact_mobile',
-		'fieldtype': 'Text',
-		'label': 'Contact Mobile No',
+		'doctype': u'DocField',
+		'fieldname': u'contact_mobile',
+		'fieldtype': u'Text',
+		'label': u'Contact Mobile No',
 		'permlevel': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'contact_email',
-		'fieldtype': 'Text',
-		'label': 'Contact Email',
+		'doctype': u'DocField',
+		'fieldname': u'contact_email',
+		'fieldtype': u'Text',
+		'label': u'Contact Email',
 		'permlevel': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'oldfieldtype': 'Column Break',
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
+		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
-		'width': '50%'
+		'width': u'50%'
 	},
 
 	# DocField
 	{
-		'default': 'Today',
-		'description': 'The date at which current entry is made in system.',
-		'doctype': 'DocField',
-		'fieldname': 'transaction_date',
-		'fieldtype': 'Date',
-		'label': 'Enquiry Date',
-		'oldfieldname': 'transaction_date',
-		'oldfieldtype': 'Date',
+		'default': u'Today',
+		'description': u'The date at which current entry is made in system.',
+		'doctype': u'DocField',
+		'fieldname': u'transaction_date',
+		'fieldtype': u'Date',
+		'label': u'Enquiry Date',
+		'oldfieldname': u'transaction_date',
+		'oldfieldtype': u'Date',
 		'permlevel': 0,
 		'reqd': 1,
-		'width': '50px'
+		'width': u'50px'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldname': 'enquiry_type',
-		'fieldtype': 'Select',
-		'label': 'Enquiry Type',
-		'oldfieldname': 'enquiry_type',
-		'oldfieldtype': 'Select',
-		'options': '\nSales\nMaintenance',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldname': u'enquiry_type',
+		'fieldtype': u'Select',
+		'label': u'Enquiry Type',
+		'oldfieldname': u'enquiry_type',
+		'oldfieldtype': u'Select',
+		'options': u'\nSales\nMaintenance',
 		'permlevel': 0,
 		'reqd': 1
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'default': 'Draft',
-		'doctype': 'DocField',
-		'fieldname': 'status',
-		'fieldtype': 'Select',
-		'label': 'Status',
+		'colour': u'White:FFF',
+		'default': u'Draft',
+		'doctype': u'DocField',
+		'fieldname': u'status',
+		'fieldtype': u'Select',
+		'label': u'Status',
 		'no_copy': 1,
-		'oldfieldname': 'status',
-		'oldfieldtype': 'Select',
-		'options': '\nDraft\nSubmitted\nQuotation Sent\nOrder Confirmed\nEnquiry Lost\nCancelled',
+		'oldfieldname': u'status',
+		'oldfieldtype': u'Select',
+		'options': u'\nDraft\nSubmitted\nQuotation Sent\nOrder Confirmed\nEnquiry Lost\nCancelled',
 		'permlevel': 1,
 		'reqd': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'amended_from',
-		'fieldtype': 'Data',
-		'label': 'Amended From',
+		'doctype': u'DocField',
+		'fieldname': u'amended_from',
+		'fieldtype': u'Data',
+		'label': u'Amended From',
 		'no_copy': 1,
-		'oldfieldname': 'amended_from',
-		'oldfieldtype': 'Data',
+		'oldfieldname': u'amended_from',
+		'oldfieldtype': u'Data',
 		'permlevel': 1,
 		'print_hide': 1,
-		'width': '150px'
+		'width': u'150px'
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'amendment_date',
-		'fieldtype': 'Date',
-		'label': 'Amendment Date',
+		'doctype': u'DocField',
+		'fieldname': u'amendment_date',
+		'fieldtype': u'Date',
+		'label': u'Amendment Date',
 		'no_copy': 1,
-		'oldfieldname': 'amendment_date',
-		'oldfieldtype': 'Date',
+		'oldfieldname': u'amendment_date',
+		'oldfieldtype': u'Date',
 		'permlevel': 1,
 		'print_hide': 1,
-		'width': '150px'
+		'width': u'150px'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': '<a href="javascript:cur_frm.cscript.TerritoryHelp();">To Manage Territory, click here</a>',
-		'doctype': 'DocField',
-		'fieldname': 'territory',
-		'fieldtype': 'Link',
+		'colour': u'White:FFF',
+		'description': u'<a href="javascript:cur_frm.cscript.TerritoryHelp();">To Manage Territory, click here</a>',
+		'doctype': u'DocField',
+		'fieldname': u'territory',
+		'fieldtype': u'Link',
 		'in_filter': 1,
-		'label': 'Territory',
-		'options': 'Territory',
-		'permlevel': 0,
-		'print_hide': 1,
-		'reqd': 1,
-		'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,
-		'in_filter': 1,
-		'label': 'Customer Group',
-		'oldfieldname': 'customer_group',
-		'oldfieldtype': 'Link',
-		'options': 'Customer Group',
+		'label': u'Territory',
+		'options': u'Territory',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 0,
 		'search_index': 1,
-		'trigger': 'Client'
+		'trigger': u'Client'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'label': 'Items',
-		'oldfieldtype': 'Section Break',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'description': "Items which do not exist in Item master can also be entered on customer's request",
-		'doctype': 'DocField',
-		'fieldname': 'enquiry_details',
-		'fieldtype': 'Table',
-		'label': 'Enquiry Details',
-		'oldfieldname': 'enquiry_details',
-		'oldfieldtype': 'Table',
-		'options': 'Enquiry Detail',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'colour': 'White:FFF',
-		'description': 'Filing in Additional Information about the Enquiry will help you analyze your data better.',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'label': 'More Info',
-		'oldfieldtype': 'Section Break',
-		'permlevel': 0
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'oldfieldtype': 'Column Break',
-		'permlevel': 0,
-		'width': '50%'
-	},
-
-	# DocField
-	{
-		'doctype': 'DocField',
-		'fieldname': 'company',
-		'fieldtype': 'Link',
+		'colour': u'White:FFF',
+		'depends_on': u'eval:doc.enquiry_from=="Customer"',
+		'description': u'<a href="javascript:cur_frm.cscript.CGHelp();">To Manage Customer Groups, click here</a>',
+		'doctype': u'DocField',
+		'fieldname': u'customer_group',
+		'fieldtype': u'Link',
+		'hidden': 0,
 		'in_filter': 1,
-		'label': 'Company',
-		'oldfieldname': 'company',
-		'oldfieldtype': 'Link',
-		'options': 'Company',
+		'label': u'Customer Group',
+		'oldfieldname': u'customer_group',
+		'oldfieldtype': u'Link',
+		'options': u'Customer Group',
+		'permlevel': 0,
+		'print_hide': 1,
+		'reqd': 0,
+		'search_index': 1,
+		'trigger': u'Client'
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'Items',
+		'oldfieldtype': u'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'description': u"Items which do not exist in Item master can also be entered on customer's request",
+		'doctype': u'DocField',
+		'fieldname': u'enquiry_details',
+		'fieldtype': u'Table',
+		'label': u'Enquiry Details',
+		'oldfieldname': u'enquiry_details',
+		'oldfieldtype': u'Table',
+		'options': u'Enquiry Detail',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'colour': u'White:FFF',
+		'description': u'Filing in Additional Information about the Enquiry will help you analyze your data better.',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'More Info',
+		'oldfieldtype': u'Section Break',
+		'permlevel': 0
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
+		'oldfieldtype': u'Column Break',
+		'permlevel': 0,
+		'width': u'50%'
+	},
+
+	# DocField
+	{
+		'doctype': u'DocField',
+		'fieldname': u'company',
+		'fieldtype': u'Link',
+		'in_filter': 1,
+		'label': u'Company',
+		'oldfieldname': u'company',
+		'oldfieldtype': u'Link',
+		'options': u'Company',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
@@ -467,14 +467,14 @@
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'fiscal_year',
-		'fieldtype': 'Select',
+		'doctype': u'DocField',
+		'fieldname': u'fiscal_year',
+		'fieldtype': u'Select',
 		'in_filter': 1,
-		'label': 'Fiscal Year',
-		'oldfieldname': 'fiscal_year',
-		'oldfieldtype': 'Select',
-		'options': 'link:Fiscal Year',
+		'label': u'Fiscal Year',
+		'oldfieldname': u'fiscal_year',
+		'oldfieldtype': u'Select',
+		'options': u'link:Fiscal Year',
 		'permlevel': 0,
 		'print_hide': 1,
 		'reqd': 1,
@@ -483,134 +483,134 @@
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'source',
-		'fieldtype': 'Select',
-		'label': 'Source',
-		'oldfieldname': 'source',
-		'oldfieldtype': 'Select',
-		'options': "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign\nWalk In",
+		'doctype': u'DocField',
+		'fieldname': u'source',
+		'fieldtype': u'Select',
+		'label': u'Source',
+		'oldfieldname': u'source',
+		'oldfieldtype': u'Select',
+		'options': u"\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign\nWalk In",
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'Enter name of campaign if source of enquiry is campaign',
-		'doctype': 'DocField',
-		'fieldname': 'campaign',
-		'fieldtype': 'Link',
-		'label': 'Campaign',
-		'oldfieldname': 'campaign',
-		'oldfieldtype': 'Link',
-		'options': 'Campaign',
+		'colour': u'White:FFF',
+		'description': u'Enter name of campaign if source of enquiry is campaign',
+		'doctype': u'DocField',
+		'fieldname': u'campaign',
+		'fieldtype': u'Link',
+		'label': u'Campaign',
+		'oldfieldname': u'campaign',
+		'oldfieldtype': u'Link',
+		'options': u'Campaign',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'depends_on': 'eval:!doc.__islocal',
-		'doctype': 'DocField',
-		'fieldname': 'order_lost_reason',
-		'fieldtype': 'Small Text',
-		'label': 'Order Lost Reason',
+		'colour': u'White:FFF',
+		'depends_on': u'eval:!doc.__islocal',
+		'doctype': u'DocField',
+		'fieldname': u'order_lost_reason',
+		'fieldtype': u'Small Text',
+		'label': u'Order Lost Reason',
 		'no_copy': 1,
-		'oldfieldname': 'order_lost_reason',
-		'oldfieldtype': 'Small Text',
+		'oldfieldname': u'order_lost_reason',
+		'oldfieldtype': u'Small Text',
 		'permlevel': 1,
 		'report_hide': 0
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldtype': 'Column Break',
-		'oldfieldtype': 'Column Break',
+		'doctype': u'DocField',
+		'fieldtype': u'Column Break',
+		'oldfieldtype': u'Column Break',
 		'permlevel': 0,
-		'width': '50%'
+		'width': u'50%'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'Your sales person who will contact the customer in future',
-		'doctype': 'DocField',
-		'fieldname': 'contact_by',
-		'fieldtype': 'Link',
+		'colour': u'White:FFF',
+		'description': u'Your sales person who will contact the customer in future',
+		'doctype': u'DocField',
+		'fieldname': u'contact_by',
+		'fieldtype': u'Link',
 		'in_filter': 1,
-		'label': 'Next Contact By',
-		'oldfieldname': 'contact_by',
-		'oldfieldtype': 'Link',
-		'options': 'Profile',
+		'label': u'Next Contact By',
+		'oldfieldname': u'contact_by',
+		'oldfieldtype': u'Link',
+		'options': u'Profile',
 		'permlevel': 0,
-		'width': '75px'
+		'width': u'75px'
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'Your sales person will get a reminder on this date to contact the customer',
-		'doctype': 'DocField',
-		'fieldname': 'contact_date',
-		'fieldtype': 'Date',
-		'label': 'Next Contact Date',
-		'oldfieldname': 'contact_date',
-		'oldfieldtype': 'Date',
+		'colour': u'White:FFF',
+		'description': u'Your sales person will get a reminder on this date to contact the customer',
+		'doctype': u'DocField',
+		'fieldname': u'contact_date',
+		'fieldtype': u'Date',
+		'label': u'Next Contact Date',
+		'oldfieldname': u'contact_date',
+		'oldfieldtype': u'Date',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
 		'allow_on_submit': 0,
-		'colour': 'White:FFF',
-		'depends_on': 'eval:!doc.__islocal',
-		'description': 'Date on which the lead was last contacted',
-		'doctype': 'DocField',
-		'fieldname': 'last_contact_date',
-		'fieldtype': 'Date',
-		'label': 'Last Contact Date',
+		'colour': u'White:FFF',
+		'depends_on': u'eval:!doc.__islocal',
+		'description': u'Date on which the lead was last contacted',
+		'doctype': u'DocField',
+		'fieldname': u'last_contact_date',
+		'fieldtype': u'Date',
+		'label': u'Last Contact Date',
 		'no_copy': 1,
-		'oldfieldname': 'last_contact_date',
-		'oldfieldtype': 'Date',
+		'oldfieldname': u'last_contact_date',
+		'oldfieldtype': u'Date',
 		'permlevel': 1,
 		'print_hide': 1
 	},
 
 	# DocField
 	{
-		'doctype': 'DocField',
-		'fieldname': 'to_discuss',
-		'fieldtype': 'Small Text',
-		'label': 'To Discuss',
+		'doctype': u'DocField',
+		'fieldname': u'to_discuss',
+		'fieldtype': u'Small Text',
+		'label': u'To Discuss',
 		'no_copy': 1,
-		'oldfieldname': 'to_discuss',
-		'oldfieldtype': 'Small Text',
+		'oldfieldname': u'to_discuss',
+		'oldfieldtype': u'Small Text',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
-		'colour': 'White:FFF',
-		'description': 'Keep a track of communication related to this enquiry which will help for future reference.',
-		'doctype': 'DocField',
-		'fieldtype': 'Section Break',
-		'label': 'Communication History',
-		'oldfieldtype': 'Section Break',
+		'colour': u'White:FFF',
+		'description': u'Keep a track of communication related to this enquiry which will help for future reference.',
+		'doctype': u'DocField',
+		'fieldtype': u'Section Break',
+		'label': u'Communication History',
+		'oldfieldtype': u'Section Break',
 		'permlevel': 0
 	},
 
 	# DocField
 	{
 		'allow_on_submit': 1,
-		'colour': 'White:FFF',
-		'doctype': 'DocField',
-		'fieldname': 'follow_up',
-		'fieldtype': 'Table',
-		'label': 'Follow Up',
-		'oldfieldname': 'follow_up',
-		'oldfieldtype': 'Table',
-		'options': 'Follow up',
+		'colour': u'White:FFF',
+		'doctype': u'DocField',
+		'fieldname': u'follow_up',
+		'fieldtype': u'Table',
+		'label': u'Follow Up',
+		'oldfieldname': u'follow_up',
+		'oldfieldtype': u'Table',
+		'options': u'Follow up',
 		'permlevel': 0
 	}
 ]
\ No newline at end of file