Fixes issue #12512
diff --git a/erpnext/stock/dashboard/item_dashboard.js b/erpnext/stock/dashboard/item_dashboard.js
index 0422026..4a52526 100644
--- a/erpnext/stock/dashboard/item_dashboard.js
+++ b/erpnext/stock/dashboard/item_dashboard.js
@@ -82,18 +82,11 @@
var message = __(" Currently no stock available in any warehouse")
$("<span class='text-muted small'>"+message+"</span>").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 @@
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 @@
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 63f2480..7d7f7e4 100644
--- a/erpnext/stock/dashboard/item_dashboard_list.html
+++ b/erpnext/stock/dashboard/item_dashboard_list.html
@@ -40,18 +40,20 @@
</span>
</div>
<div class="col-sm-2 text-right" style="margin-top: 8px;">
- {% if d.actual_qty %}
- <button class="btn btn-default btn-xs btn-move"
- data-warehouse="{{ d.warehouse }}"
- data-actual_qty="{{ d.actual_qty }}"
- data-item="{{ d.item_code }}">{{ __("Move") }}</a>
+ {% if can_write %}
+ {% if d.actual_qty %}
+ <button class="btn btn-default btn-xs btn-move"
+ data-warehouse="{{ d.warehouse }}"
+ data-actual_qty="{{ d.actual_qty }}"
+ data-item="{{ d.item_code }}">{{ __("Move") }}</a>
+ {% endif %}
+ <button style="margin-left: 7px;" class="btn btn-default btn-xs btn-add"
+ data-warehouse="{{ d.warehouse }}"
+ data-actual_qty="{{ d.actual_qty }}"
+ data-item="{{ d.item_code }}"
+ data-rate="{{ d.valuation_rate }}">{{ __("Add") }}</a>
{% endif %}
- <button style="margin-left: 7px;" class="btn btn-default btn-xs btn-add"
- data-warehouse="{{ d.warehouse }}"
- data-actual_qty="{{ d.actual_qty }}"
- data-item="{{ d.item_code }}"
- data-rate="{{ d.valuation_rate }}">{{ __("Add") }}</a>
</div>
</div>
</div>
-{% endfor %}
+{% endfor %}
\ No newline at end of file