From b691de0147cd6b5f19fa3fd9582fb18d97b74371 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Tue, 20 Jan 2026 15:08:37 +0530 Subject: [PATCH] fix: allow creation of DN in SI for items not having DN reference --- .../accounts/doctype/sales_invoice/sales_invoice.js | 10 ++-------- .../accounts/doctype/sales_invoice/sales_invoice.py | 4 +++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index c50eaa69a9f..caafdcedc23 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -115,15 +115,9 @@ erpnext.accounts.SalesInvoiceController = class SalesInvoiceController extends ( } if (cint(doc.update_stock) != 1) { - // show Make Delivery Note button only if Sales Invoice is not created from Delivery Note - var from_delivery_note = false; - from_delivery_note = this.frm.doc.items.some(function (item) { - return item.delivery_note ? true : false; - }); - - if (!from_delivery_note && !is_delivered_by_supplier) { + if (!is_delivered_by_supplier) { this.frm.add_custom_button( - __("Delivery"), + __("Delivery Note"), this.frm.cscript["Make Delivery Note"], __("Create") ); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 646d0418bc9..baa45166ba2 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -2470,7 +2470,9 @@ def make_delivery_note(source_name, target_doc=None): "cost_center": "cost_center", }, "postprocess": update_item, - "condition": lambda doc: doc.delivered_by_supplier != 1 and not doc.scio_detail, + "condition": lambda doc: doc.delivered_by_supplier != 1 + and not doc.scio_detail + and not doc.dn_detail, }, "Sales Taxes and Charges": {"doctype": "Sales Taxes and Charges", "reset_value": True}, "Sales Team": {