mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
Make next document button hide/unhide
This commit is contained in:
@@ -47,19 +47,10 @@ cur_frm.cscript.get_item_defaults = function(doc) {
|
|||||||
|
|
||||||
//======================= Refresh =====================================
|
//======================= Refresh =====================================
|
||||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||||
|
|
||||||
// Unhide Fields in Next Steps
|
|
||||||
// ---------------------------------
|
|
||||||
|
|
||||||
cur_frm.clear_custom_buttons();
|
cur_frm.clear_custom_buttons();
|
||||||
|
|
||||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
||||||
var ch = getchildren('Indent Detail',doc.name,'indent_details');
|
if(doc.per_ordered < 100) {
|
||||||
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) {
|
|
||||||
cur_frm.add_custom_button('Make Purchase Order', cur_frm.cscript['Make Purchase Order'])
|
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('Stop ' + cur_frm.cscript.indent_doctype_label, cur_frm.cscript['Stop Purchase Requisition'])
|
||||||
}
|
}
|
||||||
@@ -69,10 +60,8 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
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'])
|
cur_frm.add_custom_button('Unstop ' + cur_frm.cscript.indent_doctype_label, cur_frm.cscript['Unstop Purchase Requisition'])
|
||||||
|
|
||||||
if(doc.docstatus == 1)
|
if(doc.docstatus == 1) unhide_field(['Repair Purchase Requisition']);
|
||||||
unhide_field(['Repair Purchase Requisition']);
|
else hide_field(['Repair Purchase Requisition']);
|
||||||
else
|
|
||||||
hide_field(['Repair Purchase Requisition']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//======================= validation ===================================
|
//======================= validation ===================================
|
||||||
|
|||||||
@@ -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 (!cur_frm.cscript.is_onload) cur_frm.cscript.dynamic_label(doc, cdt, cdn);
|
||||||
|
|
||||||
if(doc.docstatus == 1 && doc.status != 'Stopped'){
|
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']);
|
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||||
|
if(doc.per_received < 100) cur_frm.add_custom_button('Make Purchase Receipt', cur_frm.cscript['Make Purchase Receipt']);
|
||||||
for(var i in ch){
|
if(doc.per_billed < 100) cur_frm.add_custom_button('Make Invoice', cur_frm.cscript['Make Purchase Invoice']);
|
||||||
if(ch[i].qty > ch[i].received_qty) allow_receipt = 1;
|
if(doc.per_billed < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']);
|
||||||
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.docstatus == 1 && doc.status == 'Stopped')
|
if(doc.docstatus == 1 && doc.status == 'Stopped')
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
if(doc.per_delivered < 100 || doc.per_billed < 100)
|
if(doc.per_delivered < 100 || doc.per_billed < 100)
|
||||||
cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
|
cur_frm.add_custom_button('Stop!', cur_frm.cscript['Stop Sales Order']);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// un-stop
|
// un-stop
|
||||||
cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
|
cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.per_installed < 100 && doc.docstatus==1) cur_frm.add_custom_button('Make Installation Note', cur_frm.cscript['Make Installation Note']);
|
||||||
|
|
||||||
if (doc.docstatus!=1) {
|
if (doc.docstatus==1) {
|
||||||
hide_field(['SMS', 'Send SMS', 'message', 'customer_mobile_no', 'Repair Delivery Note']);
|
|
||||||
} else {
|
|
||||||
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
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) {
|
if(doc.docstatus==0 && !doc.__islocal) {
|
||||||
cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
|
cur_frm.add_custom_button('Make Packing Slip', cur_frm.cscript['Make Packing Slip']);
|
||||||
|
|||||||
@@ -62,15 +62,10 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
|
|
||||||
|
|
||||||
if(doc.docstatus == 1){
|
if(doc.docstatus == 1){
|
||||||
var ch = getchildren('Purchase Receipt Detail',doc.name,'purchase_receipt_details');
|
if (doc.per_billed < 100) cur_frm.add_custom_button('Make Purchase Invoice', cur_frm.cscript['Make Purchase Invoice']);
|
||||||
allow_billing = 0;
|
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
|
||||||
for(var i in ch){
|
unhide_field(['Repair Purchase Receipt']);
|
||||||
if(ch[i].qty > ch[i].billed_qty) allow_billing = 1;
|
} else{
|
||||||
}
|
|
||||||
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{
|
|
||||||
hide_field(['Repair Purchase Receipt']);
|
hide_field(['Repair Purchase Receipt']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user