Merge branch 'responsive' of github.com:webnotes/erpnext into responsive
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..61e52d2
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,28 @@
+# Contributing to ERPNext
+
+### New Features
+
+#### Don't Repeat Yourself (DRY)
+
+We believe that the most effective way to manage a product like this is to ensure that
+there is minimum repetition of code. So before contributing a function, please make sure
+that such a feature or function does not exist else where. If it does, the try and extend
+that function to accommodate your use case.
+
+#### Don't create new DocTypes Unless Absolutely Necessary
+
+DocTypes are easy to create but hard to maintain. If you find that there is a another DocType with a similar functionality, then please try and extend that functionality. For example, by adding a "type" field to classify the new type of record.
+
+#### Tabs or spaces?
+
+Tabs!
+
+### Copyright
+
+The ERPNext code is licensed as GNU General Public License (v3) and the Documentation is licensed as Creative Commons (CC-BY-SA-3.0) and the copyright is owned by Web Notes Technologies Pvt Ltd (Web Notes). Unless otherwise asserted in the code files, Web Notes will own the copyright of all contributions too. That means Web Notes holds the rights to change the license in the future or offer Commercial Licenses.
+
+We will only accept copyright assertions in case of a significant contribution like a whole new functionality or a major rewrite. We believe if your contribution is significant then you should have a say in what license Web Notes selects in the future and/or have a right to any revenue Web Notes gets from a Commercial License. Either ways Web Notes will have the right to decide what is a "significant" contribution.
+
+Note: At the moment, Web Notes does not give Commercial License for ERPNext nor has specific plans do so in the future.
+
+The brand name ERPNext and the logo are trademarks of Web Notes Technologies Pvt. Ltd.
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index c802622..90239fa 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -197,10 +197,6 @@
 	cur_frm.cscript.hide_fields(doc, dt, dn);
 }
 
-cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
-	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
-}
-
 cur_frm.fields_dict['entries'].grid.onrowadd = function(doc, cdt, cdn){
 
 	cl = getchildren('Sales Invoice Item', doc.name, cur_frm.cscript.fname, doc.doctype);
diff --git a/license.txt b/license.txt
index 9c8bf91..093f0f1 100644
--- a/license.txt
+++ b/license.txt
@@ -1,4 +1,13 @@
+ERPNext License Info
+--------------------
+
+(c) 2013 Web Notes Technologies Pvt Ltd. Mumbai
+ERPNext is a trademark of Web Notes Technologies
+
+The ERPNext code is licensed under the GNU General Public License (v3) as mentioned below and the Documentation is licensed under Creative Commons (CC-BY-SA-3.0)
+
 GNU GENERAL PUBLIC LICENSE
+--------------------------
 
 Version 3, 29 June 2007
 
diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js
index f108271..af49bb3 100644
--- a/selling/doctype/quotation/quotation.js
+++ b/selling/doctype/quotation/quotation.js
@@ -109,14 +109,6 @@
 
 cur_frm.script_manager.make(erpnext.selling.QuotationController);
 
-cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
-	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({
-		customer: doc.customer, 
-		address: doc.customer_address, 
-		contact: doc.contact_person
-	}),'', doc, dt, dn, 1);
-}
-
 cur_frm.fields_dict.lead.get_query = function(doc,cdt,cdn) {
 	return{	query:"controllers.queries.lead_query" } }
 
diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js
index 01ea8f5..919de22 100644
--- a/selling/doctype/sales_common/sales_common.js
+++ b/selling/doctype/sales_common/sales_common.js
@@ -58,7 +58,6 @@
 				return {
 					filters: [
 						['Sales Taxes and Charges Master', 'company', '=', me.frm.doc.company],
-						['Sales Taxes and Charges Master', 'company', 'is not', 'NULL'],
 						['Sales Taxes and Charges Master', 'docstatus', '!=', 2]
 					]
 				}
@@ -146,6 +145,29 @@
 		}
 	},
 	
+	customer_address: function() {
+		var me = this;
+		if(this.frm.doc.customer) {
+			this.frm.call({
+				doc: this.frm.doc,
+				args: {
+					customer: this.frm.doc.customer, 
+					address: this.frm.doc.customer_address, 
+					contact: this.frm.doc.contact_person
+				},
+				method: "get_customer_address",
+				freeze: true,
+				callback: function(r) {
+					me.frm.refresh_fields();
+				}
+			});
+		}
+	},
+	
+	contact_person: function() {
+		this.customer_address();
+	},
+	
 	barcode: function(doc, cdt, cdn) {
 		this.item_code(doc, cdt, cdn);
 	},
diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js
index 509ecf7..4368d5b 100644
--- a/selling/doctype/sales_order/sales_order.js
+++ b/selling/doctype/sales_order/sales_order.js
@@ -141,11 +141,6 @@
 // for backward compatibility: combine new and previous states
 $.extend(cur_frm.cscript, new erpnext.selling.SalesOrderController({frm: cur_frm}));
 
-cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {		
-	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
-}
-
-
 cur_frm.cscript.new_contact = function(){
 	tn = wn.model.make_new_doc_and_get_name('Contact');
 	locals['Contact'][tn].is_customer = 1;
diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py
index 38f7d7b..be57853 100644
--- a/selling/doctype/sales_order/sales_order.py
+++ b/selling/doctype/sales_order/sales_order.py
@@ -80,27 +80,11 @@
 	def validate_for_items(self):
 		check_list, flag = [], 0
 		chk_dupl_itm = []
-		# Sales Order Items Validations
 		for d in getlist(self.doclist, 'sales_order_details'):
-			if self.doc.quotation_no and cstr(self.doc.quotation_no) == cstr(d.prevdoc_docname):
-				flag = 1
-			if d.prevdoc_docname:
-				if self.doc.quotation_date and getdate(self.doc.quotation_date) > getdate(self.doc.transaction_date):
-					msgprint("Sales Order Date cannot be before Quotation Date")
-					raise Exception
-				# validates whether quotation no in doctype and in table is same
-				if not cstr(d.prevdoc_docname) == cstr(self.doc.quotation_no):
-					msgprint("Items in table does not belong to the Quotation No mentioned.")
-					raise Exception
-
-			# validates whether item is not entered twice
 			e = [d.item_code, d.description, d.reserved_warehouse, d.prevdoc_docname or '']
 			f = [d.item_code, d.description]
 
-			#check item is stock item
-			st_itm = sql("select is_stock_item from `tabItem` where name = %s", d.item_code)
-
-			if st_itm and st_itm[0][0] == 'Yes':
+			if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == 'Yes':
 				if not d.reserved_warehouse:
 					msgprint("""Please enter Reserved Warehouse for item %s 
 						as it is stock Item""" % d.item_code, raise_exception=1)
@@ -109,7 +93,7 @@
 					msgprint("Item %s has been entered twice." % d.item_code)
 				else:
 					check_list.append(e)
-			elif st_itm and st_itm[0][0]== 'No':
+			else:
 				if f in chk_dupl_itm:
 					msgprint("Item %s has been entered twice." % d.item_code)
 				else:
@@ -121,9 +105,6 @@
 			tot_avail_qty = sql("select projected_qty from `tabBin` \
 				where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse))
 			d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0
-		
-		if getlist(self.doclist, 'sales_order_details') and self.doc.quotation_no and flag == 0:
-			msgprint("There are no items of the quotation selected", raise_exception=1)
 
 	def validate_sales_mntc_quotation(self):
 		for d in getlist(self.doclist, 'sales_order_details'):
diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js
index 62d6529..e93e6d3 100644
--- a/stock/doctype/delivery_note/delivery_note.js
+++ b/stock/doctype/delivery_note/delivery_note.js
@@ -92,10 +92,6 @@
 // for backward compatibility: combine new and previous states
 $.extend(cur_frm.cscript, new erpnext.stock.DeliveryNoteController({frm: cur_frm}));
 
-cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {		
-	if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
-}
-
 cur_frm.cscript.new_contact = function(){
 	tn = wn.model.make_new_doc_and_get_name('Contact');
 	locals['Contact'][tn].is_customer = 1;
diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py
index 502e30f..77038bb 100644
--- a/stock/doctype/delivery_note/delivery_note.py
+++ b/stock/doctype/delivery_note/delivery_note.py
@@ -58,14 +58,6 @@
 		"""Get Commission rate of Sales Partner"""
 		return get_obj('Sales Common').get_comm_rate(sales_partner, self)
 
-	def validate_prev_docname(self):
-		"""Validates that Sales Order is not pulled twice"""
-		for d in getlist(self.doclist, 'delivery_note_details'):
-			if self.doc.sales_order_no == d.prevdoc_docname:
-				msgprint(cstr(self.doc.sales_order_no) + " sales order details have already been pulled. ")
-				raise Exception, "Validation Error. "
-
-
 	def set_actual_qty(self):
 		for d in getlist(self.doclist, 'delivery_note_details'):
 			if d.item_code and d.warehouse:
@@ -246,7 +238,6 @@
 					d.fields.get('packed_qty', 0)
 				])
 		if packing_error_list:
-			from webnotes.utils import cstr
 			err_msg = "\n".join([("Item: " + d[0] + ", Qty: " + cstr(d[1]) \
 				+ ", Packed: " + cstr(d[2])) for d in packing_error_list])
 			webnotes.msgprint("Packing Error:\n" + err_msg, raise_exception=1)
diff --git a/utilities/transaction_base.py b/utilities/transaction_base.py
index 8fa99b8..ed404dd 100644
--- a/utilities/transaction_base.py
+++ b/utilities/transaction_base.py
@@ -145,9 +145,9 @@
 			'customer_address' : args["address"],
 			'address_display' : get_address_display(args["address"]),
 		}
+		if args.get('contact'):
+			ret.update(map_party_contact_details(args['contact']))
 		
-		ret.update(map_party_contact_details(args['contact']))
-
 		return ret
 
 	# TODO deprecate this - used only in sales_order.js
@@ -347,7 +347,7 @@
 	
 def get_address_display(address_dict):
 	if not isinstance(address_dict, dict):
-		address_dict = webnotes.conn.get_value("Address", address_dict, "*", as_dict=True)
+		address_dict = webnotes.conn.get_value("Address", address_dict, "*", as_dict=True) or {}
 	
 	meta = webnotes.get_doctype("Address")
 	sequence = (("", "address_line1"), ("\n", "address_line2"), ("\n", "city"),
@@ -386,23 +386,23 @@
 	
 	if not contact_name:
 		contact_name = get_default_contact(party_field, party_name)
+	if party_field:
+		contact = webnotes.conn.sql("""select * from `tabContact` where `%s`=%s
+			order by is_primary_contact desc, name asc limit 1""" % (party_field, "%s"), 
+			(party_name,), as_dict=True)
 
-	contact = webnotes.conn.sql("""select * from `tabContact` where `%s`=%s
-		order by is_primary_contact desc, name asc limit 1""" % (party_field, "%s"), 
-		(party_name,), as_dict=True)
-
-	if contact:
-		contact = contact[0]
-		out.update({
-			"contact_person": contact.get("name"),
-			"contact_display": " ".join(filter(None, 
-				[contact.get("first_name"), contact.get("last_name")])),
-			"contact_email": contact.get("email_id"),
-			"contact_mobile": contact.get("mobile_no"),
-			"contact_phone": contact.get("phone"),
-			"contact_designation": contact.get("designation"),
-			"contact_department": contact.get("department")
-		})
+		if contact:
+			contact = contact[0]
+			out.update({
+				"contact_person": contact.get("name"),
+				"contact_display": " ".join(filter(None, 
+					[contact.get("first_name"), contact.get("last_name")])),
+				"contact_email": contact.get("email_id"),
+				"contact_mobile": contact.get("mobile_no"),
+				"contact_phone": contact.get("phone"),
+				"contact_designation": contact.get("designation"),
+				"contact_department": contact.get("department")
+			})
 	
 	return out