From 2c8ce5a717ab48b3060402b464dc5fd7bcbda50a Mon Sep 17 00:00:00 2001 From: Vinayak Jethe Date: Wed, 24 Jan 2018 13:51:26 +0530 Subject: [PATCH 1/5] Fixes issue #12512 --- erpnext/stock/dashboard/item_dashboard.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index 3c334c46b6..5e5dc0a142 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -75,13 +75,21 @@ erpnext.stock.ItemDashboard = Class.extend({ this.content.find('.more').addClass('hidden'); } - // If not any stock in any warehouses provide a message to end user + // If not any stock in any warehouses provide a message to end user if (context.data.length > 0) { $(frappe.render_template('item_dashboard_list', context)).appendTo(this.result); } else { var message = __(" Currently no stock available in any warehouse") $(""+message+"").appendTo(this.result); } + + if (frappe.boot.user.can_write.indexOf("Stock Entry")>=0){ + $(".btn-move").show(); + + $(".btn-add").show(); + }else{ + $(".btn-move").hide(); + + $(".btn-add").hide(); + } }, get_item_dashboard_data: function(data, max_count, show_item) { if(!max_count) max_count = 0; From 46c82c45e076223039720f5efe4c91497d3b2312 Mon Sep 17 00:00:00 2001 From: Vinayak Jethe Date: Wed, 24 Jan 2018 14:24:58 +0530 Subject: [PATCH 2/5] Revised changes for codacy --- erpnext/stock/dashboard/item_dashboard.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index 5e5dc0a142..0422026084 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -85,10 +85,10 @@ erpnext.stock.ItemDashboard = Class.extend({ if (frappe.boot.user.can_write.indexOf("Stock Entry")>=0){ $(".btn-move").show(); - + $(".btn-add").show(); + $(".btn-add").show(); }else{ $(".btn-move").hide(); - + $(".btn-add").hide(); + $(".btn-add").hide(); } }, get_item_dashboard_data: function(data, max_count, show_item) { From 549c196bebf2a116f1e38b66d6884e20bf909a46 Mon Sep 17 00:00:00 2001 From: Vinayak Jethe Date: Wed, 24 Jan 2018 19:47:59 +0530 Subject: [PATCH 3/5] Fixes issue #12512 --- erpnext/stock/dashboard/item_dashboard.js | 18 +++++++------- .../stock/dashboard/item_dashboard_list.html | 24 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js index 0422026084..4a525261b8 100644 --- a/erpnext/stock/dashboard/item_dashboard.js +++ b/erpnext/stock/dashboard/item_dashboard.js @@ -82,18 +82,11 @@ erpnext.stock.ItemDashboard = Class.extend({ var message = __(" Currently no stock available in any warehouse") $(""+message+"").appendTo(this.result); } - - if (frappe.boot.user.can_write.indexOf("Stock Entry")>=0){ - $(".btn-move").show(); - $(".btn-add").show(); - }else{ - $(".btn-move").hide(); - $(".btn-add").hide(); - } }, get_item_dashboard_data: function(data, max_count, show_item) { if(!max_count) max_count = 0; if(!data) data = []; + data.forEach(function(d) { d.actual_or_pending = d.projected_qty + d.reserved_qty + d.reserved_qty_for_production; d.pending_qty = 0; @@ -105,9 +98,16 @@ erpnext.stock.ItemDashboard = Class.extend({ max_count = Math.max(d.actual_or_pending, d.actual_qty, d.total_reserved, max_count); }); + + var can_write = 0; + if(frappe.boot.user.can_write.indexOf("Stock Entry")>=0){ + can_write = 1; + } + return { data: data, max_count: max_count, + can_write:can_write, show_item: show_item || false } } @@ -195,4 +195,4 @@ erpnext.stock.move_item = function(item, source, target, actual_qty, rate, callb frappe.set_route('Form', doc.doctype, doc.name); }) }); -} +} \ No newline at end of file diff --git a/erpnext/stock/dashboard/item_dashboard_list.html b/erpnext/stock/dashboard/item_dashboard_list.html index 63f248043c..7d7f7e4c71 100644 --- a/erpnext/stock/dashboard/item_dashboard_list.html +++ b/erpnext/stock/dashboard/item_dashboard_list.html @@ -40,18 +40,20 @@
- {% if d.actual_qty %} -
-{% endfor %} +{% endfor %} \ No newline at end of file From 5743ce2b6b1ae4c545f3555a6b0813bccffb04e0 Mon Sep 17 00:00:00 2001 From: Vinayak Jethe Date: Thu, 25 Jan 2018 13:37:20 +0530 Subject: [PATCH 4/5] Made changes as per suggestions --- erpnext/stock/dashboard/item_dashboard_list.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/dashboard/item_dashboard_list.html b/erpnext/stock/dashboard/item_dashboard_list.html index 7d7f7e4c71..1abb086778 100644 --- a/erpnext/stock/dashboard/item_dashboard_list.html +++ b/erpnext/stock/dashboard/item_dashboard_list.html @@ -39,8 +39,8 @@ + {% if can_write %}
- {% if can_write %} {% if d.actual_qty %}
+ {% endif %} {% endfor %} \ No newline at end of file From 3574c96c8c0be7eb3e484b03f4b7f9d846e3f3a3 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Thu, 25 Jan 2018 17:11:52 +0530 Subject: [PATCH 5/5] Update item_dashboard_list.html --- .../stock/dashboard/item_dashboard_list.html | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/erpnext/stock/dashboard/item_dashboard_list.html b/erpnext/stock/dashboard/item_dashboard_list.html index 1abb086778..e0b3431839 100644 --- a/erpnext/stock/dashboard/item_dashboard_list.html +++ b/erpnext/stock/dashboard/item_dashboard_list.html @@ -41,19 +41,19 @@ {% if can_write %}
- {% if d.actual_qty %} -
{% endif %} -{% endfor %} \ No newline at end of file +{% endfor %}