From 1dadf35fc739c79f3f5af0d2df8462fbf6e5187d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 3 Sep 2013 16:21:01 +0530 Subject: [PATCH] [fix] [minor] [query] sales invoice from delivery note --- accounts/doctype/sales_invoice/sales_invoice.js | 1 - controllers/queries.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 109d9f8a07..0c8fc3714c 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -80,7 +80,6 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte 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 81040a25e3..02c992b729 100644 --- a/controllers/queries.py +++ b/controllers/queries.py @@ -169,10 +169,12 @@ def get_price_list_currency(doctype, txt, searchfield, start, page_len, filters) 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""" % {