make sensitive fields read only in item master if sle exists
This commit is contained in:
parent
fe11736995
commit
12b58ec5cc
@ -1,6 +1,18 @@
|
|||||||
cur_frm.cscript.refresh = function(doc) {
|
cur_frm.cscript.refresh = function(doc) {
|
||||||
if(cint(doc.is_local) && doc.has_serial_no) set_field_permlevel('has_serial_no', 1);
|
// make sensitive fields(has_serial_no, is_stock_item, valuation_method)
|
||||||
if(cint(doc.is_local) && doc.is_stock_item) set_field_permlevel('is_stock_item', 1);
|
// read only if any stock ledger entry exists
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
$c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -170,3 +170,11 @@ Total Available Qty: %s
|
|||||||
|
|
||||||
}
|
}
|
||||||
return str(ret)
|
return str(ret)
|
||||||
|
|
||||||
|
def check_if_sle_exists(self):
|
||||||
|
"""
|
||||||
|
checks if any stock ledger entry exists for this item
|
||||||
|
"""
|
||||||
|
|
||||||
|
sle = sql("select name from `tabStock Ledger Entry` where item_code = %s and ifnull(is_cancelled, 'No') = 'No'", self.doc.name)
|
||||||
|
return sle and 'exists' or 'not exists'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user