brotherton-erpnext/erpnext/stock/page/stock_balance/stock_balance.js
Nabin Hait 2c7a6e6b43
Reserve for subcontracting (#13195)
* [fix] #8427

* review comments changes

* Validation for reserved warhouse

* code improvements

* alignment

* test case

* message changes

* default warehouse / remove validation / change sql

* fix

* patch

* Fixed merge conflict

* Fixes and cleanups of reserve qty for subcontracting

* set from_warehouse only if purchase_order and purpose found (#12398)

* [HotFix] Validation issue for subcontract stock entry (#12127)

* [Fix] Validation issue for subcontract stock entry

* Update stock_entry.py

* Fixes and cleanups of reserve qty for subcontracting

* patch fixed

* Reload bin in patch

* [fix] set source warehouse in stock entry for manufacture

* [fix] #8540

* code alignment

* code alignment

* Move target warehouse validation to submit

* validation code improvement

* code changes for single stock entry

* validation fix

* call make_rm_stock_entry

* remove old stock entry method/rewrite test case

* Don't set bom_no against raw materials while trasferring items for sub-contracting

* minor fix
2018-03-12 14:12:12 +05:30

98 lines
2.5 KiB
JavaScript

frappe.pages['stock-balance'].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: 'Stock Summary',
single_column: true
});
page.start = 0;
page.warehouse_field = page.add_field({
fieldname: 'warehouse',
label: __('Warehouse'),
fieldtype:'Link',
options:'Warehouse',
change: function() {
page.item_dashboard.start = 0;
page.item_dashboard.refresh();
}
});
page.item_field = page.add_field({
fieldname: 'item_code',
label: __('Item'),
fieldtype:'Link',
options:'Item',
change: function() {
page.item_dashboard.start = 0;
page.item_dashboard.refresh();
}
});
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();
}
});
page.sort_selector = new frappe.ui.SortSelector({
parent: page.wrapper.find('.page-form'),
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')},
{fieldname: 'reserved_qty_for_sub_contract', label: __('Reserved for sub contracting')},
{fieldname: 'actual_qty', label: __('Actual qty in stock')},
]
},
change: function(sort_by, sort_order) {
page.item_dashboard.sort_by = sort_by;
page.item_dashboard.sort_order = sort_order;
page.item_dashboard.start = 0;
page.item_dashboard.refresh();
}
});
page.sort_selector.wrapper.css({'margin-right': '15px', 'margin-top': '4px'});
frappe.require('assets/js/item-dashboard.min.js', function() {
page.item_dashboard = new erpnext.stock.ItemDashboard({
parent: page.main,
})
page.item_dashboard.before_refresh = function() {
this.item_code = page.item_field.get_value();
this.warehouse = page.warehouse_field.get_value();
this.item_group = page.item_group_field.get_value();
}
page.item_dashboard.refresh();
// 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');
});
}