Fix to issue #12512
This commit is contained in:
rohitwaghchaure 2018-01-25 17:13:05 +05:30 committed by GitHub
commit fc318ebeff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -75,7 +75,7 @@ erpnext.stock.ItemDashboard = Class.extend({
this.content.find('.more').addClass('hidden'); 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) { if (context.data.length > 0) {
$(frappe.render_template('item_dashboard_list', context)).appendTo(this.result); $(frappe.render_template('item_dashboard_list', context)).appendTo(this.result);
} else { } else {
@ -86,6 +86,7 @@ erpnext.stock.ItemDashboard = Class.extend({
get_item_dashboard_data: function(data, max_count, show_item) { get_item_dashboard_data: function(data, max_count, show_item) {
if(!max_count) max_count = 0; if(!max_count) max_count = 0;
if(!data) data = []; if(!data) data = [];
data.forEach(function(d) { data.forEach(function(d) {
d.actual_or_pending = d.projected_qty + d.reserved_qty + d.reserved_qty_for_production; d.actual_or_pending = d.projected_qty + d.reserved_qty + d.reserved_qty_for_production;
d.pending_qty = 0; d.pending_qty = 0;
@ -97,9 +98,16 @@ erpnext.stock.ItemDashboard = Class.extend({
max_count = Math.max(d.actual_or_pending, d.actual_qty, max_count = Math.max(d.actual_or_pending, d.actual_qty,
d.total_reserved, max_count); d.total_reserved, max_count);
}); });
var can_write = 0;
if(frappe.boot.user.can_write.indexOf("Stock Entry")>=0){
can_write = 1;
}
return { return {
data: data, data: data,
max_count: max_count, max_count: max_count,
can_write:can_write,
show_item: show_item || false show_item: show_item || false
} }
} }
@ -187,4 +195,4 @@ erpnext.stock.move_item = function(item, source, target, actual_qty, rate, callb
frappe.set_route('Form', doc.doctype, doc.name); frappe.set_route('Form', doc.doctype, doc.name);
}) })
}); });
} }

View File

@ -39,6 +39,7 @@
</span> </span>
</span> </span>
</div> </div>
{% if can_write %}
<div class="col-sm-2 text-right" style="margin-top: 8px;"> <div class="col-sm-2 text-right" style="margin-top: 8px;">
{% if d.actual_qty %} {% if d.actual_qty %}
<button class="btn btn-default btn-xs btn-move" <button class="btn btn-default btn-xs btn-move"
@ -52,6 +53,7 @@
data-item="{{ d.item_code }}" data-item="{{ d.item_code }}"
data-rate="{{ d.valuation_rate }}">{{ __("Add") }}</a> data-rate="{{ d.valuation_rate }}">{{ __("Add") }}</a>
</div> </div>
{% endif %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}