Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
diff --git a/accounts/doctype/pos_setting/test_pos_setting.py b/accounts/doctype/pos_setting/test_pos_setting.py
index 2373f85..d6556ae 100644
--- a/accounts/doctype/pos_setting/test_pos_setting.py
+++ b/accounts/doctype/pos_setting/test_pos_setting.py
@@ -12,5 +12,6 @@
 		"income_account": "Sales - _TC",
 		"cost_center": "_Test Cost Center - _TC",
 		"expense_account": "_Test Account Cost for Goods Sold - _TC",
+		"naming_series": "_T-Sales Invoice-"
 	}]
 ]
\ No newline at end of file
diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 2ae569b..55a6a81 100644
--- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -366,6 +366,7 @@
 		# parent
 		{
 			"doctype": "Purchase Invoice",
+			"naming_series": "_T-Purchase Invoice-",
 			"supplier_name": "_Test Supplier",
 			"credit_to": "_Test Supplier - _TC",
 			"bill_no": "NA",
diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py
index 777f515..db08a4f 100644
--- a/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -423,6 +423,7 @@
 		from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \
 			as pr_test_records
 		pr = webnotes.bean(copy=pr_test_records[0])
+		pr.doc.naming_series = "_T-Purchase Receipt-"
 		pr.run_method("calculate_taxes_and_totals")
 		pr.insert()
 		pr.submit()
@@ -431,6 +432,7 @@
 		from stock.doctype.delivery_note.test_delivery_note import test_records \
 			as dn_test_records
 		dn = webnotes.bean(copy=dn_test_records[0])
+		dn.doc.naming_series = "_T-Delivery Note-"
 		dn.insert()
 		dn.submit()
 		return dn
diff --git a/accounts/doctype/shipping_rule/test_shipping_rule.py b/accounts/doctype/shipping_rule/test_shipping_rule.py
index 23d204d..fe11e2b 100644
--- a/accounts/doctype/shipping_rule/test_shipping_rule.py
+++ b/accounts/doctype/shipping_rule/test_shipping_rule.py
@@ -32,6 +32,7 @@
 	[
 		{
 			"doctype": "Shipping Rule",
+			"label": "_Test Shipping Rule",
 			"calculate_based_on": "Net Total",
 			"company": "_Test Company",
 			"account": "_Test Account Shipping Charges - _TC",
diff --git a/buying/doctype/purchase_order/test_purchase_order.py b/buying/doctype/purchase_order/test_purchase_order.py
index e70de97..f1cf34d 100644
--- a/buying/doctype/purchase_order/test_purchase_order.py
+++ b/buying/doctype/purchase_order/test_purchase_order.py
@@ -37,6 +37,7 @@
 		self.assertEquals(pr[0]["doctype"], "Purchase Receipt")
 		self.assertEquals(len(pr), len(test_records[0]))
 		
+		pr[0].naming_series = "_T-Purchase Receipt-"
 		webnotes.bean(pr).insert()
 		
 	def test_make_purchase_invocie(self):
@@ -54,6 +55,7 @@
 		self.assertEquals(pi[0]["doctype"], "Purchase Invoice")
 		self.assertEquals(len(pi), len(test_records[0]))
 
+		pi[0].bill_no = "NA"
 		webnotes.bean(pi).insert()
 		
 	def test_subcontracting(self):
@@ -75,6 +77,7 @@
 	[
 		{
 			"company": "_Test Company", 
+			"naming_series": "_T-Purchase Order-",
 			"conversion_rate": 1.0, 
 			"currency": "INR", 
 			"doctype": "Purchase Order", 
@@ -86,7 +89,6 @@
 			"net_total": 5000.0, 
 			"grand_total": 5000.0,
 			"grand_total_import": 5000.0,
-			
 		}, 
 		{
 			"conversion_factor": 1.0, 
@@ -101,6 +103,7 @@
 			"warehouse": "_Test Warehouse", 
 			"stock_uom": "Nos", 
 			"uom": "_Test UOM",
+			"schedule_date": "2013-03-01"
 		}
 	],
 ]
\ No newline at end of file
diff --git a/buying/doctype/supplier_quotation/test_supplier_quotation.py b/buying/doctype/supplier_quotation/test_supplier_quotation.py
index 7e772cc..813b2f8 100644
--- a/buying/doctype/supplier_quotation/test_supplier_quotation.py
+++ b/buying/doctype/supplier_quotation/test_supplier_quotation.py
@@ -36,6 +36,12 @@
 		self.assertEquals(po[0]["doctype"], "Purchase Order")
 		self.assertEquals(len(po), len(sq.doclist))
 		
+		po[0]["naming_series"] = "_T-Purchase Order-"
+
+		for doc in po:
+			if doc.get("item_code"):
+				doc["schedule_date"] = "2013-04-12"
+
 		webnotes.bean(po).insert()
 		
 test_records = [
@@ -53,7 +59,7 @@
 			"net_total": 5000.0, 
 			"grand_total": 5000.0,
 			"grand_total_import": 5000.0,
-			
+			"naming_series": "_T-Supplier Quotation-"
 		}, 
 		{
 			"description": "_Test FG Item", 
diff --git a/manufacturing/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt
index e677302..693f17d 100644
--- a/manufacturing/doctype/bom/bom.txt
+++ b/manufacturing/doctype/bom/bom.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-01-22 15:11:38", 
   "docstatus": 0, 
-  "modified": "2013-07-05 14:27:38", 
+  "modified": "2013-07-08 16:18:33", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -247,7 +247,6 @@
   "print_hide": 0
  }, 
  {
-  "default": "No Toolbar", 
   "doctype": "DocField", 
   "fieldname": "flat_bom_details", 
   "fieldtype": "Table", 
diff --git a/selling/doctype/lead/lead.py b/selling/doctype/lead/lead.py
index 4dde84a..a97611e 100644
--- a/selling/doctype/lead/lead.py
+++ b/selling/doctype/lead/lead.py
@@ -100,7 +100,17 @@
 @webnotes.whitelist()
 def make_customer(source_name, target_doclist=None):
 	from webnotes.model.mapper import get_mapped_doclist
-		
+	
+	def set_missing_values(source, target):
+		if source.doc.company_name:
+			target[0].customer_type = "Company"
+			target[0].customer_name = source.doc.company_name
+		else:
+			target[0].customer_type = "Individual"
+			target[0].customer_name = source.doc.lead_name
+			
+		target[0].customer_group = webnotes.conn.get_default("customer_group")
+			
 	doclist = get_mapped_doclist("Lead", source_name, 
 		{"Lead": {
 			"doctype": "Customer",
@@ -110,7 +120,7 @@
 				"contact_no": "phone_1",
 				"fax": "fax_1"
 			}
-		}}, target_doclist)
+		}}, target_doclist, set_missing_values)
 		
 	return [d.fields for d in doclist]
 	
diff --git a/selling/doctype/lead/test_lead.py b/selling/doctype/lead/test_lead.py
index 3fc177f..3893a3f 100644
--- a/selling/doctype/lead/test_lead.py
+++ b/selling/doctype/lead/test_lead.py
@@ -2,7 +2,7 @@
 
 test_records = [
 	[{"doctype":"Lead", "lead_name": "_Test Lead", "status":"Open", 
-		"email_id":"test_lead@example.com"}],
+		"email_id":"test_lead@example.com", "territory": "_Test Territory"}],
 	[{"doctype":"Lead", "lead_name": "_Test Lead 1", "status":"Open", 
 		"email_id":"test_lead1@example.com"}],
 	[{"doctype":"Lead", "lead_name": "_Test Lead 2", "status":"Contacted", 
@@ -21,6 +21,7 @@
 		customer = make_customer("_T-Lead-00001")
 		self.assertEquals(customer[0]["doctype"], "Customer")
 		self.assertEquals(customer[0]["lead_name"], "_T-Lead-00001")
-
+		
+		customer[0].customer_group = "_Test Customer Group"
 		webnotes.bean(customer).insert()
 		
\ No newline at end of file
diff --git a/selling/doctype/quotation/test_quotation.py b/selling/doctype/quotation/test_quotation.py
index de609b8..49fa736 100644
--- a/selling/doctype/quotation/test_quotation.py
+++ b/selling/doctype/quotation/test_quotation.py
@@ -22,9 +22,7 @@
 		self.assertEquals(sales_order[0]["customer"], "_Test Customer")
 		
 		sales_order[0]["delivery_date"] = "2014-01-01"
-		
-
-		webnotes.print_messages = True
+		sales_order[0]["naming_series"] = "_T-Quotation-"
 		webnotes.bean(sales_order).insert()
 
 
@@ -34,6 +32,7 @@
 			"company": "_Test Company", 
 			"conversion_rate": 1.0, 
 			"currency": "INR", 
+			"quotation_to": "Customer",
 			"customer": "_Test Customer", 
 			"customer_name": "_Test Customer",
 			"customer_group": "_Test Customer Group", 
diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py
index b53662e..f34ebf9 100644
--- a/selling/doctype/sales_common/sales_common.py
+++ b/selling/doctype/sales_common/sales_common.py
@@ -292,7 +292,7 @@
 			return obj.doclist
 		
 		# delete from doclist
-		obj.doclist = filter(lambda d: d.name not in delete_list, obj.doclist)
+		obj.doclist = webnotes.doclist(filter(lambda d: d.name not in delete_list, obj.doclist))
 		
 		# delete from db
 		webnotes.conn.sql("""\
diff --git a/selling/doctype/sales_order/test_sales_order.py b/selling/doctype/sales_order/test_sales_order.py
index dd0cd44..23046ed 100644
--- a/selling/doctype/sales_order/test_sales_order.py
+++ b/selling/doctype/sales_order/test_sales_order.py
@@ -59,11 +59,12 @@
 
 	def create_so(self, so_doclist = None):
 		if not so_doclist:
-			so_doclist =test_records[0]
-			
+			so_doclist = test_records[0]
+		
 		w = webnotes.bean(copy=so_doclist)
 		w.insert()
 		w.submit()
+
 		return w
 		
 	def create_dn_against_so(self, so, delivered_qty=0):
@@ -290,6 +291,7 @@
 			"transaction_date": "2013-02-21",
 			"grand_total": 1000.0, 
 			"grand_total_export": 1000.0, 
+			"naming_series": "_T-Sales Order-"
 		}, 
 		{
 			"description": "CPU", 
diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py
index 0bcd8c5..0ea7f40 100644
--- a/setup/doctype/company/company.py
+++ b/setup/doctype/company/company.py
@@ -230,6 +230,10 @@
 			cc.update({"doctype": "Cost Center"})
 			cc_bean = webnotes.bean(cc)
 			cc_bean.ignore_permissions = True
+			
+			if cc.get("cost_center_name") == self.doc.name:
+				cc_bean.ignore_mandatory = True
+			
 			cc_bean.insert()
 			
 		webnotes.conn.set(self.doc, "cost_center", "Main - " + self.doc.abbr)
diff --git a/setup/doctype/currency_exchange/test_currency_exchange.py b/setup/doctype/currency_exchange/test_currency_exchange.py
index cd0ac21..542b6af 100644
--- a/setup/doctype/currency_exchange/test_currency_exchange.py
+++ b/setup/doctype/currency_exchange/test_currency_exchange.py
@@ -3,7 +3,7 @@
 		"doctype": "Currency Exchange",
 		"from_currency": "USD",
 		"to_currency": "INR",
-		"exchange_rate": 1
+		"exchange_rate": 60.0
 	}],
 	[{
 		"doctype": "Currency Exchange",
diff --git a/startup/install.py b/startup/install.py
index dfe03b2..de60e38 100644
--- a/startup/install.py
+++ b/startup/install.py
@@ -169,7 +169,14 @@
 		{'uom_name': 'Minute', 'doctype': 'UOM', 'name': 'Minute'}, 
 	]
 	
+	from webnotes.modules import scrub
 	for r in records:
 		if not webnotes.conn.exists(r['doctype'], r['name']):
 			bean = webnotes.bean(r)
+			
+			# ignore mandatory for root
+			parent_link_field = ("parent_" + scrub(bean.doc.doctype))
+			if parent_link_field in bean.doc.fields and not bean.doc.fields.get(parent_link_field):
+				bean.ignore_mandatory = True
+			
 			bean.insert()
\ No newline at end of file
diff --git a/stock/doctype/delivery_note/test_delivery_note.py b/stock/doctype/delivery_note/test_delivery_note.py
index 287d05b..a8ff87e 100644
--- a/stock/doctype/delivery_note/test_delivery_note.py
+++ b/stock/doctype/delivery_note/test_delivery_note.py
@@ -109,6 +109,7 @@
 			"net_total": 500.0,
 			"grand_total": 500.0, 
 			"grand_total_export": 500.0,
+			"naming_series": "_T-Delivery Note-"
 		}, 
 		{
 			"description": "CPU", 
diff --git a/stock/doctype/item/item.txt b/stock/doctype/item/item.txt
index 54725a1..ff9c564 100644
--- a/stock/doctype/item/item.txt
+++ b/stock/doctype/item/item.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-05-03 10:45:46", 
   "docstatus": 0, 
-  "modified": "2013-07-05 16:24:34", 
+  "modified": "2013-07-08 14:05:47", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -202,7 +202,7 @@
   "label": "Is Stock Item", 
   "oldfieldname": "is_stock_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -270,7 +270,7 @@
   "label": "Is Asset Item", 
   "oldfieldname": "is_asset_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -283,7 +283,7 @@
   "label": "Has Batch No", 
   "oldfieldname": "has_batch_no", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -298,7 +298,7 @@
   "label": "Has Serial No", 
   "oldfieldname": "has_serial_no", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -399,7 +399,7 @@
   "label": "Is Purchase Item", 
   "oldfieldname": "is_purchase_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -525,7 +525,7 @@
   "label": "Is Sales Item", 
   "oldfieldname": "is_sales_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -540,7 +540,7 @@
   "label": "Is Service Item", 
   "oldfieldname": "is_service_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -554,7 +554,7 @@
   "label": "Allow Samples", 
   "oldfieldname": "is_sample_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -706,7 +706,7 @@
   "label": "Allow Bill of Materials", 
   "oldfieldname": "is_manufactured_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -732,7 +732,7 @@
   "label": "Allow Production Order", 
   "oldfieldname": "is_pro_applicable", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
@@ -745,7 +745,7 @@
   "label": "Is Sub Contracted Item", 
   "oldfieldname": "is_sub_contracted_item", 
   "oldfieldtype": "Select", 
-  "options": "\nYes\nNo", 
+  "options": "Yes\nNo", 
   "read_only": 0, 
   "reqd": 1
  }, 
diff --git a/stock/doctype/item/test_item.py b/stock/doctype/item/test_item.py
index 38f1d97..042363d 100644
--- a/stock/doctype/item/test_item.py
+++ b/stock/doctype/item/test_item.py
@@ -69,7 +69,8 @@
 		"parentfield": "item_reorder",
 		"warehouse": "_Test Warehouse",
 		"warehouse_reorder_level": 20,
-		"warehouse_reorder_qty": 20
+		"warehouse_reorder_qty": 20,
+		"material_request_type": "Purchase"
 	}, {
 		"doctype": "Item Price",
 		"parentfield": "ref_rate_details",
diff --git a/stock/doctype/material_request/material_request.txt b/stock/doctype/material_request/material_request.txt
index 0f1036b..649210e 100644
--- a/stock/doctype/material_request/material_request.txt
+++ b/stock/doctype/material_request/material_request.txt
@@ -2,7 +2,7 @@
  {
   "creation": "2013-03-07 14:48:38", 
   "docstatus": 0, 
-  "modified": "2013-07-08 15:40:01", 
+  "modified": "2013-07-08 16:18:00", 
   "modified_by": "Administrator", 
   "owner": "Administrator"
  }, 
@@ -99,7 +99,7 @@
   "options": "Material Request Item"
  }, 
  {
-  "default": "Give additional details about the indent.", 
+  "description": "Give additional details about the indent.", 
   "doctype": "DocField", 
   "fieldname": "more_info", 
   "fieldtype": "Section Break", 
diff --git a/stock/doctype/material_request/test_material_request.py b/stock/doctype/material_request/test_material_request.py
index 0efc3b0..5d22168 100644
--- a/stock/doctype/material_request/test_material_request.py
+++ b/stock/doctype/material_request/test_material_request.py
@@ -321,7 +321,8 @@
 			"doctype": "Material Request", 
 			"fiscal_year": "_Test Fiscal Year 2013", 
 			"transaction_date": "2013-02-18",
-			"material_request_type": "Purchase"
+			"material_request_type": "Purchase",
+			"naming_series": "_T-Material Request-"
 		}, 
 		{
 			"description": "_Test Item Home Desktop 100", 
diff --git a/stock/doctype/purchase_receipt/test_purchase_receipt.py b/stock/doctype/purchase_receipt/test_purchase_receipt.py
index 9540f78..e754e69 100644
--- a/stock/doctype/purchase_receipt/test_purchase_receipt.py
+++ b/stock/doctype/purchase_receipt/test_purchase_receipt.py
@@ -102,6 +102,7 @@
 			"supplier": "_Test Supplier",
 			"net_total": 500.0, 
 			"grand_total": 720.0,
+			"naming_series": "_T-Purchase Receipt-",
 		}, 
 		{
 			"conversion_factor": 1.0, 
diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py
index 9051d6b..fb045ce 100644
--- a/stock/doctype/stock_entry/test_stock_entry.py
+++ b/stock/doctype/stock_entry/test_stock_entry.py
@@ -278,7 +278,9 @@
 		self._insert_material_receipt()
 		
 		from stock.doctype.delivery_note.test_delivery_note \
-			import test_records as delivery_note_test_records, make_sales_invoice
+			import test_records as delivery_note_test_records
+
+		from stock.doctype.delivery_note.delivery_note import make_sales_invoice
 		
 		actual_qty_0 = self._get_actual_qty()
 		
@@ -361,9 +363,8 @@
 	def _test_delivery_note_return_against_sales_order(self, item_code, delivered_qty, returned_qty):
 		self._insert_material_receipt()
 
-		from selling.doctype.sales_order.test_sales_order \
-			import test_records as sales_order_test_records, 
-			make_sales_invoice, make_delivery_note
+		from selling.doctype.sales_order.test_sales_order import test_records as sales_order_test_records
+		from selling.doctype.sales_order.sales_order import make_sales_invoice, make_delivery_note
 
 		actual_qty_0 = self._get_actual_qty()
 		
@@ -418,8 +419,9 @@
 		actual_qty_0 = self._get_actual_qty()
 		
 		from stock.doctype.purchase_receipt.test_purchase_receipt \
-			import test_records as purchase_receipt_test_records,
-			make_purchase_invoice
+			import test_records as purchase_receipt_test_records
+
+		from stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
 		
 		# submit purchase receipt
 		pr = webnotes.bean(copy=purchase_receipt_test_records[0])
@@ -443,6 +445,7 @@
 			d.cost_center = "_Test Cost Center - _TC"
 		
 		pi.run_method("calculate_taxes_and_totals")
+		pi.doc.bill_no = "NA"
 		pi.insert()
 		pi.submit()
 		
@@ -506,7 +509,9 @@
 		actual_qty_0 = self._get_actual_qty()
 		
 		from buying.doctype.purchase_order.test_purchase_order \
-			import test_records as purchase_order_test_records, 
+			import test_records as purchase_order_test_records
+		
+		from buying.doctype.purchase_order.purchase_order import \
 			make_purchase_receipt, make_purchase_invoice
 		
 		# submit purchase receipt
@@ -540,6 +545,7 @@
 			d.cost_center = "_Test Cost Center - _TC"
 		
 		pi.run_method("calculate_taxes_and_totals")
+		pi.doc.bill_no = "NA"
 		pi.insert()
 		pi.submit()
 		
diff --git a/stock/doctype/warehouse/test_warehouse.py b/stock/doctype/warehouse/test_warehouse.py
index f3a0458..10b49b6 100644
--- a/stock/doctype/warehouse/test_warehouse.py
+++ b/stock/doctype/warehouse/test_warehouse.py
@@ -9,6 +9,7 @@
 		"doctype": "Warehouse",
 		"warehouse_name": "_Test Warehouse 1",
 		"warehouse_type": "_Test Warehouse Type",
+		"company": "_Test Company"
 	}],
 	[{
 		"doctype": "Warehouse",
diff --git a/website/doctype/shopping_cart_settings/shopping_cart_settings.py b/website/doctype/shopping_cart_settings/shopping_cart_settings.py
index 121422f..7fe14c3 100644
--- a/website/doctype/shopping_cart_settings/shopping_cart_settings.py
+++ b/website/doctype/shopping_cart_settings/shopping_cart_settings.py
@@ -15,6 +15,9 @@
 			self.validate_tax_masters()
 			self.validate_exchange_rates_exist()
 			
+	def on_update(self):
+		webnotes.conn.set_default("shopping_cart_enabled", self.doc.fields.get("enabled") or 0)
+			
 	def validate_overlapping_territories(self, parentfield, fieldname):
 		# for displaying message
 		doctype = self.meta.get_field(parentfield).options
diff --git a/website/helpers/cart.py b/website/helpers/cart.py
index 099fb68..d4ab64d 100644
--- a/website/helpers/cart.py
+++ b/website/helpers/cart.py
@@ -42,6 +42,9 @@
 			quotation_items[0].qty = qty
 	
 	apply_cart_settings(quotation=quotation)
+
+	quotation.ignore_permissions = True
+	quotation.save()
 	
 	if with_doclist:
 		return get_cart_quotation(quotation.doclist)
@@ -67,10 +70,10 @@
 		quotation.doc.address_display = address_display
 		
 	
+	apply_cart_settings(quotation=quotation)
+	
 	quotation.ignore_permissions = True
 	quotation.save()
-	
-	apply_cart_settings(quotation=quotation)
 		
 	return get_cart_quotation(quotation.doclist)
 
@@ -136,9 +139,11 @@
 			"territory": guess_territory(),
 			"status": "Open" # TODO: set something better???
 		})
-		lead_bean.ignore_permissions = True
-		lead_bean.insert()
 		
+		if webnotes.session.user != "Guest":
+			lead_bean.ignore_permissions = True
+			lead_bean.insert()
+			
 		return lead_bean.doc
 		
 def guess_territory():
@@ -202,7 +207,7 @@
 	
 	billing_territory = get_address_territory(quotation.doc.customer_address) or \
 		party.territory
-	
+		
 	set_price_list_and_rate(quotation, cart_settings, billing_territory)
 	
 	quotation.run_method("calculate_taxes_and_totals")
@@ -211,9 +216,6 @@
 	
 	_apply_shipping_rule(party, quotation, cart_settings)
 	
-	quotation.ignore_permissions = True
-	quotation.save()
-	
 def set_price_list_and_rate(quotation, cart_settings, billing_territory):
 	"""set price list based on billing territory"""
 	quotation.doc.price_list_name = cart_settings.get_price_list(billing_territory)
@@ -227,6 +229,9 @@
 	# refetch values
 	quotation.run_method("set_price_list_and_item_details")
 	
+	# set it in cookies for using in product page
+	webnotes.cookies[b"price_list_name"] = quotation.doc.price_list_name
+	
 def set_taxes(quotation, cart_settings, billing_territory):
 	"""set taxes based on billing territory"""
 	quotation.doc.charge = cart_settings.get_tax_master(billing_territory)
@@ -247,6 +252,7 @@
 	
 	apply_cart_settings(quotation=quotation)
 	
+	quotation.ignore_permissions = True
 	quotation.save()
 	
 	return get_cart_quotation(quotation.doclist)
diff --git a/website/helpers/product.py b/website/helpers/product.py
index e513c2d..168c14c 100644
--- a/website/helpers/product.py
+++ b/website/helpers/product.py
@@ -6,11 +6,18 @@
 import webnotes
 from webnotes.utils import cstr, cint, fmt_money
 from webnotes.webutils import build_html, delete_page_cache
+from website.helpers.cart import _get_cart_quotation
 
 @webnotes.whitelist(allow_guest=True)
 def get_product_info(item_code):
 	"""get product price / stock info"""
-	price_list = webnotes.conn.get_value("Price List", {"use_for_website": 1})
+	if not webnotes.conn.get_default("shopping_cart_enabled"):
+		return {}
+	
+	cart_quotation = _get_cart_quotation()
+	
+	price_list = webnotes.cookies.get("price_list_name").value
+
 	warehouse = webnotes.conn.get_value("Item", item_code, "website_warehouse")
 	if warehouse:
 		in_stock = webnotes.conn.sql("""select actual_qty from tabBin where
@@ -35,8 +42,7 @@
 			or ""
 		
 		if webnotes.session.user != "Guest":
-			from website.helpers.cart import _get_cart_quotation
-			item = _get_cart_quotation().doclist.get({"item_code": item_code})
+			item = cart_quotation.doclist.get({"item_code": item_code})
 			if item:
 				qty = item[0].qty
 
diff --git a/website/templates/html/product_page.html b/website/templates/html/product_page.html
index 255d1e7..b3e8be2 100644
--- a/website/templates/html/product_page.html
+++ b/website/templates/html/product_page.html
@@ -43,7 +43,8 @@
 							<button class="btn btn-primary">
 								<i class="icon-shopping-cart"></i> Add to Cart</button>
 						</div>
-						<div id="item-update-cart" class="input-group col-lg-4" style="display: none;">
+						<div id="item-update-cart" class="input-group col-lg-4" style="display: none;
+							padding-left: 0px; padding-right: 0px;">
 							<input type="text">
 							<div class="input-group-btn">
 								<button class="btn btn-primary">
diff --git a/website/templates/js/cart.js b/website/templates/js/cart.js
index f1002fc..27f604f 100644
--- a/website/templates/js/cart.js
+++ b/website/templates/js/cart.js
@@ -96,7 +96,7 @@
 		
 		var shipping_rule_added = false;
 		var taxes_exist = false;
-		var shipping_rule_labels = $.map(out.shipping_rules, function(rule) { return rule[1]; });
+		var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; });
 		$.each(doclist, function(i, doc) {
 			if(doc.doctype === "Quotation Item") {
 				wn.cart.render_item_row($cart_items, doc);