Show item name in item grid view based 'In List View' property
diff --git a/erpnext/templates/form_grid/includes/visible_cols.html b/erpnext/templates/form_grid/includes/visible_cols.html
index e9be40c..c26f279 100644
--- a/erpnext/templates/form_grid/includes/visible_cols.html
+++ b/erpnext/templates/form_grid/includes/visible_cols.html
@@ -1,6 +1,6 @@
{% $.each(visible_columns || [], function(i, df) { %}
{% var val = doc.get_formatted(df.fieldname);
- if((df.fieldname !== "description") && val) { %}
+ if((df.fieldname !== "description" && df.fieldname !== "item_name") && val) { %}
<div class="row">
<div class="col-xs-4 text-ellipsis">
<strong title="{%= __(df.label) %}">{%= __(df.label) %}:</strong>
diff --git a/erpnext/templates/form_grid/item_grid.html b/erpnext/templates/form_grid/item_grid.html
index 8ea3e7d..d2db463 100644
--- a/erpnext/templates/form_grid/item_grid.html
+++ b/erpnext/templates/form_grid/item_grid.html
@@ -1,4 +1,4 @@
-{% var visible_columns = row.get_visible_columns(["item_code", "item_name", "qty", "rate", "amount", "stock_uom", "uom", "discount_percentage", "schedule_date", "warehouse", "against_sales_order", "sales_order"]); %}
+{% var visible_columns = row.get_visible_columns(["item_code", "qty", "rate", "amount", "stock_uom", "uom", "discount_percentage", "schedule_date", "warehouse", "against_sales_order", "sales_order"]); %}
{% if(!doc) { %}
<div class="row">
@@ -8,6 +8,7 @@
<div class="col-sm-2 col-xs-4 text-right">{%= __("Amount") %}</div>
</div>
{% } else { %}
+ {% var visible_column_fieldnames = $.map(visible_columns, function(x, i) {return x.fieldname}); %}
<div class="row">
<div class="col-sm-6 col-xs-8">
{% if(doc.warehouse) {
@@ -45,11 +46,11 @@
<strong>{%= doc.item_code %}</strong>
{% } %}
- {% if(doc.item_name != doc.item_code) { %}
+ {% if(doc.item_name != doc.item_code && in_list(visible_column_fieldnames, "item_name")) { %}
<br>{%= doc.item_name %}{% } %}
{% if((doc.description != doc.item_code != doc.item_name) &&
- in_list($.map(visible_columns, function(x, i) {return x.fieldname}), "description")) { %}
+ in_list(visible_column_fieldnames, "description")) { %}
<br>
<strong>Description: </strong>
{%= doc.get_formatted("description") %}{% } %}