Hide buttons for return entry

This commit is contained in:
Nabin Hait 2015-07-29 13:16:37 +05:30
parent 3ad26e4dd1
commit 1e046aa49a
7 changed files with 101 additions and 101 deletions

View File

@ -20,27 +20,19 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
this._super(); this._super();
// Show / Hide button // Show / Hide button
if(doc.docstatus==1 && doc.outstanding_amount > 0) this.show_general_ledger();
this.frm.add_custom_button(__('Make Payment Entry'), this.make_bank_entry);
if(!doc.is_return) {
if(doc.docstatus==1) { if(doc.docstatus==1) {
cur_frm.add_custom_button(__('Make Purchase Return'), this.make_purchase_return); if(doc.outstanding_amount > 0) {
this.frm.add_custom_button(__('Make Payment Entry'), this.make_bank_entry);
}
cur_frm.add_custom_button(__('View Ledger'), function() { cur_frm.add_custom_button(__('Make Purchase Return'), this.make_purchase_return);
frappe.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company,
group_by_voucher: 0
};
frappe.set_route("query-report", "General Ledger");
});
} }
if(doc.docstatus===0) { if(doc.docstatus===0) {
cur_frm.add_custom_button(__('From Purchase Order'), cur_frm.add_custom_button(__('From Purchase Order'), function() {
function() {
frappe.model.map_current_doc({ frappe.model.map_current_doc({
method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice", method: "erpnext.buying.doctype.purchase_order.purchase_order.make_purchase_invoice",
source_doctype: "Purchase Order", source_doctype: "Purchase Order",
@ -54,8 +46,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
}) })
}); });
cur_frm.add_custom_button(__('From Purchase Receipt'), cur_frm.add_custom_button(__('From Purchase Receipt'), function() {
function() {
frappe.model.map_current_doc({ frappe.model.map_current_doc({
method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
source_doctype: "Purchase Receipt", source_doctype: "Purchase Receipt",
@ -66,7 +57,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
} }
}) })
}); });
}
} }
}, },

View File

@ -43,18 +43,11 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
this.frm.toggle_reqd("due_date", !this.frm.doc.is_return); this.frm.toggle_reqd("due_date", !this.frm.doc.is_return);
if(doc.docstatus==1) { this.show_general_ledger();
cur_frm.add_custom_button('View Ledger', function() {
frappe.route_options = {
"voucher_no": doc.name,
"from_date": doc.posting_date,
"to_date": doc.posting_date,
"company": doc.company,
group_by_voucher: 0
};
frappe.set_route("query-report", "General Ledger");
});
if(doc.update_stock) this.show_stock_ledger();
if(doc.docstatus==1 && !doc.is_return) {
if(cint(doc.update_stock)!=1) { if(cint(doc.update_stock)!=1) {
// show Make Delivery Note button only if Sales Invoice is not created from Delivery Note // show Make Delivery Note button only if Sales Invoice is not created from Delivery Note
var from_delivery_note = false; var from_delivery_note = false;
@ -76,7 +69,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
} }
// Show buttons only when pos view is active // Show buttons only when pos view is active
if (cint(doc.docstatus==0) && cur_frm.page.current_view_name!=="pos") { if (cint(doc.docstatus==0) && cur_frm.page.current_view_name!=="pos" && !doc.is_return) {
cur_frm.cscript.sales_order_btn(); cur_frm.cscript.sales_order_btn();
cur_frm.cscript.delivery_note_btn(); cur_frm.cscript.delivery_note_btn();
} }

View File

@ -58,7 +58,7 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({
show_general_ledger: function() { show_general_ledger: function() {
var me = this; var me = this;
if(this.frm.doc.docstatus===1 && cint(frappe.defaults.get_default("auto_accounting_for_stock"))) { if(this.frm.doc.docstatus===1) {
cur_frm.add_custom_button(__('Accounting Ledger'), function() { cur_frm.add_custom_button(__('Accounting Ledger'), function() {
frappe.route_options = { frappe.route_options = {
voucher_no: me.frm.doc.name, voucher_no: me.frm.doc.name,

View File

@ -9,6 +9,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
refresh: function(doc, dt, dn) { refresh: function(doc, dt, dn) {
this._super(); this._super();
if (!doc.is_return) {
if(doc.__onload && !doc.__onload.billing_complete && doc.docstatus==1) { if(doc.__onload && !doc.__onload.billing_complete && doc.docstatus==1) {
// show Make Invoice button only if Delivery Note is not created from Sales Invoice // show Make Invoice button only if Delivery Note is not created from Sales Invoice
var from_sales_invoice = false; var from_sales_invoice = false;
@ -25,9 +26,6 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
if (doc.docstatus==1) { if (doc.docstatus==1) {
cur_frm.add_custom_button(__('Make Sales Return'), this.make_sales_return); cur_frm.add_custom_button(__('Make Sales Return'), this.make_sales_return);
this.show_stock_ledger();
this.show_general_ledger();
} }
if(doc.docstatus==0 && !doc.__islocal) { if(doc.docstatus==0 && !doc.__islocal) {
@ -35,12 +33,6 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
cur_frm.cscript['Make Packing Slip'], frappe.boot.doctype_icons["Packing Slip"]); cur_frm.cscript['Make Packing Slip'], frappe.boot.doctype_icons["Packing Slip"]);
} }
erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
// unhide expense_account and cost_center is auto_accounting_for_stock enabled
var aii_enabled = cint(sys_defaults.auto_accounting_for_stock)
cur_frm.fields_dict["items"].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled);
if (this.frm.doc.docstatus===0) { if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('From Sales Order'), cur_frm.add_custom_button(__('From Sales Order'),
function() { function() {
@ -58,7 +50,22 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend(
}) })
}); });
} }
}
if (doc.docstatus==1) {
this.show_stock_ledger();
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
this.show_general_ledger();
}
}
erpnext.stock.delivery_note.set_print_hide(doc, dt, dn);
// unhide expense_account and cost_center is auto_accounting_for_stock enabled
var aii_enabled = cint(sys_defaults.auto_accounting_for_stock)
cur_frm.fields_dict["items"].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled);
}, },
make_sales_invoice: function() { make_sales_invoice: function() {

View File

@ -29,16 +29,12 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
refresh: function() { refresh: function() {
this._super(); this._super();
if(this.frm.doc.docstatus == 1) {
if(this.frm.doc.__onload && !this.frm.doc.__onload.billing_complete) {
cur_frm.add_custom_button(__('Make Purchase Invoice'), this.make_purchase_invoice);
}
cur_frm.add_custom_button(__('Make Purchase Return'), this.make_purchase_return);
this.show_stock_ledger(); this.show_stock_ledger();
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
this.show_general_ledger(); this.show_general_ledger();
} else { }
if(!this.frm.doc.is_return) {
if(this.frm.doc.docstatus==0) {
cur_frm.add_custom_button(__('From Purchase Order'), cur_frm.add_custom_button(__('From Purchase Order'),
function() { function() {
frappe.model.map_current_doc({ frappe.model.map_current_doc({
@ -55,6 +51,15 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
}); });
} }
if(this.frm.doc.docstatus == 1) {
if(this.frm.doc.__onload && !this.frm.doc.__onload.billing_complete) {
cur_frm.add_custom_button(__('Make Purchase Invoice'), this.make_purchase_invoice);
}
cur_frm.add_custom_button(__('Make Purchase Return'), this.make_purchase_return);
}
}
this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes"); this.frm.toggle_reqd("supplier_warehouse", this.frm.doc.is_subcontracted==="Yes");
}, },

View File

@ -57,7 +57,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
this.toggle_related_fields(this.frm.doc); this.toggle_related_fields(this.frm.doc);
this.toggle_enable_bom(); this.toggle_enable_bom();
this.show_stock_ledger(); this.show_stock_ledger();
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
this.show_general_ledger(); this.show_general_ledger();
}
}, },
on_submit: function() { on_submit: function() {

View File

@ -83,8 +83,10 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({
refresh: function() { refresh: function() {
if(this.frm.doc.docstatus==1) { if(this.frm.doc.docstatus==1) {
this.show_stock_ledger(); this.show_stock_ledger();
if (cint(frappe.defaults.get_default("auto_accounting_for_stock"))) {
this.show_general_ledger(); this.show_general_ledger();
} }
}
}, },
}); });