Trend analyzer fix due to project field movement to item level in pur cycle
diff --git a/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.js b/erpnext/analysis/search_criteria/trend_analyzer/trend_analyzer.js
index a99de23..9426a23 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 @@
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 42d5d2f..42a7c5c 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 @@
# 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
# ==============================================