2016-04-21 13:30:34 +00:00
|
|
|
frappe.pages['stock-balance'].on_page_load = function(wrapper) {
|
|
|
|
var page = frappe.ui.make_app_page({
|
|
|
|
parent: wrapper,
|
2016-06-15 07:27:22 +00:00
|
|
|
title: 'Stock Summary',
|
2016-04-21 13:30:34 +00:00
|
|
|
single_column: true
|
|
|
|
});
|
2016-04-25 12:23:42 +00:00
|
|
|
page.start = 0;
|
2016-04-21 13:30:34 +00:00
|
|
|
|
2016-04-22 11:52:22 +00:00
|
|
|
page.warehouse_field = page.add_field({
|
2016-06-13 12:16:55 +00:00
|
|
|
fieldname: 'warehouse',
|
2016-04-21 13:30:34 +00:00
|
|
|
label: __('Warehouse'),
|
|
|
|
fieldtype:'Link',
|
|
|
|
options:'Warehouse',
|
|
|
|
change: function() {
|
2016-04-25 12:23:42 +00:00
|
|
|
page.item_dashboard.start = 0;
|
|
|
|
page.item_dashboard.refresh();
|
2016-04-21 13:30:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-04-22 11:52:22 +00:00
|
|
|
page.item_field = page.add_field({
|
2016-04-21 13:30:34 +00:00
|
|
|
fieldname: 'item_code',
|
|
|
|
label: __('Item'),
|
|
|
|
fieldtype:'Link',
|
|
|
|
options:'Item',
|
|
|
|
change: function() {
|
2016-04-25 12:23:42 +00:00
|
|
|
page.item_dashboard.start = 0;
|
|
|
|
page.item_dashboard.refresh();
|
2016-04-21 13:30:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-11-08 07:10:04 +00:00
|
|
|
page.item_group_field = page.add_field({
|
|
|
|
fieldname: 'item_group',
|
|
|
|
label: __('Item Group'),
|
|
|
|
fieldtype:'Link',
|
|
|
|
options:'Item Group',
|
|
|
|
change: function() {
|
|
|
|
page.item_dashboard.start = 0;
|
|
|
|
page.item_dashboard.refresh();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-04-22 07:53:16 +00:00
|
|
|
page.sort_selector = new frappe.ui.SortSelector({
|
2016-04-22 11:52:22 +00:00
|
|
|
parent: page.wrapper.find('.page-form'),
|
2016-04-22 07:53:16 +00:00
|
|
|
args: {
|
|
|
|
sort_by: 'projected_qty',
|
|
|
|
sort_order: 'asc',
|
|
|
|
options: [
|
|
|
|
{fieldname: 'projected_qty', label: __('Projected qty')},
|
|
|
|
{fieldname: 'reserved_qty', label: __('Reserved for sale')},
|
|
|
|
{fieldname: 'reserved_qty_for_production', label: __('Reserved for manufacturing')},
|
2017-04-06 18:03:36 +00:00
|
|
|
{fieldname: 'actual_qty', label: __('Actual qty in stock')},
|
2016-04-22 07:53:16 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
change: function(sort_by, sort_order) {
|
2016-04-25 12:23:42 +00:00
|
|
|
page.item_dashboard.sort_by = sort_by;
|
|
|
|
page.item_dashboard.sort_order = sort_order;
|
|
|
|
page.item_dashboard.start = 0;
|
|
|
|
page.item_dashboard.refresh();
|
2016-04-22 07:53:16 +00:00
|
|
|
}
|
2016-04-22 11:52:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
page.sort_selector.wrapper.css({'margin-right': '15px', 'margin-top': '4px'});
|
2016-04-21 13:30:34 +00:00
|
|
|
|
2016-04-29 11:52:42 +00:00
|
|
|
frappe.require('assets/js/item-dashboard.min.js', function() {
|
|
|
|
page.item_dashboard = new erpnext.stock.ItemDashboard({
|
|
|
|
parent: page.main,
|
|
|
|
})
|
2016-04-21 13:30:34 +00:00
|
|
|
|
2016-04-29 11:52:42 +00:00
|
|
|
page.item_dashboard.before_refresh = function() {
|
|
|
|
this.item_code = page.item_field.get_value();
|
|
|
|
this.warehouse = page.warehouse_field.get_value();
|
2016-11-08 07:10:04 +00:00
|
|
|
this.item_group = page.item_group_field.get_value();
|
2016-04-29 11:52:42 +00:00
|
|
|
}
|
2016-04-21 13:30:34 +00:00
|
|
|
|
2016-04-29 11:52:42 +00:00
|
|
|
page.item_dashboard.refresh();
|
2016-04-21 13:30:34 +00:00
|
|
|
|
2016-04-29 11:52:42 +00:00
|
|
|
// item click
|
|
|
|
var 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.item_dashboard.refresh();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_click('Item');
|
|
|
|
setup_click('Warehouse');
|
|
|
|
});
|
2016-04-22 11:52:22 +00:00
|
|
|
|
|
|
|
|
2017-04-06 18:03:36 +00:00
|
|
|
}
|