mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-03 20:29:09 +00:00
feat: Warehouse Capacity Summary
- Added Page Warehouse Capacity Summary - Added Page to Desk and Putaway List View - Reused Item Dashboard/Stock Balance page render code - Added naming series to Putaway Rule
This commit is contained in:
@@ -65,6 +65,9 @@ frappe.pages['stock-balance'].on_page_load = function(wrapper) {
|
||||
frappe.require('assets/js/item-dashboard.min.js', function() {
|
||||
page.item_dashboard = new erpnext.stock.ItemDashboard({
|
||||
parent: page.main,
|
||||
page_length: 20,
|
||||
method: 'erpnext.stock.dashboard.item_dashboard.get_data',
|
||||
template: 'item_dashboard_list'
|
||||
})
|
||||
|
||||
page.item_dashboard.before_refresh = function() {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
{% for d in data %}
|
||||
<div class="dashboard-list-item" style="padding: 7px 15px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-2 small" style="margin-top: 8px;">
|
||||
<a data-type="warehouse" data-name="{{ d.warehouse }}">{{ d.warehouse }}</a>
|
||||
</div>
|
||||
<div class="col-sm-2 small" style="margin-top: 8px; ">
|
||||
<a data-type="item" data-name="{{ d.item_code }}">{{ d.item_code }}</a>
|
||||
</div>
|
||||
<div class="col-sm-1 small" style="margin-top: 8px; ">
|
||||
{{ d.stock_capacity }}
|
||||
</div>
|
||||
<div class="col-sm-2 small" style="margin-top: 8px; ">
|
||||
{{ d.actual_qty }}
|
||||
</div>
|
||||
<div class="col-sm-2 small">
|
||||
<div class="progress" title="Occupied Qty: {{ d.actual_qty }}" style="margin-bottom: 4px; height: 7px; margin-top: 14px;">
|
||||
<div class="progress-bar" role="progressbar"
|
||||
aria-valuenow="{{ d.percent_occupied }}"
|
||||
aria-valuemin="0" aria-valuemax="100"
|
||||
style="width:{{ d.percent_occupied }}%;
|
||||
background-color: {{ d.color }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-1 small" style="margin-top: 8px;">
|
||||
{{ d.percent_occupied }}%
|
||||
</div>
|
||||
{% if can_write %}
|
||||
<div class="col-sm-1 text-right" style="margin-top: 2px;">
|
||||
<button class="btn btn-default btn-xs btn-edit"
|
||||
style="margin-top: 4px;margin-bottom: 4px;"
|
||||
data-warehouse="{{ d.warehouse }}"
|
||||
data-item="{{ escape(d.item_code) }}"
|
||||
data-company="{{ escape(d.company) }}">{{ __("Edit Capacity") }}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -0,0 +1,120 @@
|
||||
frappe.pages['warehouse-capacity-summary'].on_page_load = function(wrapper) {
|
||||
var page = frappe.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
title: 'Warehouse Capacity Summary',
|
||||
single_column: true
|
||||
});
|
||||
page.set_secondary_action('Refresh', () => page.capacity_dashboard.refresh(), 'octicon octicon-sync');
|
||||
page.start = 0;
|
||||
|
||||
page.company_field = page.add_field({
|
||||
fieldname: 'company',
|
||||
label: __('Company'),
|
||||
fieldtype:'Link',
|
||||
options:'Company',
|
||||
reqd: 1,
|
||||
default: frappe.defaults.get_default("company"),
|
||||
change: function() {
|
||||
page.capacity_dashboard.start = 0;
|
||||
page.capacity_dashboard.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
page.warehouse_field = page.add_field({
|
||||
fieldname: 'warehouse',
|
||||
label: __('Warehouse'),
|
||||
fieldtype:'Link',
|
||||
options:'Warehouse',
|
||||
change: function() {
|
||||
page.capacity_dashboard.start = 0;
|
||||
page.capacity_dashboard.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
page.item_field = page.add_field({
|
||||
fieldname: 'item_code',
|
||||
label: __('Item'),
|
||||
fieldtype:'Link',
|
||||
options:'Item',
|
||||
change: function() {
|
||||
page.capacity_dashboard.start = 0;
|
||||
page.capacity_dashboard.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
page.parent_warehouse_field = page.add_field({
|
||||
fieldname: 'parent_warehouse',
|
||||
label: __('Parent Warehouse'),
|
||||
fieldtype:'Link',
|
||||
options:'Warehouse',
|
||||
get_query: function() {
|
||||
return {
|
||||
filters: {
|
||||
"is_group": 1
|
||||
}
|
||||
};
|
||||
},
|
||||
change: function() {
|
||||
page.capacity_dashboard.start = 0;
|
||||
page.capacity_dashboard.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
page.sort_selector = new frappe.ui.SortSelector({
|
||||
parent: page.wrapper.find('.page-form'),
|
||||
args: {
|
||||
sort_by: 'stock_capacity',
|
||||
sort_order: 'desc',
|
||||
options: [
|
||||
{fieldname: 'stock_capacity', label: __('Capacity (Stock UOM)')},
|
||||
{fieldname: 'percent_occupied', label:__('% Occupied')},
|
||||
{fieldname: 'actual_qty', label:__('Balance Qty (Stock ')}
|
||||
]
|
||||
},
|
||||
change: function(sort_by, sort_order) {
|
||||
page.capacity_dashboard.sort_by = sort_by;
|
||||
page.capacity_dashboard.sort_order = sort_order;
|
||||
page.capacity_dashboard.start = 0;
|
||||
page.capacity_dashboard.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
frappe.require('assets/js/item-dashboard.min.js', function() {
|
||||
$(frappe.render_template('warehouse_capacity_summary_header')).appendTo(page.main);
|
||||
|
||||
page.capacity_dashboard = new erpnext.stock.ItemDashboard({
|
||||
page_name: "warehouse-capacity-summary",
|
||||
page_length: 10,
|
||||
parent: page.main,
|
||||
sort_by: 'stock_capacity',
|
||||
sort_order: 'desc',
|
||||
method: 'erpnext.stock.dashboard.warehouse_capacity_dashboard.get_data',
|
||||
template: 'warehouse_capacity_summary'
|
||||
})
|
||||
|
||||
page.capacity_dashboard.before_refresh = function() {
|
||||
this.item_code = page.item_field.get_value();
|
||||
this.warehouse = page.warehouse_field.get_value();
|
||||
this.parent_warehouse = page.parent_warehouse_field.get_value();
|
||||
this.company = page.company_field.get_value();
|
||||
}
|
||||
|
||||
page.capacity_dashboard.refresh();
|
||||
|
||||
let setup_click = function(doctype) {
|
||||
page.main.on('click', 'a[data-type="'+ doctype.toLowerCase() +'"]', function() {
|
||||
var name = $(this).attr('data-name');
|
||||
var field = page[doctype.toLowerCase() + '_field'];
|
||||
if(field.get_value()===name) {
|
||||
frappe.set_route('Form', doctype, name)
|
||||
} else {
|
||||
field.set_input(name);
|
||||
page.capacity_dashboard.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setup_click('Item');
|
||||
setup_click('Warehouse');
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"content": null,
|
||||
"creation": "2020-11-25 12:07:54.056208",
|
||||
"docstatus": 0,
|
||||
"doctype": "Page",
|
||||
"idx": 0,
|
||||
"modified": "2020-11-25 11:07:54.056208",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "warehouse-capacity-summary",
|
||||
"owner": "Administrator",
|
||||
"page_name": "Warehouse Capacity Summary",
|
||||
"roles": [
|
||||
{
|
||||
"role": "Stock User"
|
||||
},
|
||||
{
|
||||
"role": "Stock Manager"
|
||||
}
|
||||
],
|
||||
"script": null,
|
||||
"standard": "Yes",
|
||||
"style": null,
|
||||
"system_page": 0,
|
||||
"title": "Warehouse Capacity Summary"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="dashboard-list-item" style="padding: 12px 15px;">
|
||||
<div class="row">
|
||||
<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
|
||||
Warehouse
|
||||
</div>
|
||||
<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
|
||||
Item
|
||||
</div>
|
||||
<div class="col-sm-1 small text-muted" style="margin-top: 8px;">
|
||||
Stock Capacity
|
||||
</div>
|
||||
<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
|
||||
Balance Stock Qty
|
||||
</div>
|
||||
<div class="col-sm-2 small text-muted" style="margin-top: 8px;">
|
||||
% Occupied
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user