diff --git a/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.js b/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.js index a99de236e2..9426a23520 100644 --- a/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.js +++ b/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.js @@ -101,8 +101,13 @@ report.get_query = function() { if(supp_type) add_cond += ' AND t1.supplier_type = "'+supp_type+'"'; break; case 'Project' : pro = this.get_filter('Profile', 'Project').get_value(); - col = 'DISTINCT t1.project_name'; - if(pro) add_cond += ' AND t1.project_name = "'+pro+'"'; + if (inList(['Purchase Order', 'Purchase Receipt', 'Payable Voucher'], trans)) { + col = 'DISTINCT t2.project_name'; + if(pro) add_cond += ' AND t2.project_name = "'+pro+'"'; + } else { + col = 'DISTINCT t1.project_name'; + if(pro) add_cond += ' AND t1.project_name = "'+pro+'"'; + } break; case 'Item Group' : ig = this.get_filter('Profile', 'Item Group').get_value(); if(ig) sp_cond += ' AND parent.name = "'+ig+'"'; diff --git a/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py b/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py index 42d5d2f04b..42a7c5cc7e 100644 --- a/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py +++ b/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.py @@ -118,7 +118,10 @@ if supplier_type or based_on == 'Supplier Type': # Project if project or based_on == 'Project': - add_cond += ' AND t1.project_name = "%s"' % (based_on != 'Project' and project or '%(value)s') + if trans in ['Purchase Order', 'Purchase Receipt', 'Payable Voucher']: + add_cond += ' AND t2.project_name = "%s"' % (based_on != 'Project' and project or '%(value)s') + else: + add_cond += ' AND t1.project_name = "%s"' % (based_on != 'Project' and project or '%(value)s') # Column to be seleted for group by condition # ==============================================