From 09d4933edbe6427ddab608d6307de4fbbb7f21a6 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Mon, 6 May 2019 12:53:52 +0530 Subject: [PATCH] fix: filter pi item based on po completeion --- .../procurement_tracker/procurement_tracker.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.py b/erpnext/buying/report/procurement_tracker/procurement_tracker.py index 2654cd4965..d3ee447545 100644 --- a/erpnext/buying/report/procurement_tracker/procurement_tracker.py +++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.py @@ -150,10 +150,10 @@ def get_conditions(filters): """% (filters.get('cost_center'), filters.get('project')) if filters.get("from_date"): - conditions.append("AND transaction_date>=%s", filters.get('from_date')) + conditions += "AND transaction_date>=%s"% filters.get('from_date') if filters.get("to_date"): - conditions.append("AND transaction_date<=%s", filters.get('to_date') + conditions += "AND transaction_date<=%s"% filters.get('to_date') return conditions def get_data(filters): @@ -162,6 +162,7 @@ def get_data(filters): mr_records, procurement_record_against_mr = get_mapped_mr_details(conditions) pr_records = get_mapped_pr_records() pi_records = get_mapped_pi_records() + print(pi_records) procurement_record=[] if procurement_record_against_mr: @@ -228,9 +229,12 @@ def get_mapped_pi_records(): SELECT pi_item.po_detail, pi_item.base_amount - FROM `tabPurchase Invoice` pi, `tabPurchase Invoice Item` pi_item + FROM `tabPurchase Invoice Item` as pi_item + INNER JOIN `tabPurchase Order` as po + ON pi_item.`purchase_order` = po.`name` WHERE - pi.docstatus=1 + pi_item.docstatus = 1 + AND po.status not in ("Closed","Completed","Cancelled") AND pi_item.po_detail IS NOT NULL """))