Merge branch 'master' of github.com:webnotes/erpnext
diff --git a/buying/page/purchase_analytics/purchase_analytics.js b/buying/page/purchase_analytics/purchase_analytics.js
index 96b88b3..2b869a6 100644
--- a/buying/page/purchase_analytics/purchase_analytics.js
+++ b/buying/page/purchase_analytics/purchase_analytics.js
@@ -121,7 +121,7 @@
 		var me = this;
 		this._super();
 		
-		this.trigger_refresh_on_change(["value_or_qty", "tree_type", "based_on"]);
+		this.trigger_refresh_on_change(["value_or_qty", "tree_type", "based_on", "company"]);
 
 		this.show_zero_check()		
 		this.setup_plot_check();
@@ -216,7 +216,7 @@
 		var is_val = this.value_or_qty == 'Value';
 		
 		$.each(this.tl[this.based_on], function(i, tl) {
-			if (me.is_default('company') ? true : me.apply_filter(tl, "company")) { 
+			if (me.is_default('company') ? true : tl.company === me.company) { 
 				var posting_date = dateutil.str_to_obj(tl.posting_date);
 				if (posting_date >= from_date && posting_date <= to_date) {
 					var item = me.item_by_name[tl[me.tree_grid.item_key]] || 
diff --git a/selling/page/sales_analytics/sales_analytics.js b/selling/page/sales_analytics/sales_analytics.js
index 7fdc3ac..8f09197f 100644
--- a/selling/page/sales_analytics/sales_analytics.js
+++ b/selling/page/sales_analytics/sales_analytics.js
@@ -123,7 +123,7 @@
 		var me = this;
 		this._super();
 		
-		this.trigger_refresh_on_change(["value_or_qty", "tree_type", "based_on"]);
+		this.trigger_refresh_on_change(["value_or_qty", "tree_type", "based_on", "company"]);
 
 		this.show_zero_check()		
 		this.setup_plot_check();
@@ -209,7 +209,7 @@
 		var is_val = this.value_or_qty == 'Value';
 		
 		$.each(this.tl[this.based_on], function(i, tl) {
-			if (me.is_default('company') ? true : me.apply_filter(tl, "company")) { 
+			if (me.is_default('company') ? true : tl.company === me.company) { 
 				var posting_date = dateutil.str_to_obj(tl.posting_date);
 				if (posting_date >= from_date && posting_date <= to_date) {
 					var item = me.item_by_name[tl[me.tree_grid.item_key]] || 
diff --git a/stock/doctype/item/item.js b/stock/doctype/item/item.js
index b1bb269..9af8331 100644
--- a/stock/doctype/item/item.js
+++ b/stock/doctype/item/item.js
@@ -182,13 +182,6 @@
 	function(doc,cdt,cdn) {
 		return{ query:"controllers.queries.supplier_query" } }
 
-cur_frm.cscript.on_remove_attachment = function(doc) {
-	if(!inList(cur_frm.fields_dict.image.df.options.split("\n"), doc.image)) {
-		msgprint(wn._("Attachment removed. You may need to update: ") 
-			+ wn.meta.get_docfield(doc.doctype, "description_html").label);
-	}
-};
-
 cur_frm.cscript.copy_from_item_group = function(doc) {
 	wn.model.with_doc("Item Group", doc.item_group, function() {
 		$.each(wn.model.get("Item Website Specification", {parent:doc.item_group}), 
@@ -206,5 +199,10 @@
 cur_frm.cscript.image = function() {
 	refresh_field("image_view");
 	
-	if(!cur_frm.doc.description_html) cur_frm.cscript.add_image(cur_frm.doc);
+	if(!cur_frm.doc.description_html) {
+		cur_frm.cscript.add_image(cur_frm.doc);
+	} else {
+		msgprint(wn._("You may need to update: ") + 
+			wn.meta.get_docfield(cur_frm.doc.doctype, "description_html").label);
+	}
 }
\ No newline at end of file