Merge pull request #5371 from saurabh6790/reset_user_must_always_select_on_transaction_change

[fixes] Reset "User must always select" on change of transaction
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index bc337a1..f670c90 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -6,6 +6,15 @@
 
 
 frappe.ui.form.on("Journal Entry", {
+	setup: function(frm) {
+		frm.get_field('accounts').grid.editable_fields = [
+			{fieldname: 'account', columns: 3},
+			{fieldname: 'party', columns: 4},
+			{fieldname: 'debit_in_account_currency', columns: 2},
+			{fieldname: 'credit_in_account_currency', columns: 2}
+		];
+	},
+
 	refresh: function(frm) {
 		erpnext.toggle_naming_series();
 		frm.cscript.voucher_type(frm.doc);
@@ -50,7 +59,7 @@
 	},
 
 	load_defaults: function() {
-		this.frm.show_print_first = true;
+		//this.frm.show_print_first = true;
 		if(this.frm.doc.__islocal && this.frm.doc.company) {
 			frappe.model.set_default_values(this.frm.doc);
 			$.each(this.frm.doc.accounts || [], function(i, jvd) {
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 923514d..b634ccf 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -15,16 +15,21 @@
 				this.frm.set_df_property("credit_to", "print_hide", 0);
 			}
 		}
+
+		// formatter for material request item
+		this.frm.set_indicator_formatter('item_code',
+			function(doc) { return (doc.qty<=doc.received_qty) ? "green" : "orange" })
+
 	},
 
 	refresh: function(doc) {
 		this._super();
-		
+
 		hide_fields(this.frm.doc);
 
 		// Show / Hide button
 		this.show_general_ledger();
-		
+
 		if(doc.update_stock==1 && doc.docstatus==1) {
 			this.show_stock_ledger();
 		}
@@ -34,13 +39,13 @@
 				this.frm.add_custom_button(__('Payment'), this.make_bank_entry, __("Make"));
 				cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
 			}
-			
+
 			if(doc.outstanding_amount >= 0 || Math.abs(flt(doc.outstanding_amount)) < flt(doc.grand_total)) {
-				cur_frm.add_custom_button(doc.update_stock ? __('Purchase Return') : __('Debit Note'), 
+				cur_frm.add_custom_button(doc.update_stock ? __('Purchase Return') : __('Debit Note'),
 					this.make_debit_note, __("Make"));
 			}
 		}
-		
+
 		if(doc.docstatus===0) {
 			cur_frm.add_custom_button(__('Purchase Order'), function() {
 				frappe.model.map_current_doc({
@@ -69,7 +74,7 @@
 				})
 			}, __("Get items from"));
 		}
-		
+
 		this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
 	},
 
@@ -156,7 +161,7 @@
 			frm: cur_frm
 		})
 	},
-	
+
 	asset: function(frm, cdt, cdn) {
 		var row = locals[cdt][cdn];
 		if(row.asset) {
@@ -188,13 +193,13 @@
 			var docfield = frappe.meta.docfield_map[doc.doctype][parent_fields[i]];
 			if(!docfield.hidden) unhide_field(parent_fields[i]);
 		}
-	
+
 	}
 
 	item_fields_stock = ['warehouse_section', 'received_qty', 'rejected_qty'];
 
 	cur_frm.fields_dict['items'].grid.set_column_disp(item_fields_stock,
-		(cint(doc.update_stock)==1 ? true : false));	
+		(cint(doc.update_stock)==1 ? true : false));
 
 	cur_frm.refresh_fields();
 }
@@ -361,7 +366,7 @@
 			}
 		})
 	},
-	
+
 	is_subcontracted: function(frm) {
 		if (frm.doc.is_subcontracted === "Yes") {
 			erpnext.buying.get_default_bom(frm);
@@ -369,4 +374,3 @@
 		frm.toggle_reqd("supplier_warehouse", frm.doc.is_subcontracted==="Yes");
 	}
 })
-	
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 952cce6..109a9eb 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -63,7 +63,7 @@
 		self.validate_write_off_account()
 		self.validate_fixed_asset()
 		self.set_income_account_for_fixed_assets()
-		
+
 		# if cint(self.is_pos):
 			# self.validate_pos()
 
@@ -85,7 +85,7 @@
 
 	def before_save(self):
 		set_account_for_mode_of_payment(self)
-		
+
 	def update_change_amount(self):
 		self.base_paid_amount = 0.0
 		if self.paid_amount:
@@ -95,7 +95,7 @@
 				self.change_amount = flt(self.paid_amount - self.grand_total, self.precision("change_amount"))
 				self.base_change_amount = flt(self.change_amount * self.conversion_rate, self.precision("base_change_amount"))
 
-	def on_submit(self):			
+	def on_submit(self):
 		if not self.recurring_id:
 			frappe.get_doc('Authorization Control').validate_approving_authority(self.doctype,
 			 	self.company, self.base_grand_total, self)
@@ -109,12 +109,12 @@
 		self.update_status_updater_args()
 		self.update_prevdoc_status()
 		self.update_billing_status_in_dn()
-		
-		# Updating stock ledger should always be called after updating prevdoc status, 
+
+		# Updating stock ledger should always be called after updating prevdoc status,
 		# because updating reserved qty in bin depends upon updated delivered qty in SO
 		if self.update_stock == 1:
 			self.update_stock_ledger()
-		
+
 		# this sequence because outstanding may get -ve
 		self.make_gl_entries()
 
@@ -149,8 +149,8 @@
 			self.update_billing_status_for_zero_amount_refdoc("Sales Order")
 
 		self.validate_c_form_on_cancel()
-		
-		# Updating stock ledger should always be called after updating prevdoc status, 
+
+		# Updating stock ledger should always be called after updating prevdoc status,
 		# because updating reserved qty in bin depends upon updated delivered qty in SO
 		if self.update_stock == 1:
 			self.update_stock_ledger()
@@ -466,14 +466,14 @@
 				msgprint(_("POS Profile required to make POS Entry"), raise_exception=True)
 
 		return warehouse
-		
+
 	def set_income_account_for_fixed_assets(self):
 		disposal_account = depreciation_cost_center = None
 		for d in self.get("items"):
 			if d.is_fixed_asset:
 				if not disposal_account:
 					disposal_account, depreciation_cost_center = get_disposal_account_and_cost_center(self.company)
-					
+
 				d.income_account = disposal_account
 				if not d.cost_center:
 					d.cost_center = depreciation_cost_center
@@ -573,12 +573,12 @@
 			if flt(item.base_net_amount):
 				if item.is_fixed_asset:
 					asset = frappe.get_doc("Asset", item.asset)
-				
+
 					fixed_asset_gl_entries = get_gl_entries_on_asset_disposal(asset, item.base_net_amount)
 					for gle in fixed_asset_gl_entries:
 						gle["against"] = self.customer
 						gl_entries.append(self.get_gl_dict(gle))
-					
+
 					asset.db_set("disposal_date", self.posting_date)
 					asset.set_status("Sold" if self.docstatus==1 else None)
 				else:
diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js
index 8617a26..d101ece 100644
--- a/erpnext/buying/doctype/purchase_common/purchase_common.js
+++ b/erpnext/buying/doctype/purchase_common/purchase_common.js
@@ -10,6 +10,16 @@
 cur_frm.email_field = "contact_email";
 
 erpnext.buying.BuyingController = erpnext.TransactionController.extend({
+	setup: function() {
+		this._super();
+		this.frm.get_field('items').grid.editable_fields = [
+			{fieldname: 'item_code', columns: 4},
+			{fieldname: 'qty', columns: 2},
+			{fieldname: 'rate', columns: 3},
+			{fieldname: 'amount', columns: 2}
+		];
+	},
+
 	onload: function() {
 		this.setup_queries();
 		this._super();
diff --git a/erpnext/patches/v7_0/update_home_page.py b/erpnext/patches/v7_0/update_home_page.py
index 25f814b..f646405 100644
--- a/erpnext/patches/v7_0/update_home_page.py
+++ b/erpnext/patches/v7_0/update_home_page.py
@@ -2,7 +2,9 @@
 import erpnext
 
 def execute():
+	frappe.reload_doc('portal', 'doctype', 'homepage_featured_product')
 	frappe.reload_doc('portal', 'doctype', 'homepage')
+	frappe.reload_doc('portal', 'doctype', 'products_settings')
 
 	website_settings = frappe.get_doc('Website Settings', 'Website Settings')
 	if frappe.db.exists('Web Page', website_settings.home_page):
diff --git a/erpnext/public/css/erpnext.css b/erpnext/public/css/erpnext.css
index 346cfa0..6777e1e 100644
--- a/erpnext/public/css/erpnext.css
+++ b/erpnext/public/css/erpnext.css
@@ -124,55 +124,3 @@
 .dashboard-list-item:last-child {
   border-bottom: none;
 }
-
-.payment-toolbar {
-	margin-left: 35px;
-}
-
-.payment-mode {
-	cursor: pointer;
-	font-family: sans-serif;
-	font-size: 15px;
-}
-
-.pos-payment-row .col-xs-6 {
-	padding :10px;
-}
-
-.pos-payment-row {
-	border-bottom:1px solid #d1d8dd;
-    margin: 2px 0px 5px 0px;
-}
-
-.pos-payment-row:hover, .pos-keyboard-key:hover{
-	background-color: #FAFBFC;
-	cursor: pointer;
-}
-
-.pos-keyboard-key, .delete-btn {
-	border: 1px solid #d1d8dd;
-	height:85px;
-	width:85px;
-	margin:10px 10px;
-	font-size:24px;
-	font-weight:200;
-	background-color: #FDFDFD;
-	border-color: #e8e8e8;
-}
-
-.amount {
-	margin-top: 5px;
-}
-
-.amount-label {
-	font-size: 16px;
-}
-
-.selected-payment-mode {
-	background-color: #FAFBFC;
-	cursor: pointer;
-}
-
-.pos-invoice-list {
-	padding: 15px 10px;
-}
diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js
index 17050ca..29501f5 100644
--- a/erpnext/selling/doctype/sales_order/sales_order.js
+++ b/erpnext/selling/doctype/sales_order/sales_order.js
@@ -8,6 +8,10 @@
 		erpnext.queries.setup_queries(frm, "Warehouse", function() {
 			return erpnext.queries.warehouse(frm.doc);
 		});
+
+		// formatter for material request item
+		frm.set_indicator_formatter('item_code',
+			function(doc) { return (doc.qty<=doc.delivered_qty) ? "green" : "orange" })
 	}
 });
 
@@ -117,7 +121,7 @@
 	tc_name: function() {
 		this.get_terms();
 	},
-	
+
 	make_material_request: function() {
 		frappe.model.open_mapped_doc({
 			method: "erpnext.selling.doctype.sales_order.sales_order.make_material_request",
diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js
index e613daf..d02fed2 100644
--- a/erpnext/selling/sales_common.js
+++ b/erpnext/selling/sales_common.js
@@ -10,12 +10,24 @@
 
 frappe.provide("erpnext.selling");
 erpnext.selling.SellingController = erpnext.TransactionController.extend({
+	setup: function() {
+		this._super();
+		this.frm.get_field('items').grid.editable_fields = [
+			{fieldname: 'item_code', columns: 4},
+			{fieldname: 'qty', columns: 2},
+			{fieldname: 'rate', columns: 3},
+			{fieldname: 'amount', columns: 2}
+		];
+	},
+
 	onload: function() {
 		this._super();
 		this.setup_queries();
 	},
 
 	setup_queries: function() {
+
+
 		var me = this;
 
 		this.frm.add_fetch("sales_partner", "commission_rate", "commission_rate");
@@ -336,17 +348,21 @@
 
 frappe.ui.form.on(cur_frm.doctype,"project", function(frm) {
 	if(in_list(["Delivery Note", "Sales Invoice"], frm.doc.doctype)) {
-		frappe.call({
-			method:'erpnext.projects.doctype.project.project.get_cost_center_name' ,
-			args: {	project: frm.doc.project	},
-			callback: function(r, rt) {
-				if(!r.exc) {
-					$.each(frm.doc["items"] || [], function(i, row) {
-						frappe.model.set_value(row.doctype, row.name, "cost_center", r.message);
-						msgprint(__("Cost Center For Item with Item Code '"+row.item_name+"' has been Changed to "+ r.message));
-					})
+		if(frm.doc.project) {
+			frappe.call({
+				method:'erpnext.projects.doctype.project.project.get_cost_center_name' ,
+				args: {	project: frm.doc.project	},
+				callback: function(r, rt) {
+					if(!r.exc) {
+						$.each(frm.doc["items"] || [], function(i, row) {
+							if(r.message) {
+								frappe.model.set_value(row.doctype, row.name, "cost_center", r.message);
+								msgprint(__("Cost Center For Item with Item Code '"+row.item_name+"' has been Changed to "+ r.message));
+							}
+						})
+					}
 				}
-			}
-		})
+			})
+		}
 	}
 })
diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js
index 2195a58..68ce231 100644
--- a/erpnext/stock/doctype/material_request/material_request.js
+++ b/erpnext/stock/doctype/material_request/material_request.js
@@ -7,20 +7,15 @@
 	setup: function(frm) {
 		frm.get_field('items').grid.editable_fields = [
 			{fieldname: 'item_code', columns: 4},
-			{fieldname: 'qty', columns: 3},
-			{fieldname: 'uom', columns: 2},
+			{fieldname: 'qty', columns: 2},
+			{fieldname: 'warehouse', columns: 3},
 			{fieldname: 'schedule_date', columns: 2},
 		];
-
+	},
+	onload: function(frm) {
 		// formatter for material request item
-		frappe.meta.set_formatter('Material Request Item', 'item_code', frm.doc.name,
-			function(value, df, options, doc) {
-				return repl('<span class="indicator %(color)s">%(name)s</span>', {
-					color: (doc.qty<=doc.ordered_qty) ? "green" : "orange",
-					name: doc.item_code
-				});
-			}
-		);
+		frm.set_indicator_formatter('item_code',
+			function(doc) { return (doc.qty<=doc.ordered_qty) ? "green" : "orange" })
 	}
 });
 
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index 76b0395..737902b 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -49,6 +49,14 @@
 				};
 			});
 		}
+
+		this.frm.get_field('items').grid.editable_fields = [
+			{fieldname: 'item_code', columns: 3},
+			{fieldname: 'qty', columns: 2},
+			{fieldname: 's_warehouse', columns: 3},
+			{fieldname: 't_warehouse', columns: 3}
+		];
+
 	},
 
 	onload_post_render: function() {
diff --git a/erpnext/templates/form_grid/material_request_grid.html b/erpnext/templates/form_grid/material_request_grid.html
deleted file mode 100644
index 282437a..0000000
--- a/erpnext/templates/form_grid/material_request_grid.html
+++ /dev/null
@@ -1,49 +0,0 @@
-{% var visible_columns = row.get_visible_columns(["item_code", "warehouse",
-	"item_name", "amount", "stock_uom", "uom", "qty", "schedule_date"]); %}
-
-{% if(!doc) { %}
-	<div class="row">
-		<div class="col-sm-4">{%= __("Item") %}</div>
-		<div class="col-sm-3">{%= __("Required On") %}</div>
-		<div class="col-sm-3">{%= __("Warehouse") %}</div>
-		<div class="col-sm-2 text-right">{%= __("Qty") %}</div>
-	</div>
-{% } else { %}
-	<div class="row">
-		<div class="col-sm-4">
-            <span class="indicator {%= (doc.qty<=doc.ordered_qty) ? "green" : "orange" %}">{%= doc.item_code %}</span>
-			{% if(doc.item_name != doc.item_code) { %}
-				<br>{%= doc.item_name %}{% } %}
-            <!-- {% if(doc.item_name != doc.description) { %}
-                <p>{%= doc.description %}</p>{% } %} -->
-			{% include "templates/form_grid/includes/visible_cols.html" %}
-		</div>
-
-
-		<div class="col-sm-3">
-			{% if(doc.schedule_date) { %}
-                <span title="{%= __("Reqd By Date") %}" class="{%=
-				(frappe.datetime.get_diff(doc.schedule_date, frappe.datetime.get_today()) < 0
-					&& doc.ordered_qty < doc.qty)
-					? "text-danger" : "text-muted" %}">
-					{%= doc.get_formatted("schedule_date") %}</span>
-			{% } %}
-        </div>
-
-        <!-- warehouse -->
-		<div class="col-sm-3">
-			{% if(doc.warehouse) { %}
-				<span class="label label-default" title="{%= __("For Warehouse") %}"
-                    style="margin-right: 10px;">
-					{%= doc.warehouse %}
-				</span>
-			{% } %}
-        </div>
-
-		<!-- qty -->
-		<div class="col-sm-2 text-right">
-			{%= doc.get_formatted("qty") %}
-			<span class="small">{%= doc.uom || doc.stock_uom %}</span>
-		</div>
-	</div>
-{% } %}