[fix] [minor] [query] sales invoice from delivery note
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 109d9f8..0c8fc37 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -80,7 +80,6 @@
 						source_doctype: "Delivery Note",
 						get_query: function() {
 							var filters = {
-								docstatus: 1,
 								company: cur_frm.doc.company
 							};
 							if(cur_frm.doc.customer) filters["customer"] = cur_frm.doc.customer;
diff --git a/controllers/queries.py b/controllers/queries.py
index 81040a2..02c992b 100644
--- a/controllers/queries.py
+++ b/controllers/queries.py
@@ -169,10 +169,12 @@
 def get_delivery_notes_to_be_billed(doctype, txt, searchfield, start, page_len, filters):
 	return webnotes.conn.sql("""select `tabDelivery Note`.name, `tabDelivery Note`.customer_name
 		from `tabDelivery Note` 
-		where `tabDelivery Note`.`%(key)s` like %(txt)s %(fcond)s and
+		where `tabDelivery Note`.`%(key)s` like %(txt)s and 
+			`tabDelivery Note`.docstatus = 1 %(fcond)s and
 			(ifnull((select sum(qty) from `tabDelivery Note Item` where 
 					`tabDelivery Note Item`.parent=`tabDelivery Note`.name), 0) >
 				ifnull((select sum(qty) from `tabSales Invoice Item` where 
+					`tabSales Invoice Item`.docstatus = 1 and
 					`tabSales Invoice Item`.delivery_note=`tabDelivery Note`.name), 0))
 			%(mcond)s order by `tabDelivery Note`.`%(key)s` asc
 			limit %(start)s, %(page_len)s""" % {