From 9eb9ccd785e4b92b7f1872ece1316208b406b5dd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 29 Jul 2015 13:23:37 +0530 Subject: [PATCH] Make Debit / Credit Note button in Purchase / Sales Invoice --- .../accounts/doctype/purchase_invoice/purchase_invoice.js | 6 +++--- .../accounts/doctype/purchase_invoice/purchase_invoice.py | 4 ++-- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 08ed4f3a81..e3245cbfae 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -28,7 +28,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ this.frm.add_custom_button(__('Make Payment Entry'), this.make_bank_entry); } - cur_frm.add_custom_button(__('Make Purchase Return'), this.make_purchase_return); + cur_frm.add_custom_button(__('Make Debit Note'), this.make_debit_note); } if(doc.docstatus===0) { @@ -103,9 +103,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ }) }, - make_purchase_return: function() { + make_debit_note: function() { frappe.model.open_mapped_doc({ - method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_purchase_return", + method: "erpnext.accounts.doctype.purchase_invoice.purchase_invoice.make_debit_note", frm: cur_frm }) }, diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 7e0ed7f390..6e85087f16 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -411,6 +411,6 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters): 'txt': "%%%s%%" % frappe.db.escape(txt), 'mcond':get_match_cond(doctype)}) @frappe.whitelist() -def make_purchase_return(source_name, target_doc=None): +def make_debit_note(source_name, target_doc=None): from erpnext.controllers.sales_and_purchase_return import make_return_doc - return make_return_doc("Purchase Invoice", source_name, target_doc) \ No newline at end of file + return make_return_doc("Purchase Invoice", source_name, target_doc) \ No newline at end of file diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 8348c08a51..017ab3a10d 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -65,7 +65,8 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte cur_frm.add_custom_button(__('Make Payment Entry'), cur_frm.cscript.make_bank_entry); } - cur_frm.add_custom_button(__('Make Sales Return'), this.make_sales_return); + cur_frm.add_custom_button(doc.update_stock ? __('Make Sales Return') : __('Make Credit Note'), + this.make_sales_return); } // Show buttons only when pos view is active