Make next document button hide/unhide

This commit is contained in:
Nabin Hait 2012-04-24 11:39:54 +05:30
parent e6d808820a
commit 663e971557
5 changed files with 14 additions and 45 deletions

View File

@ -47,32 +47,21 @@ cur_frm.cscript.get_item_defaults = function(doc) {
//======================= Refresh =====================================
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// Unhide Fields in Next Steps
// ---------------------------------
cur_frm.clear_custom_buttons();
if(doc.docstatus == 1 && doc.status != 'Stopped'){
var ch = getchildren('Indent Detail',doc.name,'indent_details');
var is_closed = 1;
for(var i in ch){
if(flt(ch[i].qty) > flt(ch[i].ordered_qty)) is_closed = 0;
}
if(!is_closed) {
if(doc.per_ordered < 100) {
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order'])
cur_frm.add_custom_button('Stop ' + cur_frm.cscript.indent_doctype_label, cur_frm.cscript['Stop Purchase Requisition'])
}
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
if(doc.docstatus == 1 && doc.status == 'Stopped')
if(doc.docstatus == 1 && doc.status == 'Stopped')
cur_frm.add_custom_button('Unstop ' + cur_frm.cscript.indent_doctype_label, cur_frm.cscript['Unstop Purchase Requisition'])
if(doc.docstatus == 1)
unhide_field(['Repair Purchase Requisition']);
else
hide_field(['Repair Purchase Requisition']);
if(doc.docstatus == 1) unhide_field(['Repair Purchase Requisition']);
else hide_field(['Repair Purchase Requisition']);
}
//======================= validation ===================================

View File

@ -58,22 +58,10 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, cdt, cdn);
if(doc.docstatus == 1 && doc.status != 'Stopped'){
var ch = getchildren('PO Detail',doc.name,'po_details');
var allow_billing = 0; var allow_receipt = 0;
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
for(var i in ch){
if(ch[i].qty > ch[i].received_qty) allow_receipt = 1;
if(ch[i].qty > ch[i].billed_qty) allow_billing = 1;
}
if(allow_receipt)
cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
if(allow_billing)
cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
if(allow_billing || allow_receipt)
cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
if(doc.per_received < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
if(doc.per_billed < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
if(doc.per_billed < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
}
if(doc.docstatus == 1 && doc.status == 'Stopped')

View File

@ -86,7 +86,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.per_delivered < 100 || doc.per_billed < 100)
cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
} else {
// un-stop
cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
}

View File

@ -62,12 +62,10 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.per_installed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', cur_frm.cscript['Make Installation Note']);
if (doc.docstatus!=1) {
hide_field(['SMS', 'Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
} else {
if (doc.docstatus==1) {
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
unhide_field(['SMS','Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
}
unhide_field('Repair Delivery Note');
} else hide_field('Repair Delivery Note');
if(doc.docstatus==0 && !doc.__islocal) {
cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);

View File

@ -62,15 +62,10 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.docstatus == 1){
var ch = getchildren('Purchase Receipt Detail',doc.name,'purchase_receipt_details');
allow_billing = 0;
for(var i in ch){
if(ch[i].qty > ch[i].billed_qty) allow_billing = 1;
}
cur_frm.add_custom_button('Make Purchase Invoice', cur_frm.cscript['Make Purchase Invoice']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
else{
if (doc.per_billed < 100) cur_frm.add_custom_button('Make Purchase Invoice', cur_frm.cscript['Make Purchase Invoice']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
unhide_field(['Repair Purchase Receipt']);
} else{
hide_field(['Repair Purchase Receipt']);
}
}