Make Debit / Credit Note button in Purchase / Sales Invoice
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
index 08ed4f3..e3245cb 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js
@@ -28,7 +28,7 @@
 					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 @@
 		})
 	},
 	
-	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 7e0ed7f..6e85087 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -411,6 +411,6 @@
 			'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 8348c08..017ab3a 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -65,7 +65,8 @@
 				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