fix: don't create debit/credit note automatically (#19185)
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js
index 0926ecb..2ee6872 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.js
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.js
@@ -85,26 +85,13 @@
refresh: function(frm) {
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
frm.add_custom_button(__('Credit Note'), function() {
- frappe.confirm(__("Are you sure you want to make credit note?"),
- function() {
- frm.trigger("make_credit_note");
- }
- );
+ frappe.model.open_mapped_doc({
+ method: "erpnext.stock.doctype.delivery_note.delivery_note.make_sales_invoice",
+ frm: cur_frm,
+ })
}, __('Create'));
-
frm.page.set_inner_btn_group_as_primary(__('Create'));
}
- },
-
- make_credit_note: function(frm) {
- frm.call({
- method: "make_return_invoice",
- doc: frm.doc,
- freeze: true,
- callback: function() {
- frm.reload_doc();
- }
- });
}
});
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py
index bdb49e4..c98dfe3 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.py
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.py
@@ -458,6 +458,9 @@
doc = get_mapped_doc("Delivery Note", source_name, {
"Delivery Note": {
"doctype": "Sales Invoice",
+ "field_map": {
+ "is_return": "is_return"
+ },
"validation": {
"docstatus": ["=", 1]
}
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
index 8266055..2e8bc64 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js
@@ -41,28 +41,15 @@
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
frm.add_custom_button(__('Debit Note'), function() {
- frappe.confirm(__("Are you sure you want to make debit note?"),
- function() {
- frm.trigger("make_debit_note");
- }
- );
+ frappe.model.open_mapped_doc({
+ method: "erpnext.stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice",
+ frm: cur_frm,
+ })
}, __('Create'));
-
frm.page.set_inner_btn_group_as_primary(__('Create'));
}
},
- make_debit_note: function(frm) {
- frm.call({
- method: "make_return_invoice",
- doc: frm.doc,
- freeze: true,
- callback: function() {
- frm.reload_doc();
- }
- });
- },
-
company: function(frm) {
frm.trigger("toggle_display_account_head");
},
diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
index 0c8e9a0..fae4de3 100644
--- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
+++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.py
@@ -426,16 +426,6 @@
self.load_from_db()
- def make_return_invoice(self):
- return_invoice = make_purchase_invoice(self.name)
- return_invoice.is_return = True
- return_invoice.save()
- return_invoice.submit()
-
- debit_note_link = frappe.utils.get_link_to_form('Purchase Invoice', return_invoice.name)
-
- frappe.msgprint(_("Debit Note {0} has been created automatically").format(debit_note_link))
-
def update_billed_amount_based_on_po(po_detail, update_modified=True):
# Billed against Sales Order directly
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
@@ -510,7 +500,8 @@
"Purchase Receipt": {
"doctype": "Purchase Invoice",
"field_map": {
- "supplier_warehouse":"supplier_warehouse"
+ "supplier_warehouse":"supplier_warehouse",
+ "is_return": "is_return"
},
"validation": {
"docstatus": ["=", 1],