From 663e971557c68f3f2da119f774ae121c2731d51a Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Apr 2012 11:39:54 +0530 Subject: [PATCH] Make next document button hide/unhide --- erpnext/buying/doctype/indent/indent.js | 19 ++++--------------- .../doctype/purchase_order/purchase_order.js | 18 +++--------------- .../doctype/sales_order/sales_order.js | 1 - .../doctype/delivery_note/delivery_note.js | 8 +++----- .../purchase_receipt/purchase_receipt.js | 13 ++++--------- 5 files changed, 14 insertions(+), 45 deletions(-) diff --git a/erpnext/buying/doctype/indent/indent.js b/erpnext/buying/doctype/indent/indent.js index 570e06c1b8..089f8a76e9 100644 --- a/erpnext/buying/doctype/indent/indent.js +++ b/erpnext/buying/doctype/indent/indent.js @@ -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 =================================== diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 7af1204fa4..1b4cb37879 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -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') diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index a2aaf8f00d..e87c4dc6b8 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -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']); } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index d2b58f8fd6..6a9f0e19b4 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -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']); diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 7ad9d91928..1490426cfe 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -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']); } }