field toggle enabled if stock ledger entry exists

This commit is contained in:
Nabin Hait 2012-10-16 12:28:30 +05:30
parent 35d01ed3a4
commit 6425542d8f

View File

@ -18,18 +18,12 @@ cur_frm.cscript.refresh = function(doc) {
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
// read only if any stock ledger entry exists
if (!doc.__islocal) {
set_field_permlevel("item_code", 1);
}
cur_frm.toggle_enable("item_code", doc.__islocal);
if ((!doc.__islocal) && (doc.is_stock_item == 'Yes')) {
var callback = function(r, rt) {
if (r.message == 'exists') permlevel = 1;
else permlevel = 0;
set_field_permlevel('has_serial_no', permlevel);
set_field_permlevel('is_stock_item', permlevel);
set_field_permlevel('valuation_method', permlevel);
var enabled = (r.message == 'exists') ? false : true;
cur_frm.toggle_enable(['has_serial_no', 'is_stock_item', 'valuation_method'], enabled);
}
$c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback);
}